Skip to content

Instantly share code, notes, and snippets.

View davidh-raybeam's full-sized avatar

David Hollis davidh-raybeam

View GitHub Profile
@davidh-raybeam
davidh-raybeam / brew config
Created June 14, 2012 18:41
Homebrew Python2.4 Install Output
$ brew --config
HOMEBREW_VERSION: 0.9
HEAD: c2a04d3b18daa497cd0d6f25163ea118a151f8b3
HOMEBREW_PREFIX: /usr/local
HOMEBREW_CELLAR: /usr/local/Cellar
CPU: 8-core 64-bit sandybridge
OS X: 10.7.4
Kernel Architecture: x86_64
Xcode: 4.3.3
GCC-4.0: N/A
@davidh-raybeam
davidh-raybeam / list.html
Created July 19, 2012 20:39
Stupid Table Sizing Fix
<!-- ... -->
<td>
<p class="option-text">Blah blah blah</p>
</td>
<!-- ... -->
@davidh-raybeam
davidh-raybeam / regexen.rb
Created July 31, 2012 16:19 — forked from sionide21/regexen.rb
Regex game regression tester
class Regexen
def initialize(a={})
a.default_proc = proc { |h,k| [] }
@good = a[:good]
@bad = a[:bad]
end
def good=(r)
@good << r
end
def bad=(r)
@davidh-raybeam
davidh-raybeam / .bashrc
Created February 14, 2013 19:57
A shell function and script to run a command as another user. Invoke as `runas USER COMMAND`
# ...
runas ()
{
usr=$1;
shift;
sudo -u $usr /path/to/with_env.sh $@
}
# ...
@davidh-raybeam
davidh-raybeam / gist:5162503
Created March 14, 2013 15:50
Apparently python actually creates local variables for list comprehensions. I always assumed that comprehension expressions created their own scope.
$ python
Python 2.7.1 (r271:86832, Jul 31 2011, 19:30:53)
[GCC 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2335.15.00)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> x = 42
>>> l = [1,2,3,4,5]
>>> [x*x for x in l]
[1, 4, 9, 16, 25]
>>> x
5
@davidh-raybeam
davidh-raybeam / PL : NL ::
Last active December 15, 2015 04:09
A quick comparison of programming and natural languages.
syntactic atoms : vocabulary
language features and larger syntatctic constructs : grammar
idioms, patterns : idioms
3rd-party code : literature
source-code repositories : corpora
@davidh-raybeam
davidh-raybeam / .bashrc
Created March 20, 2013 19:32
A simple shell function to quickly stub out python packages.
pypkg () {
local pkgpath="$(echo $1 | sed 's:\.: :g')"
local fspath="."
for el in $pkgpath; do
fspath="${fspath}/${el}"
(mkdir "$fspath" && touch "${fspath}/__init__.py") &>/dev/null
done
}
@davidh-raybeam
davidh-raybeam / gist:5263794
Last active December 15, 2015 12:59
after pasting this into your terminal, you should be able to just "copy_key REMOTE_SERVER"
copy_key () {
local remote_server=$1
[[ -z "$1" ]] && echo "Must provide a server." 2>&1 && return 1
cd "$HOME"
cat .ssh/id_rsa.pub | ssh $remote_server "mkdir -p .ssh && cat - >>.ssh/authorized_keys2"
}
@davidh-raybeam
davidh-raybeam / clip.py
Created March 28, 2013 20:03
These ruby and python scripts provide functions that allow you to copy their arguments to the clipboard.
# Put the following function definition into a file called ~/.pythonrc
# and add the line
# export PYTHONSTARTUP="$HOME/.pythonrc"
# to your .bash{rc,_profile}
import os
def clip(x):
os.popen('pbcopy','w').write(str(x))
@davidh-raybeam
davidh-raybeam / .bashrc
Created April 3, 2013 20:15
make and change to a dir
# ...
mdcd () {
mkdir -p $1 && cd $1
}
# ...