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 problem is that the Person object currently has two sub-objects: | |
# PersonFirstname and PersonLastname, and both have a @value attribute, which | |
# is suboptimal. | |
# Is there a way to end up with a Person object that has both @firstname and | |
# @lastname, without extraneous child objects? | |
class PersonFirstname | |
include HappyMapper | |
tag "firstname" | |
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 HappyMapper | |
class Item | |
private | |
def value_from_xml_node(node, namespace=nil) | |
node.register_default_namespace(namespace.chop) if namespace | |
if element? | |
depth = options[:deep] ? './/' : '' | |
result = node.find_first("#{depth}#{namespace}#{tag}") | |
if tag.match(/\/@[a-z\d]+$/i) |
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
describe "Kernel#retryable" do | |
it "should not affect the return value of the block given" do | |
retryable { 'foo' }.should == 'foo' | |
end | |
it "should not affect the return value of the block given when there is a retry" do | |
num_calls = 0 | |
ret_val = retryable_deluxe do | |
num_calls += 1 |
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 MyClass | |
attr_reader :myvar | |
def initialize | |
@myvar = "omg" | |
do_stuff | |
end | |
def do_stuff |
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
#!/usr/bin/python | |
# Found @ http://darkreverser.wordpress.com/2008/02/13/new-blog | |
# Changelog | |
# 0.01 - Initial version | |
# 0.02 - Huffdic compressed books were not properly decrypted | |
import sys,struct,binascii | |
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
(.)(.) |
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 User < ActiveRecord::Base | |
validates_uniqueness_of :email, :case_sensitive => false | |
validate :valid_email? | |
private | |
def valid_email? | |
address = EmailVeracity::Address.new(email) |
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
config.gem "heycarsten-email-veracity", :lib => "email_veracity" |
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
begin | |
retryable( :tries => 2 ) do | |
Timeout::timeout(5) do |t| | |
xml_string = open( my_url, "User-Agent" => "Firefox/2.0" ).read | |
end | |
end | |
rescue Timeout::Error | |
LOG.error("Timeout error: #{$!} (#{my_url})") | |
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
God.watch do |w| | |
# ... | |
# Setting ENV variables for your script. | |
w.env = { "WORKER_ID" => "12" } | |
# Allow STDOUT and capture it to a log file. | |
w.log = "path/to/stdout/log/file.log" | |
# ... |
OlderNewer