This file contains hidden or 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 | |
# -*- ruby -*- | |
# twitter command line client | |
# That's What I Call Lame | |
# 09nov2008 +chris+ | |
require 'json' | |
require 'open-uri' |
This file contains hidden or 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 hidden or 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 by_loop | |
loop do | |
break if yield | |
end | |
end | |
def by_while | |
while true | |
break if yield | |
end |
This file contains hidden or 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
With this code, CPU usage shoots to 100% when serving the index page. | |
% gem19 list -l | |
*** LOCAL GEMS *** | |
daemons (1.0.10) | |
diakonos (0.8.7) |
This file contains hidden or 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
layout do |path, wish| | |
if path !~ /feed|show/ | |
mobile_rendering? ? :mobile : :main | |
end | |
end | |
def self.mobile_rendering? | |
(request.host =~ /m\.learnivore/) ? true : false | |
end |
This file contains hidden or 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
iota % rvm ruby sc.rb | |
info: jruby-1.5.1: jruby 1.5.1 (ruby 1.9.2dev trunk 24787) (2010-06-06 f3a3480) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_20) [amd64-java] | |
Rehearsal ---------------------------------------------- | |
scan 5.973000 0.000000 5.973000 ( 5.928000) | |
scan ++ 10.103000 0.000000 10.103000 ( 10.104000) | |
scan re 5.443000 0.000000 5.443000 ( 5.443000) | |
scan re ++ 10.329000 0.000000 10.329000 ( 10.329000) | |
while 8.482000 0.000000 8.482000 ( 8.482000) |
This file contains hidden or 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
LotteryTicket = | |
get_picks: -> @picks | |
set_picks: (@picks) -> | |
get_purchased: -> @purchase | |
set_purchased: (@purchased) -> |
This file contains hidden or 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 higher_order | |
lambda{|arg| arg + yield(5) } | |
end | |
foo = lambda{|arg| arg + 1 } | |
higher_order(&foo).(3) # => 9 |
This file contains hidden or 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
test = Hash.new | |
test.class == Hash #=> true | |
case test.class.to_s | |
when "Hash" | |
true | |
else | |
false | |
end | |
end #=> true |
This file contains hidden or 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 ProjectReader | |
module_function | |
# finds keys in .erb files from a given directory | |
def find_keys(path) | |
keys = Dir[File.join(path, '**/*.erb')].map{|path| | |
extract_keys(path) | |
}.flatten | |
unless keys.empty? |
OlderNewer