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 | |
require 'camping' | |
Camping.goes :Mini | |
class Mini::Game | |
attr_reader :score | |
def initialize(*p) |
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 | |
require 'rubygems' | |
# require 'minitest/autorun' | |
require 'logger' | |
require 'minitest/unit' | |
Log = Logger.new(STDOUT) | |
Log.level = Logger::DEBUG |
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 | |
require 'test/unit' | |
def read_triangle_input(ary) | |
ary.map {|i| i.split.map(&:to_i) } | |
end | |
def triangle_sum(tri) | |
tri.shift # remove length |
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
require 'rbosa' | |
itunes = OSA.app('iTunes') | |
music = itunes.current_playlist | |
music.name #=> "Music" | |
tracks = music.tracks | |
sum = tracks.inject(0) {|n,i| n + i.played_count } #=> 3871 | |
average = sum / tracks.size.to_f #=> 3.61100746268657 |
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
if $cygwin; then | |
alias pbpaste=/home/alphach/bin/pbpaste.cmd | |
alias pbcopy=/home/alphach/bin/pbcopy.cmd | |
fi |
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
IRB.conf[:PROMPT][ IRB.conf[:PROMPT_MODE] ][:RETURN]='' |
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 | |
require 'fastercsv' | |
require 'tweet' | |
base_path = File.dirname(__FILE__) | |
csv_files = Dir["#{base_path}/*.csv"].sort_by do |filename| | |
DateTime.parse(File.basename(filename, '.csv')) | |
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
#!/usr/bin/env ruby | |
require 'twitter' | |
last_tweet = Tweet.find(:first, :order => 'time DESC') | |
tweets = Twitter.new(ARGV[0]) | |
if last_tweet.nil? or tweets.current_tweet[:time] > last_tweet.time | |
while tweet = tweets.succ |
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
server.modules = ( | |
... | |
"mod_webdav", | |
... | |
) | |
$HTTP["host"] =~ "weave.foo.com" { | |
server.document-root = "/foo/weave" | |
accesslog.filename = "/var/log/lighttpd/weave/access.log" | |
webdav.activate = "enable" |
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
/etc/fstab: | |
//foo/bar /mnt/foo cifs rw,uid=1000,gid=1000,auto,file_mode=0644,dir_mode=0755,credentials=/root/.smb_credentials 0 0 | |
/root/.smb_credentials: | |
username=foo | |
password=bar |