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
#!/opt/local/bin/ruby | |
require "rubygems" | |
require "exifr" | |
require "flickr" | |
require "pit" | |
class FlickrPhoto | |
def self.set_token(*args) | |
@@flickr = Flickr.new(*args) | |
if @@flickr.auth.token |
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 -wKU | |
# -*- encoding:utf-8 -*- | |
class Node | |
attr_accessor :id, :edges, :cost, :done, :from | |
def initialize(id, edges=[], cost=nil, done=false) | |
@id, @edges, @cost, @done = id, edges, cost, done | |
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
require "graphviz" | |
require "RMagick" | |
class GraphAz | |
attr_accessor :graph, :nodes, :edges, :gnode, :gedge | |
def initialize(name= :G, *opt, &blk) | |
@graph = GraphViz.new(name, *opt, &blk) | |
@gnode, @gedge = @graph.node, @graph.edge | |
@nodes, @edges = [], {} | |
@@lap, @laps = 0, [] |
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
# -*- encoding:utf-8 -*- | |
require "graphaz" | |
class Sampler | |
@@q = Hash.new{[]} | |
def self.initialize | |
flag, color = nil, nil | |
data = DATA.readlines.map { |line| line.chomp } | |
data.each do |item| | |
next if item.empty? |
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
# -*- encoding:utf-8 -*- | |
require "graphaz" | |
COLORS = DATA.readlines.map { |line| line.sub(/\[.*$/, '').chomp } | |
DARKS = %w(black urlywood navyblue navy indigo darkslateblue mediumblue midnightblue blue darkslategray) | |
def init(ga, num) | |
1.upto(num) { |n| ga.add(n.to_s) } | |
1.upto(num) { |n| ga.add("#{rand(num)+1} => #{n}") } | |
ga |
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 Termtter::Client | |
# search replacement: | |
# ADD: #[page] arg for list next pages | |
register_command( | |
:name => :search, :aliases => [:s], | |
:exec_proc => lambda {|arg| | |
search_option = config.search.option.empty? ? {} : config.search.option | |
arg.gsub!(/\s*#(\d+)$/) { search_option[:page] = $1 ; ''} | |
if arg.empty? && tags = public_storage[:hashtags] | |
arg = tags.to_a.join(" ") |
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 "bloops" | |
class BloopSong | |
def self.init(tempo) | |
@bloops = Bloops.new | |
@bloops.tempo = tempo | |
yield self | |
self | |
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/bin/env ruby -wKU | |
def class_tree(klass, mod=false) | |
klass = klass.class unless klass.is_a?(Class) | |
supers = klass.ancestors.reject { |anc| anc.class == Module unless mod } | |
method_list = supers.inject({}) do |h, _class| | |
h[_class] = _class.public_instance_methods(false). | |
sort.partition { |m| m !~ /^\w/ }.flatten | |
h | |
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
#!/opt/local/bin/ruby1.9 | |
#-*-encoding: utf-8-*- | |
require "test/unit" | |
class Array | |
def insert_sort | |
inject([]) { |mem, var| mem.insert_with_order(var) } | |
end | |
def insert_with_order(item) |
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
#!/opt/local/bin/ruby1.9 | |
#-*-encoding: utf-8-*- | |
require "test/unit" | |
require "strscan" | |
class String | |
def self.method_added(name) | |
class_variable_set("@@#{$`}", 0) if name =~ /_compare$/ | |
end |