Skip to content

Instantly share code, notes, and snippets.


Vinicius Baggio Fuentes vinibaggio

View GitHub Profile
View gist:0e8be5f07b81dbdb49d6
$ go run bla.go
runtime: garbage collector found invalid heap pointer *(0x2081ce020+0x0)=0x1 s=nil
runtime: found *(0x2081b9ce0+0x28) = 0x2081ce020+0x0
fatal error: bad pointer
runtime stack:
/usr/local/Cellar/go/1.4/libexec/src/runtime/panic.go:491 +0xad fp=0x7fff5fbff1a0 sp=0x7fff5fbff170
scanblock(0x2081b9ce0, 0x240, 0x1065e8)
/usr/local/Cellar/go/1.4/libexec/src/runtime/mgc0.c:412 +0x989 fp=0x7fff5fbff2e0 sp=0x7fff5fbff1a0
View gist:179976
def self.allow(roles, options = {})
class_eval do
def check_permission
# Insert your application logic here
if current_user.nil? or !current_user.roles.exists?(:id => roles)
flash[:notice] = "Go away!"
return check_and_redirect_to("/login")
View gist:179964
module AllowMacros
def self.included(mod)
mod.extend ClassMethods
module ClassMethods
FILTER_METHOD = :check_permission
View failing_macros.rb
module FailingMacros
def self.included(base)
base.send(:extend, ClassMethods)
module ClassMethods
def should_indeed_fail
it "should indeed fail" do
fail "Just fail"
View gist:195632
# Métodos que me fazem chorar...
def self.recently_accessed
find :all, :conditions => { :id => [186,268,234,107,176] }
View gist:195641
# Codigo que me faz chorar { eval(my_string) }.call
View deploy.rb
require 'capistrano/ext/multistage'
set :application, "minha_app"
set :repository, "meu_repositorio"
set :scm, :git
set :use_sudo, false
set :ssh_options, { :forward_agent => true }
View pagseguro_helper.rb
module PagseguroHelper
def pagseguro_form(order)
content_tag(:form, :id => "pagseguro", :target => 'pagseguro', :method => 'post', :action => '') do
result = ""
result << hidden_field_tag(:email_cobranca, '')
result << hidden_field_tag(:tipo, 'CP') # Chumbado
result << hidden_field_tag(:moeda, 'BRL') # Chumbado
result << hidden_field_tag(:ref_transacao,
result << hidden_field_tag(:encoding, 'utf-8')
result << hidden_field_tag(:tipo_frete, 'SD') # Sedex - pro pagseguro calcular o frete automagicamente
View example.rb
# NOTE: Inline templates defined in the source file that requires sinatra are automatically
# loaded.
# Call `enable :inline_templates` explicitly if you have inline templates in other source
# files.
require 'rubygems'
require 'sinatra'
get '/' do
View app.rb
require 'rubygems'
gem "rack", "1.0.1"
gem "sinatra", "1.0"
gem "hpricot", "0.8.2"
gem "amatch", "0.2.5"
gem "sinatra-content-for"
gem "json"