Skip to content

Instantly share code, notes, and snippets.

Avatar

Vinicius Baggio Fuentes vinibaggio

View GitHub Profile
View gist:179964
module AllowMacros
def self.included(mod)
mod.extend ClassMethods
end
module ClassMethods
FILTER_METHOD = :check_permission
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")
end
end
end
View failing_macros.rb
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
View gist:195632
# Métodos que me fazem chorar...
def self.recently_accessed
find :all, :conditions => { :id => [186,268,234,107,176] }
end
View gist:195641
# Codigo que me faz chorar
Proc.new { 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 => '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
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"
View .gvimrc
source $HOME/.vimrc
colorscheme vividchalk
set gfn=Menlo\ Regular:h12
set guioptions=egmrt
set showtabline=2
set transparency=5
set lines=50