Skip to content

Instantly share code, notes, and snippets.

@dira
dira / gist:3385655
Created August 18, 2012 09:37
Command line ruby - eurucamp 2012
Write
http://trollop.rubyforge.org/
helps provide - short options, long options, switches with on and off
$PROGRAM_NAME = '..'
exit <code>
Man
http://rubygems.org/gems/gem-man
@dira
dira / largest.sh
Created June 11, 2012 18:53
Find largest sub-folders
sudo du ./* | sort -n -r | head -n 10
@dira
dira / cleanup_rails3_log.vim
Created April 25, 2012 13:37
Cleanup the development log in vim
%s/Started GET "\/assets.*$/
%s/Served asset.*$/
%s/MONGODB.*$/
%s/\n\n\+/\r
" also as a vim function: https://github.com/dira/vimfiles/commit/8fe83043e73cff19a52ed6b43a6261019f32cf19
@dira
dira / rename_mongoid_collection.rb
Created March 28, 2012 10:14
Rename a Mongoid collection
# want to nest `Video` under `Media`; had a `videos` collection
# rename the collection:
Mongoid.database.drop_collection('videos')
Mongoid.database.rename_collection('videos', 'media')
# or
Mongoid.database.collection('videos').rename('media')
# change the type of all the existing records
@dira
dira / convert-bw.sh
Created March 8, 2012 20:25
Convert black and white, aliased image to color-and-white, not aliased
# convert black & white image with aliasing such as all black & black-ish pixels have another color
# which means: change all pixels that are not-white
convert -fill "#2CD152" +opaque white black-grey-and-white.png green-and-white.png
@dira
dira / install script.sh
Created October 8, 2011 12:25
Notes for installing stuff on a new computer (not automatized for now)
# install http://mxcl.github.com/homebrew/
# install iterm2
# install macvim
# install zsh
# make zsh default
chsh -s $(which zsh)
@dira
dira / captioner.sh
Created September 8, 2011 21:46
Add a caption (for Picasa) to many images
# install http://www.sno.phy.queensu.ca/~phil/exiftool
exiftool -xmp:description='the caption' -E source/*.JPG
@dira
dira / application.rb
Created February 10, 2011 02:28
A Rake middleware to specify to OmniAuth where to redirect after successful authentication
# config/application.rb
config.middleware.use 'StoreRedirectTo'
# and make sure you autoload the contents of /lib
@dira
dira / ProxyForCharles.rb
Created January 26, 2011 23:08
How to set the proxy for testing HTTParty requests with Charles
http_proxy '10.2.2.1', 8888
# the ones inspired by the documentation do not work
# http_proxy 'http://10.2.2.1', 8888
# http_proxy 'http://localhost', 8888
# http_proxy 'http://127.0.0.1', 8888
@dira
dira / railroady.bash
Created December 22, 2010 22:10
Generate diagrams for models and controllers in Rails, with railroady
railroady -M -i -t -o models.dot; dot -Tpng models.dot > models.png; open models.png
railroady -C --hide-private --hide-protected -o controllers.dot