This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import collections | |
def flatten(l): | |
for el in l: | |
if isinstance(el, collections.Iterable) and not isinstance(el, (str, bytes)): | |
yield from flatten(el) | |
else: | |
yield el |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import functools | |
from boto3.exceptions import ThrottlingException | |
def throttling_handler(func): | |
@functools.wraps(func) | |
def wrapper(*args, **kwargs): | |
while True: | |
try: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
export PROJECT_DIR=$(git rev-parse --show-toplevel) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from copy import deepcopy | |
import networkx as nx | |
import numpy as np | |
import pandas as pd | |
import matplotlib.pyplot as plt | |
G = nx.DiGraph() | |
class Literal(str): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import subprocess | |
import re | |
def get_windows(): | |
list_of_windows = subprocess.check_output(["wmctrl","-l"]).split(b"\n") | |
meta_list_of_windows = [s.decode("utf-8").split() for s in list_of_windows if s] | |
user_processes = {} | |
for line in meta_list_of_windows: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def grid_plot(x_label, y_label, z_label, data, ax=None): | |
""" Useful if you have a dataframe, with a certain number of unique categories or values in x and y, | |
and you want to compare them visually to a third continuous value. """ | |
if ax is None: | |
ax = plt.gca() | |
x_val = np.sort(np.unique(data[x_label])) | |
y_val = np.sort(np.unique(data[y_label])) | |
x_idx = np.arange(len(x_val)) | |
y_idx = np.arange(len(y_val)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import random as rand | |
from functools import partial | |
def twiddle(run, args, p, dp, tol = 0.2, N = 100, logger = None): | |
""" Uses gradient descent to find the optimal value of p as input for function run. | |
run is a function which takes p as an argument and returns an error (with 0 being optimal) as an output. | |
dp is the initial magnitute for each index of p to begin | |
N is the max number of iterations, after which the best value of p is returned. | |
tol is the max error allowed, under which this function will terminate. """ | |
best_err, best_p, best_dp, n = 1000000, None, None, 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" Python 3 implementation of Deep Learning book early stop algorithm. | |
@book{Goodfellow-et-al-2016, | |
title={Deep Learning}, | |
author={Ian Goodfellow and Yoshua Bengio and Aaron Courville}, | |
publisher={MIT Press}, | |
note={\url{http://www.deeplearningbook.org}}, | |
year={2016} | |
} | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import cv2 | |
import random | |
import scipy.stats | |
# Matplotlib | |
import matplotlib as mpl | |
mpl.use('Agg') | |
import matplotlib.pyplot as plt |
NewerOlder