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
html body * span.clear,html body * div.clear,html body * li.clear,html body * dd.clear{background:none;border:0;clear:both;display:block;float:none;font-size:0;list-style:none;margin:0;padding:0;overflow:hidden;visibility:hidden;width:0;height:0}.clearfix:after{clear:both;content:'.';display:block;visibility:hidden;height:0}.clearfix{display:inline-block}* html .clearfix{height:1%}.clearfix{display:block}html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,sub,sup,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outline:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-col |
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
i, @i = 1, 1 | |
def add_one(i) | |
i =+1 | |
end | |
add_one(i) | |
add_one(i) | |
add_one(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
#!/bin/bash | |
VERSION="1.1" | |
REEV="http://rubyforge.org/frs/download.php/48623/ruby-enterprise-1.8.6-20081215.tar.gz" | |
REEF="ruby-enterprise-1.8.6-20081215.tar.gz" | |
REEFF=${REEF%".tar.gz"} | |
PASSENGER="2.0.6" | |
echo "#####################################" | |
echo "Welcome, let's get this party rollin'" | |
echo "#####################################" |
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 fun(cl,name,&body) | |
cl.class_eval { | |
define_method(name,body) | |
} | |
end | |
fun String,:world do | |
"#{self} world" | |
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
def print_ancestor_definitions(cl,method) | |
ancestors = cl.ancestors | |
p ancestors.join(' < ') #Print heirarchy | |
p "Searching..." | |
ancestors.each do |c| | |
if c.instance_methods.include? method | |
p "#{c} defines #{method} as an instance method!" | |
elsif c.singleton_methods.include? method | |
p "#{c} defines #{method} as a singleton method" | |
else |
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 What | |
@foo = 'bar' | |
class Whatever | |
def change_foo | |
What.instance_variable_set(:@foo, "changed") | |
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
#!/usr/local/bin ruby19 | |
#I'll fix this eventually. | |
99.downto(1) do |bottles| | |
f = Fiber.new do |bottles| | |
"#{bottles} bottles of beer on the wall, #{bottles} bottle#{bottles == 1 ? '':'s'} of beer. | |
Take one down and pass it around, #{bottles-1} bottle#{bottles == 1 ? '':'s'} of beer on the wall." | |
end | |
puts f.resume(bottles) |
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 'stringio' | |
old_stdout, new_stdout = $stdout, StringIO.new | |
$stdout = new_stdout | |
puts "Hello, World!" | |
$stdout = old_stdout | |
puts new_stdout.string |
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 f(ra,n) | |
ra.inject(0) { |r,x| r += 1 if x.include? n; r } | |
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
namespace :flickr do | |
desc "Fetches, checks and updates photos" | |
task :default => [:fetch_photos, :check_photos, :update_photos] | |
desc "Fetches photos for tags from flickr" | |
task :fetch_photos => :merb_env do | |
categories = Category.all | |
OlderNewer