Skip to content

Instantly share code, notes, and snippets.

View davidbalbert's full-sized avatar

David Albert davidbalbert

View GitHub Profile
ace:scripts david$ type rvm | head -n1
rvm is a function
ace:scripts david$ rvm debug
ruby-1.9.2-p0:
rvm 1.0.9 by Wayne E. Seguin (wayneeseguin@gmail.com) [http://rvm.beginrescueend.com/]
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
# path prompt
export PS1="\h:\w\$(parse_git_branch)\$ "
@davidbalbert
davidbalbert / .vimrc
Created February 25, 2011 07:38
Show trailing spaces with middots in vim
set list listchars=tab:\ \ ,trail:·
@davidbalbert
davidbalbert / .bashrc
Created February 25, 2011 07:57
show branch name in your prompt
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/\ \[\1\]/'
}
# path prompt
export PS1="\h:\w\$(parse_git_branch)\$ "
# make bash use vi mode. You are by default in "insert" mode, so you have to hit escape to get to the commands
set -o vi
import gevent
from gevent.event import Event
e = Event()
g = gevent.spawn(e.wait)
g.join()
@davidbalbert
davidbalbert / gist:1368802
Created November 15, 2011 23:54
wrap_and_run
def wrap_and_run(message, *args)
EM.run_bock do
@one_api.send(message, *args) do |response|
return response
end
end
end
wrap_and_run(:send_sms, the_hash)
#!/bin/sh
if [ ! -t 0 ]; then
file=/dev/stdin
elif [ -f $1 ]; then
file=$1
else
echo "Usage: $0 code.c"
exit 1
fi
require 'socket'
require 'thread'
s = Socket.new :INET, :STREAM
addr = Socket.pack_sockaddr_in(12345, '127.0.0.1')
s.bind(addr)
s.listen(10)
#include <stdio.h>
int main(int argc, const char *argv[])
{
printf("sizeof(char) = %lu\n", sizeof(char));
printf("sizeof(short) = %lu\n", sizeof(short));
printf("sizeof(int) = %lu\n", sizeof(int));
printf("sizeof(long) = %lu\n", sizeof(long));
printf("sizeof(long long) = %lu\n", sizeof(long long));
printf("sizeof(float) = %lu\n", sizeof(float));
@davidbalbert
davidbalbert / env.diff
Created March 31, 2012 19:17
Homebrew env
--- normal.env 2012-03-31 15:13:44.000000000 -0400
+++ brew.env 2012-03-31 15:14:23.000000000 -0400
@@ -1,21 +1,35 @@
Apple_PubSub_Socket_Render=/tmp/launch-0TPw0t/Render
Apple_Ubiquity_Message=/tmp/launch-beOjEY/Apple_Ubiquity_Message
+CC=/usr/bin/clang
+CFLAGS=-Os -w -pipe -march=native -Qunused-arguments
COMMAND_MODE=unix2003
+CPPFLAGS=-I/usr/local/Cellar/readline/6.2.2/include
+CXX=/usr/bin/clang++