Skip to content

Instantly share code, notes, and snippets.

@erubboli
erubboli / in_bash_profile.sh
Created December 4, 2011 11:27
add branch to PS1
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return;
echo "["${ref#refs/heads/}"]"
}
PS1='\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
@erubboli
erubboli / image_to_array.rb
Created September 22, 2011 23:18
convert an image to c array
//Convert the 128x128 image with:
// convert image.jpg image.rgb
res=128
img_file = File.open(ARGV[0],'r')
puts "static char image[#{res*res}] = { "
img_file.bytes.each_slice(res) do |l|
puts " #{l.join(',')}"
end