This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Order | |
attr_accessor :status | |
def initialize(adapter = MyWhateverAdapter.new) | |
@adapter = adapter | |
end | |
def pay! | |
@response = @adapter.pay(self) | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server_name .px2.com.br ~^(<subdomain>)\.px2\.com\.br$ ; | |
location / { | |
rewrite ^(.*)$ http://$subdomain.pixelquadrado.com.br/$1 permanent; | |
break; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 } |