Skip to content

Instantly share code, notes, and snippets.

View caironoleto's full-sized avatar
🎯
Focusing

Cairo Noleto caironoleto

🎯
Focusing
View GitHub Profile
<div id="content-outer">
<!-- start content -->
<div id="content">
<div id="page-heading"><h1>Editando Usuário <%= @user.id %></h1></div>
<table border="0" width="100%" cellpadding="0" cellspacing="0" id="content-table">
<tr>
<th rowspan="3" class="sized"><%= image_tag("/images/shared/side_shadowleft.jpg", :width => '20', :height => '300') %></th>
<th class="topleft"></th>
@caironoleto
caironoleto / order.rb
Created November 9, 2011 22:58 — forked from fellix/order.rb
order
class Order
attr_accessor :status
def initialize(adapter = MyWhateverAdapter.new)
@adapter = adapter
end
def pay!
@response = @adapter.pay(self)
end
@caironoleto
caironoleto / gist:1140306
Created August 11, 2011 18:04 — forked from marcusvmsa/gist:1140301
Tentativa de redirecionamento nginx
server_name .px2.com.br ~^(<subdomain>)\.px2\.com\.br$ ;
location / {
rewrite ^(.*)$ http://$subdomain.pixelquadrado.com.br/$1 permanent;
break;
}
# The basic idea is that we take the existing data via ActiveRecord
# and create new documents in MongoDB using MongoMapper.
# This method is necessary as we want to keep all the associations of existing dataset
# and by the way, clean up empty columns
# We rely on models still being ActiveRecord::Base, I bet you can figure out how the look like.
# And have the newer MongoDB ones here in a module, painful as we have to set the collection_name
# Don't put a +timestamps!+ into your MongoMapper models yet because this would change the updated_at if existing
# As you see in the MongoDB models, a few loose their indepence, e.g. Source as I
# plan to add other sources besides flickr, or Page and Album which only make sense in
# their parent Website
#raffle numbers for the mega sena
@nums = []
def avoid_repeating(current)
if @nums.include?(current) == true or current == 0
avoid_repeating(rand(61))
else
@nums << current
end
module Imoby
class FormBuilder < ActionView::Helpers::FormBuilder
(field_helpers - %w(label check_box radio_button fields_for form_for hidden_field radio_sym select_sym)).each do |selector|
src = <<-end_src
def #{selector}(method, options = {})
make_default_template method,
@template.send(#{selector.inspect}, @object_name, method, objectify_options(options))
end
end_src
class SkatingContest
def o_vencedor; @o_vencedor; end
def o_vencedor=( nome )
unless nome.respond_to? :to_str
raise ArgumentError, "O nome do vencedor deve ser uma String,
não um prooblema matemático ou uma lista de nomes ou qualquer ou
coisa parecida."
end
@o_vencedor = nome
end
# CAPITULO 5 - http://why.nomedojogo.com/chapter-5.html
# 5. O Roubo do Capitão Loteria
# OBS: Alguém poderia me explicar?
##########################################################################################################
elsif numeros_escolhidos.detect { |p| not INTERVALO_NUMERICO === p }
raise ArgumentError, "os três escolhidos devem ser números entre 1 e 25."
end
# Dúvida: o que o .detect faz? e como eu leria esse trecho de código? { |p| not INTERVALO_NUMERICO === p }