Skip to content

Instantly share code, notes, and snippets.

@kdavh
kdavh / extend_module.rb
Created April 13, 2013 21:42
Question about scope when using `exend ModuleName` and `::define_method` in a class
module M
def i_method
define_method(:new_method) do
"I am from i_method, but I should be an instance method"
end
end
end
class C
extend M
@kdavh
kdavh / gist:5332969
Last active December 15, 2015 22:29
problem with hardcoded html form used with rails
##### CODE IN models/users/show.html.erb ######
<%= form_for user do |f| %>
<%= f.label :name %>
<%= f.text_field :name %>
<% Team.all.each do |team|%>
<%= check_box_tag( "user[team_ids][]", team.id,
user.team_ids.include?(team.id),
id: "user_team_ids_#{team.id}"
@kdavh
kdavh / gist:5126962
Created March 10, 2013 03:16
Confusing behavior by Ruby Debugger using 'n' (or next) command.
[5] pry(main)> prime? 5
[2, 11] in /Users/kdavh/Google Drive/cs/2013 App Academy/Coursework/w1d1/primes.rb
2 require 'debugger'
3
4 def prime?(num)
5 debugger
6
=> 7 (2..num/2).each do |i|
8 if (num % i) == 0
@kdavh
kdavh / dabblet.css
Created November 16, 2012 17:43
Ratings Stars
/*
Ratings Stars
(with as little code as possible)
*/
.rating {
unicode-bidi: bidi-override;
direction: rtl;
text-align: center;
}
.rating > span {