Skip to content

Instantly share code, notes, and snippets.

@seki
seki / qr.rb
Created December 14, 2009 20:04
<html>
<head>
<title>QR</title>
</head>
<body>
<form action="http://localhost/cgi-bin/qr.rb" method="post">
<textarea name="t" cols="80" rows="15">
</textarea>
<input type="submit" name="QR" value="QR" />
</form>
module Enumerable
class Reverse
def initialize(value)
@value = value
end
attr_reader :value
def <=>(other)
- (@value <=> other.value)
end
# -*- coding: utf-8 -*-
require 'hpricot'
require 'open-uri'
require 'erb'
class PokemonCardCom
def host
'http://www.pokemon-card.com'
end
require 'pp'
class MyPP
def self.pp(obj, size, tail=' ...')
s = self.new(size, tail)
catch(:done) {PP.pp(obj, s)}
s.to_s
end
def initialize(size, tail='')
require 'erb'
class ERB
class ERBString < String
def to_s; self; end
def erb_concat(s)
if self.class === s
concat(s)
else
@seki
seki / otto.rb
Created December 11, 2010 13:01
require 'drb'
require 'pp'
require 'net/https'
require 'oauth'
require 'json'
class JSONStream
def initialize(drop)
@buf = ''
@drop = drop
require 'stringio'
class BPlistParser
def self.parse_file(fname)
File.open(fname) do |fp|
self.new(fp).top_object
end
end
def initialize(io)
require 'simple-oauth'
require 'drb'
require 'pp'
require 'json'
MyDrip = DRbObject.new_with_uri('drbunix:' + File.expand_path('~/.drip/port'))
class JSONStream
def initialize(drip)
@buf = ''
@seki
seki / bag.rb
Created June 27, 2011 17:35
Bag for Markov
class Bag
def initialize
@bag = Hash.new(0)
@size = 0
@cache = nil
end
attr_reader :size
def push(obj)
@cache = nil
require 'thread'
class ActorsOffice
def initialize(actor)
@queue = Queue.new
@thread = Thread.new(actor) do
catch(actor) do
while true
msg, arg, blk = @queue.pop
actor.__send__(msg, *arg, &blk)