Skip to content

Instantly share code, notes, and snippets.


Rafael Souza rafaelss

View GitHub Profile
View gist:aba61e9108faf11b988b
require "benchmark/ips"
email = nil
Benchmark.ips do |x|'com if') { email.downcase.strip if email }'sem if') { email.to_s.downcase.strip }
View gist:f3c8074c8e8b7afb5d3f
require "benchmark/ips"
state1 = :initial
state2 = "initial"
Benchmark.ips do |x|"case to_s.to_sym") do
case state1.to_s.to_sym
when :initial
a = 1
View closure.php
class ActiveRecord {
public static function find($id) {
echo $id, PHP_EOL;
class ActiveRecordCache {
View gist:7610
require 'rubygems'
require 'sinatra'
require 'hpricot'
require 'open-uri'
helpers do
def episodes_form
body = '<form method="post" action="/"><select name="link">'
doc = Hpricot(open(""))
rafaelss / gist:8426
Created Sep 2, 2008
Example of new PHP6 syntax
View gist:8426
function html($closure) {
return tag('html', func_get_args());
function head($closure) {
return tag('head', func_get_args());
function title($closure) {
rafaelss / gist:11035
Created Sep 16, 2008
Strange behavior of PDO::FETCH_CLASS fetch mode
View gist:11035
class Project {
public function __construct() {
echo 'calling constructor', PHP_EOL;
public function __get($name) {
echo 'getting: ', $name, PHP_EOL;
View twibot.rb
sqlite3 twibot.db 'CREATE TABLE statuses (id INTEGER PRIMARY KEY, status_id VARCHAR NOT NULL)'
View gist:66152
# extracted from
class Float
def round_to(x)
(self * 10**x).round.to_f / 10**x
def ceil_to(x)
(self * 10**x).ceil.to_f / 10**x