Skip to content

Instantly share code, notes, and snippets.

View philadams-zz's full-sized avatar

Phil Adams philadams-zz

View GitHub Profile

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
### MATPLOTLIBRC FORMAT
# This is a sample matplotlib configuration file - you can find a copy
# of it on your system in
# site-packages/matplotlib/mpl-data/matplotlibrc. If you edit it
# there, please note that it will be overridden in your next install.
# If you want to keep a permanent local copy that will not be
# over-written, place it in HOME/.matplotlib/matplotlibrc (unix/linux
# like systems) and C:\Documents and Settings\yourname\.matplotlib
# (win32 systems).
@philadams-zz
philadams-zz / gist:6271864
Last active December 21, 2015 07:29
brew upgrade git issues...
> brew doctor
Warning: An outdated version of Git was detected in your PATH.
Git 1.7.10 or newer is required to perform checkouts over HTTPS from GitHub.
Please upgrade: brew upgrade git
> brew upgrade git
==> Upgrading 1 outdated package, with result:
git 1.8.3.4
==> Upgrading git
git: No `python` found in your PATH! Consider to `brew install python`.
@philadams-zz
philadams-zz / R split one column into multiple others
Last active December 19, 2015 07:29
Sometimes in a survey you have a question of the type, "... please select all that apply". In super awesome survey software, the returned data arrives with a column for each of the options so your software and graphs can easily know about each option's presence of absence. In super awesome survey software that only fails on this one point (like …
splitcol = function(x, newcols, targetCol) {
# delete commas IN THE STATEMENTS SEPARATED BY COMMAS ROFLMAO
x[[targetCol]] = sub('tablet, such', 'tablet such', x[[targetCol]])
x[[targetCol]] = sub('phone, tablet, or', 'phone tablet or', x[[targetCol]])
# check for presence of known examples (newcols[2])
for (i in newcols) {
x[[i[1]]] = ifelse(grepl(i[2], x[[targetCol]]), 1, 0)
}
write.table(file=pipe("pbcopy"), mydata, row.names=FALSE, sep="\t")
@philadams-zz
philadams-zz / x256 colors
Created February 23, 2013 00:27
print all xterm-256 and -16 colors
#! /usr/bin/env python
# Display the colors available in a terminal.
print "16-color mode:"
for color in range(0, 16) :
for i in range(0, 3) :
print "\033[0;%sm%02s\033[m" % (str(color + 30), str(color)),
print
@philadams-zz
philadams-zz / Read SPSS file with custom headers in R
Created December 10, 2012 21:03
Read SPSS file with custom headers in R
library('memisc')
args = commandArgs(trailingOnly=TRUE)
fname = args[1]
myData = as.data.set(spss.system.file(fname))
@philadams-zz
philadams-zz / grep_emails.sh
Created June 28, 2012 15:18
grep all email addresses from a file
grep -E -o "\b[a-zA-Z0-9.-]+@[a-zA-Z0-9.-]+\.[a-zA-Z0-9.-]+\b" filename.txt
@philadams-zz
philadams-zz / webgl-detect.js
Created January 31, 2012 07:47
WebGL Javascript Detection
// JQuery only used for selecting and removing elements,
// mostly left in for the below ALERT.
// the console.log statements are for your sanity checks.
var asa; var canvas; var dcanvas; var gl; var expmt;
canvas = $('#my-canvas');
console.log(canvas);
// check to see if we can do webgl
# PIL doesn't know OS X comes with freetype. Add links before (re)installing.
# Now you can just install jpeg using homebrew, and then PIL with pip.
ln -s /usr/X11/include/freetype2 /usr/local/include/
ln -s /usr/X11/include/ft2build.h /usr/local/include/
ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/
ln -s /usr/X11/lib/libfreetype.6.dylib /usr/local/lib/libfreetype.dylib