Skip to content

Instantly share code, notes, and snippets.

View ryanholbrook's full-sized avatar

Ryan Holbrook ryanholbrook

View GitHub Profile
@ma7dev
ma7dev / cool_script.sh
Last active September 5, 2022 13:23
takes requirements.txt file without module versions and annotates it with the latest set of module versions that won't result in build/runtime errors.
#!/bin/bash
# TODO: you will need to have conda installed
# create a python environment
conda create -n env_tmp python=3.8.13 -y
# activate environment
conda activate env_tmp
@niklasschmitz
niklasschmitz / jaxpr_graph.py
Last active January 7, 2024 19:15 — forked from mattjj/grad_graph.py
visualizing jaxprs
import jax
from jax import core
from graphviz import Digraph
import itertools
styles = {
'const': dict(style='filled', color='goldenrod1'),
'invar': dict(color='mediumspringgreen', style='filled'),
'outvar': dict(style='filled,dashed', fillcolor='indianred1', color='black'),
@MilesCranmer
MilesCranmer / matrix_box_notation.tex
Last active February 9, 2021 10:49
Draw boxes for matrices in equation
%Make sure to have \usepackage{tikz}
%https://tex.stackexchange.com/a/45815/140440 - for grid
%https://tex.stackexchange.com/a/381175/140440 - for alignment in equation
% This function draws a matrix.
\newcommand{\mat}[2]{% cols, rows
\vcenter{\hbox{ %Vertical alignment
\begin{tikzpicture}[scale=0.3, align=center]
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@danmou
danmou / auto_shape_mixin.py
Created December 5, 2019 10:00
Mixin for `tf.keras.layers.Layer`s and subclasses to automatically define input and output specs the first time the model is called.
from typing import Any, Mapping, Optional, Sequence, TypeVar, Union
import tensorflow as tf
from tensorflow.keras import layers
T = TypeVar('T')
Nested = Union[T, Sequence[T], Mapping[Any, T]]
class AutoShapeMixin:
@tfeldmann
tfeldmann / duplicates.py
Last active January 19, 2024 23:36
Fast duplicate file finder written in python
#!/usr/bin/env python
"""
Fast duplicate file finder.
Usage: duplicates.py <folder> [<folder>...]
Based on https://stackoverflow.com/a/36113168/300783
Modified for Python3 with some small code improvements.
"""
import os
import sys
@behrica
behrica / maps.org
Last active August 15, 2021 09:51
Proof of concept for htmlwidget integration in org mode
renderDeps <- function(widget,dir=".",libdir="lib") {
  rendered <- htmltools::renderTags(widget)

  deps <- lapply(rendered1$dependencies, function(dep) {
    dep <- htmltools::copyDependencyToDir(dep, libdir, FALSE)
    dep <- htmltools::makeDependencyRelative(dep, dir, FALSE)
@bshishov
bshishov / forecasting_metrics.py
Last active April 20, 2024 04:29
Python Numpy functions for most common forecasting metrics
import numpy as np
EPSILON = 1e-10
def _error(actual: np.ndarray, predicted: np.ndarray):
""" Simple error """
return actual - predicted
@MMesch
MMesch / robust_splines_sklearn.py
Last active July 6, 2023 23:04
Robust Spline Regression with Scikit-Learn
#!/usr/bin/env python
"""
Robust B-Spline regression with scikit-learn
"""
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate as si
from sklearn.base import TransformerMixin
from sklearn.pipeline import make_pipeline
@gilbertw1
gilbertw1 / .Xresources
Last active December 2, 2022 10:51
XMonad Configuration
Xft.dpi: 120
Xft.antialias: true
Xft.hinting: true
Xft.rgba: rgb
Xft.hintstyle: hintslight
rofi.color-enabled: true
rofi.color-window: #282828, #282828, #268bd2
rofi.color-normal: #282828, #ffffff, #282828, #268bd2, #ffffff
rofi.color-active: #282828, #268bd2, #282828, #268bd2, #205171