Skip to content

Instantly share code, notes, and snippets.

View gist:a2cd8c4a646b7598cff5
class Locatable < ActiveRecord::Base
belongs_to :locatable, :polymorphic=>true
belongs_to :location
end
class Location < ActiveRecord::Base
has_many :locatables, dependent: :destroy
@psousa
psousa / .bash_profile
Last active Aug 29, 2015
mac bash profile with color and showing git branch
View .bash_profile
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:5110510
Created Mar 7, 2013
GoogleAnalitycs sdk Titanium example initializer
View gist:5110510
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 / speed up apache and passenger
Created Feb 5, 2010
quick notes on speeding up apache and passenger by caching images and gzipping stuff
View speed up apache and passenger
#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 / restfull controller textmate snippet
Created Jun 27, 2009
snippet for resftull controllers in rails. Scope selector: source.ruby.rails
View restfull controller textmate snippet
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
View I18n.t rails textmate snippet
snippet:
<%= t('${1:path}')%>
activation:
[tab trigger] trans
scope selector:
text.html.ruby, text.haml
You can’t perform that action at this time.