Skip to content

Instantly share code, notes, and snippets.

View rodrigoflores's full-sized avatar

Rodrigo Flores rodrigoflores

View GitHub Profile
#outer {
width: 500px;
}
#outer:hover #text {
-webkit-transition: left linear .5s;
position: absolute;
left: 100px;
}
p {
background-color: red;
}
# do .. end when we're only interested on the side effect
array.each do |item|
puts item
end
# { } when we want the result of the evaluation
array.map { |item|
item + 1

Integers

1 + 1
2 * 2
5 / 3
5 % 3
5 ** 2
@rodrigoflores
rodrigoflores / gist:2372462
Created April 13, 2012 00:57
Has many association
irb(main):013:0> blog = Blog.new
=> #<Blog id: nil, title: nil, created_at: nil, updated_at: nil>
irb(main):014:0> blog.save
(0.2ms) BEGIN
SQL (0.4ms) INSERT INTO `blogs` (`created_at`, `title`, `updated_at`) VALUES ('2012-04-13 00:56:01', NULL, '2012-04-13 00:56:01')
(19.5ms) COMMIT
=> true
irb(main):015:0> post = blog.posts.new
=> #<Post id: nil, blog_id: 2, created_at: nil, updated_at: nil>
irb(main):016:0> post.save
class Password < ActiveRecord::Base
belongs_to :user
scope :current, where(:changed_at => nil)
end
class Password < ActiveRecord::Base
belongs_to :user
scope :current, where(:changed_at => nil)
end
flores in /Users/flores/Code/sum/sum/mdown-erlang with 1.9.3-p125 on (master *)
% erl
Erlang R15B (erts-5.9) [source] [64-bit] [smp:2:2] [async-threads:0] [hipe] [kernel-poll:false]
Eshell V5.9 (abort with ^G)
1> c(markdown).
{ok,markdown}
2> markdown:to_html(<<"# OK #">>).
"<h1>OK</h1>\n"
3> markdown:to_html(<<"# OK #\n * OK">>).
@rodrigoflores
rodrigoflores / simple-form.pt-BR.yml
Created August 31, 2011 14:35
pt-BR Simple Form
pt-BR:
simple_form:
"yes": 'Sim'
"no": 'Não'
required:
text: 'obrigatório'
mark: '*'
# You can uncomment the line below if you need to overwrite the whole required html.
# When using html, text and mark won't be used.
# html: '<abbr title="required">*</abbr>'
@rodrigoflores
rodrigoflores / casa.rb
Created August 25, 2011 12:59
Case where with classes
case my_var
when String then puts "It is a string"
when Integer then puts "It is an integer"
else puts "It is another thing"
end
#instead of
case my_var.class
when String then puts "It is a string"
when Integer then puts "It is an integer"