Skip to content

Instantly share code, notes, and snippets.

View dmarx's full-sized avatar

David Marx dmarx

View GitHub Profile
@minrk
minrk / nbstripout
Last active June 6, 2023 06:23
git pre-commit hook for stripping output from IPython notebooks
#!/usr/bin/env python
"""strip outputs from an IPython Notebook
Opens a notebook, strips its output, and writes the outputless version to the original file.
Useful mainly as a git filter or pre-commit hook for users who don't want to track output in VCS.
This does mostly the same thing as the `Clear All Output` command in the notebook UI.
LICENSE: Public Domain
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active May 17, 2024 12:37
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

@cfobel
cfobel / color-brewer-qualitative.gpl
Created December 4, 2014 13:34
8 colors light/medium/dark color-brewer-qualitative color palette
GIMP Palette
Name: color-brewer-qualitative
Columns: 3
# This color palette combines the following three palletes developed
# by Cynthia Brewer (see http://colorbrewer2.org/):
# - Dark2_8.gpl
# - Pastel2_8.gpl
# - Set2_8.gpl
179 226 205 light_cyan
253 205 172 light_orange
@alexsavio
alexsavio / mcmc
Last active October 2, 2020 22:35 — forked from osdf/gist:5133737
Simple MCMC sampling with Python
"""
Some python code for
Markov Chain Monte Carlo and Gibs sampling
by Bruce Walsh
"""
import numpy as np
import numpy.linalg as npla
@pbugnion
pbugnion / ipython_notebook_in_git.md
Last active October 22, 2023 12:25
Keeping IPython notebooks under Git version control

This gist lets you keep IPython notebooks in git repositories. It tells git to ignore prompt numbers and program outputs when checking that a file has changed.

To use the script, follow the instructions given in the script's docstring.

For further details, read this blogpost.

The procedure outlined here is inspired by this answer on Stack Overflow.

@karpathy
karpathy / min-char-rnn.py
Last active May 19, 2024 16:44
Minimal character-level language model with a Vanilla Recurrent Neural Network, in Python/numpy
"""
Minimal character-level Vanilla RNN model. Written by Andrej Karpathy (@karpathy)
BSD License
"""
import numpy as np
# data I/O
data = open('input.txt', 'r').read() # should be simple plain text file
chars = list(set(data))
data_size, vocab_size = len(data), len(chars)
@thomasp85
thomasp85 / animate.R
Created February 3, 2016 19:43
Animating graph over time
library(ggraph)
library(gganimate)
library(igraph)
# Data from http://konect.uni-koblenz.de/networks/sociopatterns-infectious
infect <- read.table('out.sociopatterns-infectious', skip = 2, sep = ' ', stringsAsFactors = FALSE)
infect$V3 <- NULL
names(infect) <- c('from', 'to', 'time')
infect$timebins <- as.numeric(cut(infect$time, breaks = 100))
# We want that nice fading effect so we need to add extra data for the trailing
@shagunsodhani
shagunsodhani / LIME.md
Created January 28, 2017 12:32
Summary of "Why Should I Trust You? Explaining the Predictions of Any Classifier" paper

"Why Should I Trust You?": Explaining the Predictions of Any Classifier

Introduction

  • The paper introduces a novel technique to explain the predictions of any classifier in an interpretable and faithful manner.
  • It also proposes a method to explain models by obtaining representative individual predictions and their explanations.
  • Link to the paper
  • Demo

Desired Characteristics for Explanations

@tomfa
tomfa / handler.py
Last active February 14, 2023 15:08
AWS Lambda: Python store to S3
# This file is your Lambda function
import json
import boto3
def save_to_bucket(event, context):
AWS_BUCKET_NAME = 'my-bucket-name'
s3 = boto3.resource('s3')
bucket = s3.Bucket(AWS_BUCKET_NAME)
path = 'my-path-name.txt'
@gilrosenthal
gilrosenthal / Fast.ai install script
Created July 4, 2018 20:14
Fast.ai Install on Google Colab
!pip install fastai
!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-python
import cv2
from os import path
from wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tag
platform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())
accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'
!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision