Skip to content

Instantly share code, notes, and snippets.

Reid Williams ReidWilliams

Block or report user

Report or block ReidWilliams

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
ReidWilliams / inspect.js
Created Jul 13, 2015
Inspect functions that are part of a promise chain
View inspect.js
// Uses underscore.js to wrap a function and upon calling
// prints the function source and the argument.
// Useful for debugging chains of promises.
// var myfunction = function(argument) {...};
// myfunction = inspect(myfunction); // myfunction is now instrumented
var _ = require('underscore');
var util = require('util');
var inspect = function(fnToInspect) {
ReidWilliams /
Last active Jan 27, 2017
One line command to kill node debug processes on Mac OS
kill -9 $(ps -ef | grep '[n]ode --debug-brk=5858' | awk '{print $2}')
while true; do rsync -e "ssh -i /PATH/TO/PRIVATE/KEY.pem" -azvh --delete ./LOCAL-REPO/ ec2-user@IP:/REMOTE/PATH; sleep 2; done
ReidWilliams /
Last active Nov 28, 2017
resize crop with imagemagick
# resize all files in directory <in> so that the shorter dimension (or both dims) is 64 pixels, then
# crop the longer dimension to 64 pixels.
magick convert in/* -resize 64x64^ -gravity center -extent 64x64 'out/%06d.jpg'
# crop images using find / exec. Find / exec is useful when there are many images and file globs don't work.
# Crop to 1150 by 512 at the top, left edge of the image
find ./*.jpg -exec magick convert {} -crop 1150x512+0+0 {} \;
ReidWilliams /
Created Dec 5, 2017
SSH with port forwarding
# Easy way to remotely access a Jupyter notebook, by forwarding a port
# Forward local port 8888 to the remote's localhost port 8888
ssh -L 8888:localhost:8888 user@
ReidWilliams / anaconda.txt
Created Dec 15, 2017
Anaconda cheatsheet
View anaconda.txt
# create environment with jupyter
conda create -n ENVNAME python=3 jupyter
ReidWilliams / freeze-install.txt
Created Jan 30, 2018
Python: freeze and install packages
View freeze-install.txt
$ pip freeze > requirements.txt
$ pip install -r requirements.txt
ReidWilliams / pandas.txt
Last active Feb 22, 2018
Pandas cheatsheet
View pandas.txt
# rename a dataframe column
dataframe = dataframe.rename(index=str, columns={'old_col_name': 'new_col_name'})
# get all possible values for a string / categorical column
# group data and count number of rows in a group
grouped = dataframe.groupby(color)
nreds = len(grouped.get_group('red'))
View gist:20cfdeb1dd4d90201b24d40a3e5a181d
def estimate(self, X):
""" Use saved model to predict/estimate retention probability.
X (dict): dictionary of features, values.
Automatically uses model trained on same set of features as
X argument.
List of one element, retention probability.
ReidWilliams / component.story.js
Created Nov 20, 2018
Storybook story template
View component.story.js
// Dependencies
import React from 'react'
import { storiesOf } from '@storybook/react'
import centered from '@storybook/addon-centered'
import { action } from '@storybook/addon-actions'
// Local Dependencies
import { ComponentDecorator } from 'stories/decorators'
import MyComponent from './index'
You can’t perform that action at this time.