Skip to content

Instantly share code, notes, and snippets.

View rafaelss's full-sized avatar

Rafael Souza rafaelss

View GitHub Profile
@rafaelss
rafaelss / gist:5224882
Last active December 15, 2015 07:39
SublimeText2 User Preferences
{
"auto_complete": false,
"bold_folder_labels": true,
"color_scheme": "Packages/RailsCasts Colour Scheme/RailsCastsColorScheme.tmTheme",
"detect_indentation": true,
"draw_white_space": "all",
"ensure_newline_at_eof_on_save": true,
"font_face": "Droid Sans Mono",
"font_size": 14,
"highlight_line": true,
PATH="/Users/rafael/rubies/`cat /Users/rafael/rubies/current`/bin:$GOPATH/bin:/usr/local/share/python:$PATH"
@rafaelss
rafaelss / gist:3700977
Created September 11, 2012 19:04
PostgreSQL 9.2 upgrade steps
Steps to install and run PostgreSQL 9.2 using Homebrew (Mac OS X)
(if you aren't using version 9.1.5, change line 6 with the correct version)
1. pg_ctl -D /usr/local/var/postgres stop -s -m fast
2. mv /usr/local/var/postgres /usr/local/var/postgres91
3. curl https://raw.github.com/fragility/homebrew/737af01178590950749cf5e841f2d086c57c5a80/Library/Formula/postgresql.rb > /usr/local/Library/Formula/postgresql.rb
4. brew upgrade postgresql
5. initdb /usr/local/var/postgres -E utf8
6. pg_upgrade -b /usr/local/Cellar/postgresql/9.1.5/bin -B /usr/local/Cellar/postgresql/9.2.0/bin -d /usr/local/var/postgres91 -D /usr/local/var/postgres
7. pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start
class A
def foo
case true
when true
puts defined?(bar)
puts "nil? #{bar}"
when false
bar = "something else"
raise "here? no"
end
class Code
def initialize(code)
@code = code
end
def process
parse(transform(@code))
end
def transform(code)
class MyDecorator
attr_accessor :view_context
def form(&block)
view_context.form_for(TheModel.new, &block)
end
end
server {
listen 8081;
server_name localhost;
location /site {
internal;
postgres_escape $api_key $arg_api_key;
postgres_pass database;
@rafaelss
rafaelss / build.sh
Last active October 2, 2015 20:18
Script to build nginx with some modules configured
#!/usr/bin/env bash
version="1.5.10"
pcre_version="8.34"
set -e
rm -rf nginx-$version*
# download nginx
@rafaelss
rafaelss / gist:2046324
Created March 15, 2012 19:36
XML c14n with Nokogiri
require "nokogiri"
xmldoc = Nokogiri::XML(File.read(ARGV[0]), nil, nil, Nokogiri::XML::ParseOptions::NOBLANKS | Nokogiri::XML::ParseOptions::NOCDATA | Nokogiri::XML::ParseOptions::STRICT)
print xmldoc.at(ARGV[1]).canonicalize
$ ab -n 5 -c 5 http://127.0.0.1:3000/
This is ApacheBench, Version 2.3 <$Revision: 1178079 $>
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/
Benchmarking 127.0.0.1 (be patient).....done
Server Software: thin
Server Hostname: 127.0.0.1