Skip to content

Instantly share code, notes, and snippets.

View vinibaggio's full-sized avatar

Vinicius Baggio Fuentes vinibaggio

View GitHub Profile
@vinibaggio
vinibaggio / gist:0e8be5f07b81dbdb49d6
Created December 22, 2014 23:01
GC crash in 1.4
$ 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:
runtime.throw(0x151ab9)
/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
module AllowMacros
def self.included(mod)
mod.extend ClassMethods
end
module ClassMethods
FILTER_METHOD = :check_permission
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")
end
end
end
module FailingMacros
def self.included(base)
base.send(:extend, ClassMethods)
end
module ClassMethods
def should_indeed_fail
it "should indeed fail" do
fail "Just fail"
end
# Métodos que me fazem chorar...
def self.recently_accessed
find :all, :conditions => { :id => [186,268,234,107,176] }
end
# Codigo que me faz chorar
Proc.new { eval(my_string) }.call
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 }
module PagseguroHelper
def pagseguro_form(order)
content_tag(:form, :id => "pagseguro", :target => 'pagseguro', :method => 'post', :action => 'https://pagseguro.uol.com.br/security/webpagamentos/webpagto.aspx') do
result = ""
result << hidden_field_tag(:email_cobranca, 'seu@email.com')
result << hidden_field_tag(:tipo, 'CP') # Chumbado
result << hidden_field_tag(:moeda, 'BRL') # Chumbado
result << hidden_field_tag(:ref_transacao, order.id)
result << hidden_field_tag(:encoding, 'utf-8')
result << hidden_field_tag(:tipo_frete, 'SD') # Sedex - pro pagseguro calcular o frete automagicamente
# 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
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"