Skip to content

Instantly share code, notes, and snippets.

View manuelmorales's full-sized avatar

Manuel Morales manuelmorales

View GitHub Profile
@manuelmorales
manuelmorales / custom_gemfiles.sh
Created August 24, 2011 16:00
Custom Gemfiles
# define your BUNDLE_GEMFILE environment variable
# NOTE: Ubuntu users must use .bashrc instead of .bash_profile
echo "export BUNDLE_GEMFILE=Gemfile.dev" >> ~/.bash_profile
# reload your terminal
source ~/.bash_profile
# install the bundler gem
gem install bundler
@manuelmorales
manuelmorales / eps_to_png.sh
Created September 22, 2011 10:10
EPS to PNG with ImageMagick
export BASE_DENSITY=72
export DESIRED_RESOLUTION=1600
export TARGET_DENSITY=$(identify -density $BASE_DENSITY -format "%[fx:min($BASE_DENSITY*$DESIRED_RESOLUTION/w*2,$BASE_DENSITY*$DESIRED_RESOLUTION/h*2)]" IllustratorEPSfile.eps)
convert -density $TARGET_DENSITY -channel rgba -alpha on -colorspace rgb -scale 50% IllustratorEPSfile.eps IllustratorEPSfile.png
@manuelmorales
manuelmorales / github_using_deploy_keys.sh
Created September 26, 2011 14:34
Access GitHub using deploy key
# ~/.ssh/config
Host github-as-deploy
HostName github.com
User git
IdentityFile /home/info/.ssh/dev3dynamic-deploy-key
# test with
ssh -T github-as-deploy
@manuelmorales
manuelmorales / push_branch_and_set_tracking.sh
Created September 28, 2011 09:15
Make git pull and push always do it from the same branch
# From http://mislav.uniqpath.com/2010/07/git-tips/
# git push will by default push all branches that have the same name on the remote.
# To limit this behavior to just the current branch, set this configuration option:
git config --global push.default tracking
git config push.default tracking
# pushes the "master" branch to "origin" remote and sets up tracking
@manuelmorales
manuelmorales / rails_cache_dir.vim
Created December 9, 2011 10:53
How to make Vim to pick up the app/cache directory
" Add this to your ~/.vimrc to allow you do :Rcache activity_json
" to open app/cache/activity_json_cache.rb
autocmd User Rails Rnavcommand cache app/cache -glob=**/* -suffix=_cache.rb
@manuelmorales
manuelmorales / purge_old_sessions.rb
Created January 3, 2012 16:08
Deleting old user sessions from Rails database
# app/modes/session.rb
class Session < ActiveRecord::Base
named_scope :unactive_for, lambda{|period| {:conditions => ['sessions.updated_at <= ?', Time.now - period]}}
def self.purge_older_than period
unactive_for(period).find_in_batches do |sessions|
sessions.each{|s| "#{s.id}: s.destroy"}
end
end
end
@manuelmorales
manuelmorales / enable_apple_uk_keyboard.sh
Created January 12, 2012 09:13
Script to setup English Apple keyboard on Ubuntu Linux
## ~/bin/uk-keyb.sh
#!/bin/bash
setxkbmap -model pc105 -layout gb -variant mac
xmodmap ~/.Xmodmap.mac
## ~/.Xmodmap.mac
! Swap Alt and Cmd keys.
keycode 37 = Control_L
keycode 133 = Alt_L Meta_L
@manuelmorales
manuelmorales / instal_ruby_187.sh
Created January 17, 2012 21:15
Installing ruby 1.8.7 on Ubuntu 11.10 Oneiric with RVM
sudo apt-get install curl git-core ruby zlib1g-dev libxml2-dev mysql-client libsqlite3-dev libmysql-ruby libmysqlclient-dev libssl-dev libxslt-dev libreadline-dev zlib1g-dev
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
source ~/.bashrc
rvm install 1.8.7
# Optionally you can do this instead of installing the Ubuntu package for zlib and readline
# rvm package install readline
# rvm package install zlib
@manuelmorales
manuelmorales / instal_ruby_192.sh
Created January 21, 2012 12:31
Installing ruby 1.9.2 on Ubuntu 11.10 Oneiric with RVM
# This is for installing RVM on your machine with all the needed development libs.
# You can skip this if you have RVM already working.
sudo apt-get install curl git-core ruby zlib1g-dev libxml2-dev mysql-client libsqlite3-dev libmysql-ruby libmysqlclient-dev libssl-dev libxslt-dev libreadline-dev zlib1g-dev
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
source ~/.bashrc
# To install Ruby 1.9.2
rvm install 1.9.2
echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >> ~/.bashrc
echo "\nrvm 1.9.2" >> ~/.bashrc
@manuelmorales
manuelmorales / replace_across_files.vim
Created January 24, 2012 14:30
Replace text across files with vim
" Replace all <% whatever do %> with <%= whatever do %>
:args app/views/*/*
:argdo %s/<% \(.*\) do \(.*\) %>/<%= \1 do \2 %>/ge | update