Skip to content

Instantly share code, notes, and snippets.

View JonathanLoscalzo's full-sized avatar

Jonathan Loscalzo JonathanLoscalzo

View GitHub Profile
@JonathanLoscalzo
JonathanLoscalzo / chmodCheatSheet.md
Created October 12, 2021 23:54 — forked from juanarbol/chmodCheatSheet.md
Chmod cheat sheet

Chmod codes cheat sheet

How to use chmod codes in UNIX:

  1. There are three types of permissions in files and folders in unix
    1. Read (r)
    2. Write (w)
    3. Execute (x)
  2. And, there is a classification of users called UGO (explained bellow):
  3. U ~> User (usually, you)
@okld
okld / multipage_settings_app.py
Last active July 11, 2024 23:55
Streamlit - Settings page with session state
import streamlit as st
from persist import persist, load_widget_state
def main():
if "page" not in st.session_state:
# Initialize session state.
st.session_state.update({
# Default page.
"page": "home",
@aditya-malte
aditya-malte / smallberta_pretraining.ipynb
Created February 22, 2020 13:41
smallBERTa_Pretraining.ipynb
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tvst
tvst / SessionState.py
Last active April 14, 2024 20:24
DO NOT USE!!! Try st.session_state instead.
"""Hack to add per-session state to Streamlit.
Usage
-----
>>> import SessionState
>>>
>>> session_state = SessionState.get(user_name='', favorite_color='black')
>>> session_state.user_name
''
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@davidejones
davidejones / handler_fieldstorage.py
Created May 2, 2018 15:24
aws lambda parsing multipart form with python3
from cgi import FieldStorage
from io import BytesIO
def parse_into_field_storage(fp, ctype, clength):
fs = FieldStorage(
fp=fp,
environ={'REQUEST_METHOD': 'POST'},
headers={
'content-type': ctype,
@alexcasalboni
alexcasalboni / aws-lambda-static-type-checker.md
Last active May 22, 2023 07:31
AWS Lambda Static Type Checker Example (Python3)

How to use Python3 Type Hints in AWS Lambda

TL;DR

Static Type Checkers help you find simple (but subtle) bugs in your Python code. Check out lambda_types.py and incrementally improve your code base and development/debugging experience with type hints.

Your Lambda Function code will go from this:

@ramhiser
ramhiser / huber.py
Created January 21, 2015 17:39
Robust Estimation of Mean and Standard Deviation in Python via the Huber Estimator
import numpy as np
from statsmodels.robust.scale import huber
# Mean and standard deviation to generate normal random variates
mean, std_dev = 0, 2
sample_size = 25
np.random.seed(42)
x = np.random.normal(mean, std_dev, sample_size)
# Appends a couple of outliers
@martinnormark
martinnormark / BusinessLogicInstaller.cs
Created July 17, 2012 09:17
Castle Windsor IoC Container setup for ASP.NET MVC
using Castle.MicroKernel.Registration;
using Castle.MicroKernel.SubSystems.Configuration;
using Castle.Windsor;
using MyApp.BusinessLogic.Facades;
namespace MyApp.Web.PresentationLogic.Container
{
public class BusinessLogicInstaller : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
@hyle
hyle / ko.utils.signatures.js
Last active May 14, 2022 21:15
KnockoutJS utils (ko.utils) signatures
// knockout 2.2.1
ko.utils.arrayFilter = function (array, predicate) { /* .. */ }
ko.utils.arrayFirst = function (array, predicate, predicateOwner) { /* .. */ }
ko.utils.arrayForEach = function (array, action) { /* .. */ }
ko.utils.arrayGetDistinctValues = function (array) { /* .. */ }