Skip to content

Instantly share code, notes, and snippets.

View marcusvmsa's full-sized avatar
🎯
Focusing

Marcus Sá marcusvmsa

🎯
Focusing
  • Vakinha
  • Porto Alegre - Brazil
View GitHub Profile
gem list | cut -d" " -f1 | xargs gem uninstall -aIx
@marcusvmsa
marcusvmsa / reset.css
Created December 7, 2010 17:31
Minimal CSS Reset
body{padding:0;margin:0;font:13px Arial,Helvetica,Garuda,sans-serif;*font-size:small;*font:x-small;}
h1,h2,h3,h4,h5,h6,ul,li,em,strong,pre,code{padding:0;margin:0;line-height:1em;font-size:100%;font-weight:normal;font-style: normal;}
table{font-size:inherit;font:100%;}
ul{list-style:none;}
img{border:0;}
p{margin:1em 0;}
@marcusvmsa
marcusvmsa / gist:837043
Created February 21, 2011 13:19
Get local IP with Ruby
require "socket"
local_ip = UDPSocket.open {|s| s.connect("64.233.187.99", 1); s.addr.last}
@marcusvmsa
marcusvmsa / .bashrc
Created April 4, 2011 11:29 — forked from dermidgen/.bashrc
.bashrg example
# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
[ -z "$PS1" ] && return
# don't put duplicate lines in the history. See bash(1) for more options
export HISTCONTROL=ignoredups
# ... and ignore same sucessive entries.
vacuumdb --full --analyze --username postgres --dbname [DBNAME] --host [HOSTNAME]
pg_dump [DBNAME] -Ft -v -U postgres -f tmp/[DBNAME].tar --host [HOSTNAME]
dropdb [DBNAME] --username postgres --host [HOSTNAME]
createdb --encoding UTF8 [DBNAME] --username postgres --host [HOSTNAME] --template template0
pg_restore tmp/[DBNAME].tar | psql --dbname [DBNAME] --username postgres --host [HOSTNAME]
vacuumdb --full --analyze --username postgres --dbname [DBNAME] --host [HOSTNAME]
@marcusvmsa
marcusvmsa / estados_brasileiros.erb
Created April 12, 2011 13:10
Lista de estados brasileiros para ActioView
<%= f.select :state, [ ["Acre", "AC"],
["Alagoas", "AL"],
["Amapá", "AP"],
["Amazonas", "AM"],
["Bahia", "BA"],
["Ceará", "CE"],
["Distrito Federal", "DF"],
["Espírito Santo", "ES"],
["Goiás", "GO"],
["Maranhão", "MA"],
@marcusvmsa
marcusvmsa / gist:942865
Created April 26, 2011 19:02
Exceptions available in your Ruby on Rails project
all_exceptions = []
ObjectSpace.each_object(Class) do |k|
all_exceptions << k if k.ancestors.include?(Exception)
end
@marcusvmsa
marcusvmsa / gist:1140301
Created August 11, 2011 18:00
Tentativa de redirecionamento nginx
server_name .px2.com.br ;
#rewrite ^(.*)\.px2\.com\.br$ http://www.$1.com.br/ permanent;
if ($host ~* "^(.*)\.px2\.com\.br$"){
set $subd $1;
rewrite ^(.*)$ http://$subd.pixelquadrado.com.br$1 permanent;
break;
}
if ($host = 'px2.com.br' ) {
rewrite ^/(.*)$ http://www.pixelquadrado.com.br/$1 permanent;
}
@marcusvmsa
marcusvmsa / spawn-fcgi.sh
Created September 12, 2011 18:10
spawn-fcgi
spawn-fcgi -a 127.0.0.1 -p 53217 -P /var/run/fastcgi-php.pid -- /usr/bin/php-cgi
@marcusvmsa
marcusvmsa / attr_acessible_security.rb
Created March 6, 2012 01:09 — forked from rafaelp/attr_acessible_security.rb
How to protect against mass assignment attack
# Put this file on config/initializer
# This will create an empty whitelist of attributes available for mass assignment for
# all models in your app. As such, your models will need to explicitly whitelist
# accessible parameters by using an attr_accessible declaration. This technique is best
# applied at the start of a new project. However, for an existing project with a thorough
# set of functional tests, it should be straightforward and relatively quick to insert this
# initializer, run your tests, and expose each attribute (via attr_accessible) as dictated
# by your failing tests.