Skip to content

Instantly share code, notes, and snippets.

View psousa's full-sized avatar

Pedro Sousa psousa

View GitHub Profile
snippet:
<%= t('${1:path}')%>
activation:
[tab trigger] trans
scope selector:
text.html.ruby, text.haml
@psousa
psousa / restfull controller textmate snippet
Created June 27, 2009 11:45
snippet for resftull controllers in rails. Scope selector: source.ruby.rails
def index
@${1:things} = ${2:Thing}.find :all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @$1 }
end
end
def show
@psousa
psousa / speed up apache and passenger
Created February 5, 2010 16:47
quick notes on speeding up apache and passenger by caching images and gzipping stuff
#1) install mod deflate and expires on your apache
#Run the following commands: "a2enmod expires" and "a2enmod deflate"
#2) add this inside <VirtualHost> section of your Apache configuration
RewriteEngine On
RewriteCond %{QUERY_STRING} ^[0-9]{10}$
RewriteRule ^(.*)$ /add_expires_header%{REQUEST_URI} [QSA]
<Directory "/home/user/apps/myapp/current/public/add_expires_header">
ExpiresActive On
@psousa
psousa / gist:5110510
Created March 7, 2013 18:33
GoogleAnalitycs sdk Titanium example initializer
var myAPP = {};
Ti.include('windows/gallery.js');
(function() {
myAPP.setupAnalytics=function(){
var GoogleAnalytics = require('com.thinkorange.google.analytics');
GoogleAnalytics.accountID = "UA-xxxxxx-1";
GoogleAnalytics.debug = true;
GoogleAnalytics.trackUncaughtExceptions = true;
@psousa
psousa / .bash_profile
Last active August 29, 2015 14:15
mac bash profile with color and showing git branch
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
#got brew installed on /usr/local
PATH="/usr/local/bin:$PATH"
PS1="\[\033[0;35m\]\u@\h\[\033[0;33m\] \$(parse_git_branch) \w\[\033[00m\]: "
#installed rvm
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
@psousa
psousa / gist:a2cd8c4a646b7598cff5
Created October 2, 2015 15:25
experiment poly
class Locatable < ActiveRecord::Base
belongs_to :locatable, :polymorphic=>true
belongs_to :location
end
class Location < ActiveRecord::Base
has_many :locatables, dependent: :destroy