Skip to content

Instantly share code, notes, and snippets.

View seki's full-sized avatar

Masatoshi SEKI seki

View GitHub Profile
@seki
seki / gist:118701
Created May 27, 2009 15:45
concept code of NanoTable
require 'rbtree'
class Nano
class Pivot
def initialize(ary)
@ary = ary
end
end
class Prefix < Pivot
@seki
seki / koto.cgi.rb
Created May 27, 2009 15:55
tiny chat for toRubyKaigi
#!/usr/local/bin/ruby
require 'drb/drb'
DRb.start_service
ro = DRbObject.new_with_uri('druby://localhost:54321?cgi')
ro.start(ENV.to_hash, $stdin, $stdout)
class Sbb
Node = Struct.new(:key, :value, :lh, :rh, :left, :right)
class Search
def initialize(key)
@key = key
@found = nil
@created = false
end
attr_accessor :found, :created
require 'rinda/tuplespace'
require 'singleton'
class NotificationCenter
include Singleton
class Handle
def initialize; @removed = false; end
def remove; @removed = true; end
def removed?; @removed; end
require 'drb/drb'
ro = DRbObject.new_with_uri(ARGV.shift)
name = 'your_nick'
url = 'http://your_page'
desc = 'your comment'
p ro.exchange(name, url, desc)
require 'thread'
require 'drb/drb'
require 'rinda/rinda'
class Agent
def initialize(name, url, desc)
@tuple = [name, url, desc]
@inbox = Queue.new
@renewer = Rinda::SimpleRenewer.new(15)
end
#tweet
$ irb
irb(main):001:0> require 'drb/drb'
=> true
irb(main):002:0> DRb.start_service
=> #<DRb::DRbServer:...>
irb(main):003:0> ro = DRbObject.new_with_uri('druby://localhost:54321')
=> #<DRb::DRbObject:0...>
irb(main):004:0> ro.notify('tweet')
require 'drb/drb'
DRb.start_service
ro = DRbObject.new_with_uri('druby://localhost:54000')
ro.hello
#terminal 1
duo:~ mas$ irb
irb(main):001:0> require 'drb/drb'
=> true
irb(main):002:0> DRb.start_service
ro => #<DRb::DRbServer:0...
irb(main):003:0> ro = DRbObject.new_with_uri('druby://localhost:54300')
=> #<DRb::DRbObject...
irb(main):004:0> ro[1] = 'Hello, World.'
@seki
seki / deq.rb
Created November 27, 2009 19:52
require 'drb/drb'
DRb.start_service
queue = DRbObject.new_with_uri('druby://localhost:54320')
while true
p queue.pop
sleep(rand)
end