Skip to content

Instantly share code, notes, and snippets.

Ryan Wilson-Perkin ryanwilsonperkin

Block or report user

Report or block ryanwilsonperkin

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
ryanwilsonperkin /
Created Jun 3, 2014
Version control the way OutKast intended.
git config alias.up commit
git config alias.out push
git config alias.something pull
ryanwilsonperkin /
Created Sep 13, 2014
Register a shell function called ldapuser to search the University of Guelph's LDAP server for a record with the given username.
# Use as `ldapuser username` to lookup ldap record for "username"
function ldapuser {
ldapsearch -x -H ldap:// -b "ou=People," "uid=$1"
ryanwilsonperkin /
Last active Mar 8, 2016
Python method for fetching deeply nested dict keys à la ImmutableJS.getIn
def deep_get(o, keys):
return reduce(lambda prev, current: prev.get(current, {}), keys, o) or None
import random
class ShittyList(list):
def __len__(self):
min, max = 0, super(ShittyList, self).__len__()
return random.randrange(min, max)
View comprehension.js
// Clever
function comprehension(arr, fn) {
return arr.reduce((obj, key) => Object.assign(obj, {[key]: fn(key)}), {});
// Legible
function comprehension(arr, fn) {
const obj = {};
for (key of arr) {
obj[key] = fn(key);

Keybase proof

I hereby claim:

  • I am ryanwilsonperkin on github.
  • I am ryanwilsonperkin ( on keybase.
  • I have a public key whose fingerprint is 5664 AF96 D17B 16E8 F21B F431 FBA8 1CE4 75C6 7F0D

To claim this, I am signing this object:

# Having fun with context managers
from contextlib import contextmanager
def deity():
print 'The Father'
print 'The Holy Ghost'
god = deity()
ryanwilsonperkin / webpack.config.js
Created Feb 23, 2017
Webpack: chunkhash in production, hash in development
View webpack.config.js
const PRODUCTION = process.env.NODE_ENV === 'production';
const HASH_MODE = PRODUCTION ? 'chunkhash' : 'hash';
module.exports = {
output: {
filename: `[name].[${HASH_MODE}].js`,
chunkFilename: `[name].[${HASH_MODE}].js`,
ryanwilsonperkin /
Last active Nov 23, 2017
Different types of decorators
# Regular decorator
def decorator(f):
def wrapped(*args, **kwargs):
result = f(*args, **kwargs)
return result
return wrapped
# Regular decorator usage


A simple way to get line profiling on your python functions.

  1. pip install line_profiler
  2. Decorate your function with @profile (no import needed)
  3. Launch a shell with kernprof -l shell
  4. Call the function you want to profile. Preferably several times! (%timeit is great for running it several times)
  5. Exit the shell. You'll see a dumped file created called
You can’t perform that action at this time.