Skip to content

Instantly share code, notes, and snippets.

require 'socket'
require 'rubygems'
require 'monitor'
include Socket::Constants
lock = Mutex.new ; buf = []
client = Connection.new( 2201, '10.45.10.219' ).listen
server = Connection.new( 2202, '10.45.10.219' ).connect
stop = false
require 'rubygems'
require 'socket'
include Socket::Constants
lock = Mutex.new ; buf = []
client = TCPServer.new( 2201 )
server = TCPSocket.new( '10.x.x.x', 2202 )
def read
require 'socket'
class Server
def initialize( port )
@server = TCPServer.new( port )
@threads = []
end
def run( &block )
require 'socket'
class Server
def initialize( port )
@server = TCPServer.new( port )
@threads = []
end
def run( &block )
$:.unshift( "waves/lib" )
require 'rubygems'
require 'waves'
module BoogieBoard
include Waves::Foundations::Simple
module Configurations
module Cassandra
module CSS
# stuff that is pure CSS generation goes here
end
module Hacks
def self.dependencies( *args )
self['dependencies'] ||= Set.new
args.length == 0 ? self['dependencies'] :
self['dependencies'] += ( args - gems.dependencies )
end
@dyoder
dyoder / path.rb
Created September 14, 2008 07:07
def call( request )
capture = {}
path = extract_path( request )
capture if @pattern.all? do | want |
case want
when true then path = []
when String then want == path.pop
when Symbol then capture[ want ] = path.pop
when Regexp then want === path.pop
when Hash
# 'html' is the default when there is no extension or Accept header
# we will actually default to json, though ...
Formats = [ :json, :html ]
on( :get, [ :resource ] ) do
# ... do something to get results
format = File.extname( path ); format = 'json' if format.empty?
results.send( "to_#{ format }" )
end
ypcmc02106:pages dyoder$ irb
irb(main):001:0> class A ; attr_accessor :foo ; def initialize; foo = String.new ; end ; end
=> nil
irb(main):002:0> a1 = A.new
=> #<A:0x86970>
irb(main):003:0> a2 = a1.dup
=> #<A:0x82a64>
irb(main):004:0> a1.foo = 'hello'
=> "hello"
irb(main):005:0> a2.foo