Skip to content

Instantly share code, notes, and snippets.

View workmad3's full-sized avatar

David Workman workmad3

View GitHub Profile
class Fixnum
def amicable?
b = self.divisors.sum
return b != self && b.divisors.sum == self
end
def divisors
(1..self/2).select{|x| self % x == 0}
end
end
def add_n(n)
Proc.new {|x| x + n }
end
add_5 = add_n(5)
add_5.call(1)
add_5.call(7)
add_10 = add_n(10)
add_10.call(add_5.call(4))
class Sudoku
def initialize
@puzzle = Array.new(9) {Array.new(9, 0)}
end
end
class Date
def wday_name
self.strftime("A")
end
end
Date.yesterday.wday_name #=> "Tuesday"
class MyProxy < BasicObject
def initialize(target)
@target = target
end
def method_missing(name, *args, &block)
@target.send(name, *args, &block)
end
end
1) Delicious::BookmarkList should find the bookmark title, address and description of the bookmark list provided
Failure/Error: bookmark_list.bookmarks.should == [{:title => "Access to MySQL", :link => "http://www.bullzip.com/products/a2m/info.php", :description => "Bullzip Utility Source - Free software for printing PDF documents and converting Microsoft Access databases to MySQL."}]
expected: [{:title=>"Access to MySQL", :link=>"http://www.bullzip.com/products/a2m/info.php", :description=>"Bullzip Utility Source - Free software for printing PDF documents and converting Microsoft Access databases to MySQL."}],
got: [{:title=>"Access To MySQL", :link=>"http://www.bullzip.com/products/a2m/info.php", :description=>"Bullzip Utility Source - Free software for printing PDF documents and converting Microsoft Access databases to MySQL."}] (using ==)
# ./spec/models/delicious/bookmark_list_spec.rb:7:in `block (2 levels) in <top (required)>'
class Foobar
@city = "London"
def city
self.class.instance_variable_get(:@city)
end
end
class Barfoo < Foobar
@city = "New York"
class Foobar
attr_accessor :locale
def initialize(locale = 'sv')
@locale = locale
end
end
<?php
include_once MODEL_PATH.'forums/Forum.php';
include_once MODEL_PATH.'forums/Topic.php';
require_once MODEL_PATH.'socialNetwork/group/XACLGroup.php';
/**
* InitTopic
*
* This controller
*
<% if local_assigns.include?(:phone) && local_assigns.include?(:location) %>
<ul class="profile_info_triple">
<li><%= link_to(fb_name(owner, :use_you => false, :linked => false), owner) %></li>
<li><%= location %></li>
<li class="phone"><%= phone %></li>
</ul>
<% elsif local_assigns.include?(:phone) || local_assigns.include?(:location) %>
<ul class="profile_info_dual">
<li><%= link_to(fb_name(owner, :use_you => false, :linked => false), owner) %></li>
<li class="phone"><%= phone %></li>