Skip to content

Instantly share code, notes, and snippets.

@stuntgoat
stuntgoat / getline.sh
Created April 17, 2014 01:29
get a single line by line number from a file with bash
function getl() {
if [ "$1" -a "$2" ]
then
tail -n+"$1" "$2" | head -n1
else
echo "Usage: getl "
fi
}
@stuntgoat
stuntgoat / debug.py
Created March 11, 2014 23:00
debug a function call. Put this in your ipython startup file.
def dbgf(f, *args, **kwargs):
"""
Debug a function call.
"""
import pdb; pdb.set_trace()
f(*args, **kwargs)

All of the categories!

I wrote a really simple JavaScript script that uses jQuery to extract all the categories from Facebook's "Create a page" page.

Instructions

  1. Navigate to the Create a page page.
  2. jQuerify the page.
  3. Open up your JavaScript console of choice and run the following script:
~/py/tluster $ word-analogy vectors.bin
Enter three words (EXIT to break): man king woman
Word: man Position in vocabulary: 137
Word: king Position in vocabulary: 900
Word: woman Position in vocabulary: 635
Word Distance
(defsynth foo [freq 200 dur 1]
"
defines the foo synth. Taken from the Overtone example
https://github.com/overtone/overtone/blob/master/src/overtone/examples/getting_started/basic.clj
"
(let [src (saw [freq (* freq 1.01) (* 0.99 freq)])
low (sin-osc (/ freq 2.1))
filt (lpf src (line:kr (* 10 freq) freq 10))
env (env-gen (perc 0.1 dur) :action FREE)]
@stuntgoat
stuntgoat / indent_sql.el
Created February 10, 2014 08:55
An indentation heuristic for Emacs' sql-mode
(defun get-previous-indentation ()
"Get the column of the previous indented line"
(interactive)
(save-excursion
(progn
(move-beginning-of-line nil)
(skip-chars-backward "\n \t")
(back-to-indentation))
(current-column)))
@stuntgoat
stuntgoat / pre-commit.sh
Last active April 30, 2024 02:11
Git pre-commit hook for finding Python added 'print' statements.
#!/bin/sh
# To enable this hook, rename this file to "pre-commit".
###############################################################################
# https://gist.github.com/stuntgoat/8800170
# Git pre-commit hook for finding and warning about Python print
# statements.
#
@stuntgoat
stuntgoat / ex.ck
Last active December 31, 2015 11:29
// TODO:
// create an array for each pulse on/off cycle
// an array of volume
// an array for
"audio/hey.wav" => string hey;
"audio/hi.wav" => string hi;
"audio/ho.wav" => string ho;
@stuntgoat
stuntgoat / .screerc
Last active December 30, 2015 23:49
# a lot of screen history saved
defscrollback 500000
# for emacs bindings
markkeys "h=^B:l=^F:$=^E"
# output a screen copy buffer to mac os pasteboard
bufferfile /tmp/screen-exchange
bind y eval writebuf "exec sh -c 'pbcopy < /tmp/screen-exchange'"
@stuntgoat
stuntgoat / pandas_notes.py
Last active March 8, 2016 01:45
notes on using Pandas
# read csv
df = pd.read_csv("<filename>")
# show duplicates; returns series of bools
dup_indexes = r.duplicated(cols=("colname1", "colname2"))
# remove duplicates; in place
df.drop_duplicates("colname1", "colname2", inplace=True)
# drop a column