Skip to content

Instantly share code, notes, and snippets.

View manuelmorales's full-sized avatar

Manuel Morales manuelmorales

View GitHub Profile
Dir["*.avi"].sort.map{|s| [Dir["*#{s.scan(/\dx\d\d/)}*srt"].first, s.gsub(/avi$/,"srt")]}.each{|a| FileUtils.mv a.first, a.last}
mysql> show indexes in activities;
mysql> EXPLAIN SELECT * FROM 'users';
@manuelmorales
manuelmorales / gist:954214
Created May 3, 2011 20:55
Enable bluetooth receiving in Ubuntu 10.10
sudo apt-get install apache2.2-bin libapache2-mod-dnssd gnome-user-share
bluetooth-applet
Left Click => "Preferences" => "Receive Files"
@manuelmorales
manuelmorales / activerecord_parse_boolean.rb
Created May 4, 2011 11:34
How to parse true/false parameters to boolean attributes with ActiveRecord
ActiveRecord::ConnectionAdapters::Column.value_to_boolean(parameter)
" search across files in vim
:lgrep -r pattern dir_1 dir_2
:lopen
" go to next file
:lnf
" go to next or previous match
:lnext
:lprev
@manuelmorales
manuelmorales / gist:1055086
Created June 29, 2011 21:48
Root Android Gingerbread 2.3.4
# http://forum.xda-developers.com/showthread.php?t=788108
unzip CF-Root-XX_OXA_JVP-v3.7-CWM3RFS.zip
tar xvf CF-Root-XX_OXA_JVP-v3.7-CWM3RFS.tar
# Put phone in download mode
heimdall flash --kernel zImage
cp CF-Root-ext4-v1.3-Addon.apk /media/phone/
@manuelmorales
manuelmorales / lib_reload.rb
Created July 25, 2011 11:01
How to force lib reload in Rails
load "#{Rails.root}/lib/yourfile.rb"
@manuelmorales
manuelmorales / xdelta3_patching.sh
Created July 27, 2011 11:19
Command line Patching with Xdelta3
cp 1 my_file.pptx
for N in {2..15}; do xdelta3 -f -d -s my_file.pptx $N my_file.pptx; done
@manuelmorales
manuelmorales / rvm-rails-snow-leopard.sh
Created August 17, 2011 15:01
RVM in Snow Leopard
bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function' >> ~/.bash_profile
source ~/.bash_profile
# You might not need this
curl -O ftp://ftp.gnu.org/gnu/readline/readline-6.1.tar.gz
tar xzvf readline-6.1.tar.gz
cd readline-6.1
./configure --prefix=$HOME/readline
make
@manuelmorales
manuelmorales / call_url_for.rb
Created August 22, 2011 11:31
How to call url_for from a model or somewhere else
# Let's break MVC!
include ActionController::UrlWriter
self.class.default_url_options = {:host => "localhost"}
home_url