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 'av_capture' | |
require 'drb' | |
class PhotoServer | |
attr_reader :worker | |
def initialize | |
@worker = Queue.new | |
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
class ChannelSpace | |
class ChannelHandle | |
def initialize(ts, size) | |
@ts = ts | |
@size = size | |
@name = Object.new | |
@ts.write([@name, 0, []]) | |
end | |
def write(value) |
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
# -*- coding: utf-8 -*- | |
require 'rinda/tuplespace' | |
module Channel | |
class ChannelSpace | |
class Any | |
def initialize(ary) | |
@ary = ary | |
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 'rinda/tuplespace' | |
class ChannelSpace | |
include DRbUndumped | |
class ChannelError < RuntimeError | |
def initialize(str, handle) | |
@channel = handle | |
super(str) | |
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
rate = 210 | |
while line = gets | |
line.chomp! | |
puts | |
if line.empty? | |
sleep(0.7) | |
next | |
end | |
puts(line) | |
IO.popen("say -r #{rate}", "w") do |say| |
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 GPIO | |
module_function | |
def export(n, dir) | |
File.open("/sys/class/gpio/export", "w") do |fp| | |
fp.write(n.to_s) | |
end | |
sleep 0.1 | |
File.open("/sys/class/gpio/gpio#{n}/direction", "w") do |fp| | |
fp.write(dir) |
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/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) |
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 'rbtree' | |
class Nano | |
class Pivot | |
def initialize(ary) | |
@ary = ary | |
end | |
end | |
class Prefix < Pivot |
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
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 |
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 'rinda/tuplespace' | |
require 'singleton' | |
class NotificationCenter | |
include Singleton | |
class Handle | |
def initialize; @removed = false; end | |
def remove; @removed = true; end | |
def removed?; @removed; end |
OlderNewer