Skip to content

Instantly share code, notes, and snippets.

View rafaelss's full-sized avatar

Rafael Souza rafaelss

View GitHub Profile
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
@rafaelss
rafaelss / no patch
Created February 14, 2012 00:43
ruby 1.9.3 cumulative path - https://gist.github.com/1688857
$ time ruby script/test_recurrence.rb
bundle exec ruby script/test_recurrence.rb
real 0m9.903s
user 0m7.250s
sys 0m1.205s
real 0m8.395s
user 0m7.157s
sys 0m1.101s
@rafaelss
rafaelss / output.txt
Created February 3, 2012 13:12
should_receive/should_not_receive and respond_to?
require "rspec/mocks"
include RSpec::Mocks::Methods
class MyClass; end
MyClass.should_receive(:my_method).never
puts MyClass.respond_to?(:my_method)
class MyOtherClass; end
@rafaelss
rafaelss / rails_3_0_10
Created September 5, 2011 00:24
where is monday?
ruby-1.9.2-p290 :001 > Date.today
=> Sun, 04 Sep 2011
ruby-1.9.2-p290 :002 > Date.tomorrow
=> Mon, 05 Sep 2011
@rafaelss
rafaelss / README.md
Created September 5, 2011 00:05
Countdown Quiz

Countdown - Numbers Round

To run the code you must follow the commands below:

gem install riot # or sudo gem intall riot
git clone git://gist.github.com/1193748.git
cd 1193748
ruby -I. countdown_test.rb

I choose use riot as test framework. I'm using it in some small projects

function _bundle_exec() {
if [ -e Gemfile ]; then
grep -q "$1" "Gemfile.lock"
if [[ "$1" == "ruby" || $? -eq 0 ]]; then
echo "bundle exec $@"
bundle exec $@
return
fi
fi
require "rubygems"
require "typhoeus"
require "awesome_print"
def run(follow)
request = Typhoeus::Request.new("http://www.google.com", :method => :get)
request.follow_location = follow
hydra = Typhoeus::Hydra.new
hydra.queue(request)