Skip to content

Instantly share code, notes, and snippets.

@wx13
wx13 / remove_output.py
Created November 14, 2014 22:18
Python script to remove outputs from an ipython notebook (without requiring ipython to be installed)
import json
from sys import argv
def strip_output(nb):
for ws in nb['worksheets']:
for cell in ws['cells']:
if 'outputs' in cell:
cell['outputs'] = []
if __name__ == '__main__':
@wx13
wx13 / tmuxx.sh
Last active December 26, 2015 19:19
Easy selection of available tmux sessions
#!/bin/bash
LD_LIBRARY_PATH=$HOME/local/lib
k=0
choices=()
while read line
do
k=$((k+1))
echo $k "$line"
@wx13
wx13 / gist:5810413
Created June 18, 2013 23:23
windows shortcut to a cygwin terminal program
C:\path-to-cygwin\bin\mintty.exe -he -l -e /bin/bash -c "PATH=$PATH:/bin/ && /path-to-program/program -z $1" "%1"
@wx13
wx13 / word_freq.sh
Created March 1, 2013 16:47
one-liner to get word frequencies from a file
strings $1 | sed 's/[^a-zA-Z0-9]/\n/g' | egrep '[a-zA-Z]{5}' | tr '[:upper:]' '[:lower:]' | awk '{++a[$1]}END{for(x in a){print a[x], x}}'
@wx13
wx13 / .bashrc
Created January 11, 2013 19:03
Current directory in window title; sup'd up 'cd' command.
# Put the CWD in the window title.
function chtt {
echo -en "\033]2;$@\007"
}
export PROMPT_COMMAND='chtt $(pwd)'
# Put the CWD in the window title.
function chtt {
echo -en "\033]2;$@\007"
}
export PROMPT_COMMAND='chtt $(pwd)'
@wx13
wx13 / .Xdefaults
Created December 7, 2012 21:49
Xdefaults keymap for mouse scrollwheel
xterm*VT100.translations: #override <Key>F1: keymap(x)
xterm*VT100.xKeymap.translations: \
<Key>F1: keymap(y) \n\
<Btn4Down>,<Btn4Up>: string("0x1B") string("[M`11") \n\
<Btn5Down>,<Btn5Up>: string("0x1B") string("[Ma11") \n\
Ctrl<Btn4Down>,<Btn4Up>: string("0x1B") string("[Mp11") \n\
Ctrl<Btn5Down>,<Btn5Up>: string("0x1B") string("[Mq11")
xterm*VT100.yKeymap.translations: \
<Key>F1: keymap(x) \n\
<Btn4Down>,<Btn4Up>: scroll-back(4,line) \n\
@wx13
wx13 / gist:3881163
Created October 12, 2012 19:56
auto update gh-pages from doc dir
#!/bin/bash
# found at: http://happygiraffe.net/blog/2009/07/04/publishing-a-subdirectory-to-github-pages/
parent_sha=$(git show-ref -s refs/heads/gh-pages)
doc_sha=$(git ls-tree -d HEAD jslint4java-docs/src/main/resources | awk '{print $3}')
new_commit=$(echo "Auto-update docs." | git commit-tree $doc_sha -p $parent_sha)
git update-ref refs/heads/gh-pages $new_commit
@wx13
wx13 / gist:3308884
Created August 9, 2012 23:08
read octave code in from a named pipe
f = fopen('blah','r'); while ~feof(f); line = fgetl(f); eval(line); fflush(stdout); end; fclose(f);
@wx13
wx13 / octave_pty.rb
Created August 9, 2012 19:50
ruby/pty interaction with octave in real-time
require 'pty'
def till_prompt(cout)
buffer = ""
loop { buffer << cout.getc.chr; break if buffer =~ /octave:.*>/ }
return buffer
end
def octave(string)
@octave_in.printf("#{string}\n")
@wx13
wx13 / jedi.bat
Created March 9, 2012 23:23
windows batch script to open a file in a cygwin editor (replace "jedi" with editor of your choice)
@echo off
C:
chdir C:/Users/jdevita/cygwin/bin
set HOME=\Users\jdevita\cygwin\home\jdevita
echo %1 > C:/Users/jdevita/cygwin/tmp/temp.txt
bash --login -i -c "jedi \"$(sed -e 's/\"//g' -e 's/\([A-Z]\):/\/cygdrive\/\1/' -e 's/\\\/\//g' -e 's/ *$//' /tmp/temp.txt)\""