Skip to content

Instantly share code, notes, and snippets.

View epignatelli's full-sized avatar
🍀

Eduardo Pignatelli epignatelli

🍀
View GitHub Profile
@epignatelli
epignatelli / insert_copyright.sh
Created January 27, 2023 11:33
Add copyright header to all python files in all directories and sub-directories
@epignatelli
epignatelli / code_interview_utils.py
Last active November 2, 2022 16:26
Useful coding interview utility functions
import decimal
import math
from typing import List
def is_prime(n: int) -> bool:
if n == 0:
return False
if n == 1:
return False
# activate shell
source $HOME/anaconda3/etc/profile.d/conda.sh
./anaconda3/bin/conda init
# download privacy notebook
git clone https://[email protected]/astanziola/privacy-exercise
conda env create -f privacy-exercise/env/environment.yml
# download computer vision notebook
git clone https://[email protected]/epignatelli/scalable-recognition-with-a-vocabulary-tree

A computer program can be seen simultaneously as a set of computer instructions or as concrete poetry formed by the indentations in the text of the program. Nicholas Negroponte, Being Digital, 1995.

Here lies a lake of data that will never be found.
In a variable called start is an int that will never be parsed.
In a variable called stop is a string that will never be trimmed.
In a variable called step is a string that will never be concatenated.
Here lies a lake of data that will never be found.
109 111 110 103 111 100 98 43 115 114 118 58 47 47 112 108 97 121 101 114 58 111 109 65 115 105 108 117 120 99 65 75 55 105 77 104 70 64 99 108 117 115 116 101 114 48 46 48 114 121 117 119 46 109 111 110 103 111 100 98 46 110 101 116

@epignatelli
epignatelli / box_upload_with_refresh.py
Last active August 25, 2021 07:45
Script to upload to box with token refresh by default
import os
from boxsdk import Client, OAuth2
from tqdm import tqdm
import keyring
CLIENT_ID = os.environ["BOX_CLIENT_ID"]
CLIENT_SECRET = os.environ["BOX_CLIENT_SECRET"]
@epignatelli
epignatelli / icon-gmail.html
Last active December 28, 2024 17:27
Fontawesome icon for Gmail
// gmail.svg
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 24" width="64" height="64"><path d="M29.986 27.715H2.008C.915 27.715 0 26.85 0 25.733V6.376A2.01 2.01 0 0 1 2.008 4.37h27.978c1.093 0 2.008.9 2.008 2.008v19.33c-.025 1.144-.915 2.008-2.008 2.008z" fill="#f2f2f2"/><path d="M4 27.715l11.97-8.76.076-.508L3.7 9.578l-.025 17.705z" opacity=".1" fill="#221f1f"/><g fill="#d44c3d"><path d="M2.008 27.715C.9 27.715 0 26.85 0 25.733V6.35c0-1.118.9-1.32 2.008-1.32s2.008.23 2.008 1.32v21.364z"/><path d="M2.008 5.334c1.423 0 1.703.432 1.703 1.016v21.084H2.008c-.94 0-1.703-.762-1.703-1.703V6.35c-.025-.6.28-1.016 1.703-1.016zm0-.28C.9 5.055 0 5.283 0 6.35v19.356a1.98 1.98 0 0 0 2.008 2.008h2.008V6.35C4 5.258 3.126 5.055 2.008 5.055zm27.978.28c1.296 0 1.703.254 1.703.966v19.458c0 .94-.762 1.703-1.703 1.703h-1.703V6.3c-.025-.737.407-.966 1.703-.966zm0-.28c-1.118 0-2.008.152-2.008 1.245v21.44h2.008c1.118 0 2.008-.9 2.008-2.008V6.274c-.025-1.093-.915-1.22-2.008-1.22z"/><path d="M29.986 27.715h-2.008V6.3c0-1.118
@epignatelli
epignatelli / icon-scholar.html
Created December 25, 2020 16:50
Fontawesome icon for Google Scholar
// google-scholar.svg
<svg height="2500" width="2500" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<g fill="none" fill-rule="evenodd"><path d="M256 411.12L0 202.667 256 0z" fill="#4285f4"/>
<path d="M256 411.12l256-208.453L256 0z" fill="#356ac3"/>
<circle cx="256" cy="362.667" fill="#a0c3ff" r="149.333"/>
<path d="M121.037 298.667c23.968-50.453 75.392-85.334 134.963-85.334s110.995 34.881 134.963 85.334H121.037z" fill="#76a7fa"/>
</g>
</svg>
// style.css
@epignatelli
epignatelli / stax_template.py
Created November 18, 2020 18:20
A template for buiding deep NNs with stax
import jax
import jax.numpy as jnp
@jax.jit
def compute_loss(y_hat: jnp.ndarray, y: jnp.ndarray):
raise NotImplementedError
@partial(jax.jit, static_argnums=0)
@epignatelli
epignatelli / jax_stax_module_decorator.py
Last active October 28, 2020 14:15
a module decorator for jax.experimental.stax
from typing import Tuple, NamedTuple, Callable, Any
import functools
import jax.numpy as jnp
Params = Any
RNGKey = jnp.ndarray
Shape = Tuple[int]
"""
This gist is an extract from:
https://github.com/epignatelli/reinforcement-learning-an-introduction
"""
def policy_evaluation(env, policy=None, steps=1, discount=1., in_place=False):
"""
Args:
policy (numpy.array): a numpy 3-D numpy array, where the first two dimensions identify a state and the third dimension identifies the actions.
The array stores the probability of taking each action.