Skip to content

Instantly share code, notes, and snippets.

@esebastian
esebastian / git-dos2unix
Created June 10, 2014 15:37
Convert DOS CRLF newlines to Unix/Linux LF in all text files in a Git repo
git ls-files | xargs perl -le 'for (@ARGV) { print if -f && -T }' | xargs perl -pi -e 's/\r\n/\n/'
@esebastian
esebastian / non_binary_pending_commit
Last active August 29, 2015 13:59
Get the list of not yet committed non binary files in a repo
git status -sb | awk '{ print $2 }' | sed -e '1d' | xargs perl -le 'for (@ARGV) { print if -f && -T }'
@esebastian
esebastian / binary_pending_commit
Created April 14, 2014 07:20
Get the list of not yet committed binary files in a repo
git status -sb | awk '{ print $2 }' | sed -e '1d' | xargs perl -le 'for (@ARGV) { print unless -f && -T }'
@esebastian
esebastian / dos2unix
Last active August 29, 2015 13:59
Convert DOS CRLF newlines to Unix/Linux LF
find . -type f -print0 | xargs -0 perl -pi -e 's/\r\n/\n/'
@esebastian
esebastian / gist:9068949
Created February 18, 2014 11:11
Mount routes from extension in Sinatra
# add requires as needed...
# main app
class App < Sinatra::Base
register Sinatra::Namespace
# mount routes from extension
register Sinatra::Guides
mount_guides
@esebastian
esebastian / dump_obj.py
Last active January 1, 2016 16:09
Dump the state of a Python object
'from http://stackoverflow.com/a/192184/1663589
def dump(obj):
for attr in dir(obj):
print "obj.%s = %s" % (attr, getattr(obj, attr))