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
ryanwilsonperkin / git_up_git_out.sh
Created Jun 3, 2014
Version control the way OutKast intended.
View git_up_git_out.sh
# http://www.youtube.com/watch?v=CssC-DY4lO8
git config alias.up commit
git config alias.out push
git config alias.something pull
@ryanwilsonperkin
ryanwilsonperkin / ldapuser.sh
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.
View ldapuser.sh
# Use as `ldapuser username` to lookup ldap record for "username"
function ldapuser {
ldapsearch -x -H ldap://directory.uoguelph.ca -b "ou=People,o=uoguelph.ca" "uid=$1"
}
@ryanwilsonperkin
ryanwilsonperkin / react_links.md
Last active May 25, 2018
Useful links for those new to the react ecosystem
View react_links.md
@ryanwilsonperkin
ryanwilsonperkin / deep_get.py
Last active Mar 8, 2016
Python method for fetching deeply nested dict keys à la ImmutableJS.getIn
View deep_get.py
def deep_get(o, keys):
return reduce(lambda prev, current: prev.get(current, {}), keys, o) or None
View shitty_python.py
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);
View keybase.md

Keybase proof

I hereby claim:

  • I am ryanwilsonperkin on github.
  • I am ryanwilsonperkin (https://keybase.io/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:

View contextmanagers.py
# Having fun with context managers
from contextlib import contextmanager
@contextmanager
def deity():
print 'The Father'
yield
print 'The Holy Ghost'
god = deity()
View profiling.md

Profiling!

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 manage.py 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 manage.py.lprof
@ryanwilsonperkin
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`,
},
...
};
You can’t perform that action at this time.