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
VALUE rb_ary_each(ary) | |
VALUE ary; | |
{ | |
long i; | |
for (i=0; ilen; i++) { | |
rb_yield(RARRAY(ary)->ptr[i]); | |
} | |
return ary; | |
} |
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 Base | |
def initialize | |
@@var = 'base' | |
end | |
def base_set_var | |
@@var = 'base' | |
end | |
def base_print_var |
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
def process(values) | |
result = Proc.new { return values.max }.call | |
result * 100 | |
end | |
puts process( [1,2,3] ) |
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
def process(values) | |
result = lambda { return values.max }.call | |
result * 100 | |
end | |
puts process( [1,2,3] ) |
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
y = false | |
z = 1 | |
x = y or z | |
def z arg | |
arg * 10 | |
end | |
puts x |
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/env ruby | |
require 'open-uri' | |
require "rexml/document" | |
require 'rexml/xpath' | |
feed_link = "http://feeds.feedburner.com/37signals/beMH" | |
title, published_date = "", "" | |
TITLE_PATH = "//item//title" | |
DATE_PATH = "//item/pubDate" |
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/env ruby | |
require 'rubygems' | |
require 'open-uri' | |
require 'feed-normalizer' | |
def every seconds, &block | |
while true | |
yield | |
sleep seconds | |
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
require 'rubygems' | |
require 'scrubyt' | |
HASH_TERM = "leadscon" | |
data = Scrubyt::Extractor.define do | |
fetch 'http://www.hashtweeps.com/' | |
fill_textfield "term", HASH_TERM | |
submit |
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
# using properly-named methods indicate the intention | |
# as opposed to having the logic inlined | |
class RemoteCache < Remote | |
def deploy! | |
update_repository_cache | |
copy_repository_cache | |
end | |
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
# using a block ensures the file is closed when done | |
File.open("temp_file") do |file| | |
file.write(data) | |
end |