This file contains hidden or 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
hello_world = lambda do |env| | |
[200, {"Content-Type" => "text/html"}, [ "<h1>Hello World!</h1>"]] | |
end | |
run hello_world |
This file contains hidden or 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
∴ rake test | |
(in /usr/local/lib/ruby/gems/1.9.1/gems/local_eval-0.2.6) | |
bacon -k /usr/local/lib/ruby/gems/1.9.1/gems/local_eval-0.2.6/test/test.rb | |
Testing LocalEval version 0.2.6... | |
With Remix version 0.4.9 and Object2module version 0.5.0 | |
Ruby version 1.9.2 | |
dyld: lazy symbol binding failed: Symbol not found: _rb_is_meta_singleton_of | |
Referenced from: /usr/local/lib/ruby/gems/1.9.1/gems/object2module-0.5.0/lib/object2module.bundle | |
Expected in: flat namespace |
This file contains hidden or 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
VALUE convert_embedded_to_iv_table( VALUE object ) { | |
len = ROBJECT_NUMIV( object ); | |
newptr = ALLOC_N( VALUE, ROBJECT_EMBED_LEN_MAX ); | |
MEMCPY( newptr, ptr, VALUE, len ); | |
RBASIC( object )->flags &= ~ROBJECT_EMBED; | |
ROBJECT( object )->as.heap.ivptr = newptr; | |
return object; | |
} |
This file contains hidden or 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_relative '../lib/rpersist.rb' | |
require_relative './rpersist_mocks.rb' | |
# we have two types of persistence | |
# * explicit persistence (object.persist!) | |
# * implicit (atomic) persistence | |
# additionally, we have two types of atomic persistence | |
# * atomic accessors | |
# * atomic functions |
This file contains hidden or 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
#https://gist.github.com/709860 | |
require 'benchmark' | |
# does Benchmark::bmbm have environments/setup like Test::Unit | |
# want some variables to be set per benchmark case - now have to dup them myself | |
# is is needed as the testcases have destructive operations, otherwise the testcases will be dependent on each other | |
def benchmark_setup(obj=TOP_SELF) | |
code = <<-CODE |
This file contains hidden or 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
#https://gist.github.com/709860 | |
require 'benchmark' | |
# does Benchmark::bmbm have environments/setup like Test::Unit | |
# want some variables to be set per benchmark case - now have to dup them myself | |
# is is needed as the testcases have destructive operations, otherwise the testcases will be dependent on each other | |
larger_benchmark = Proc.new do |benchmark| | |
big = (1..95).to_a |
This file contains hidden or 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
Twines are singular encapsulations of methods with stateful context. They: | |
* function like methods from a high level perspective | |
* can have invisible private helper methods | |
* have a namespaced name, like modules (but probably should not share the class namespace) | |
* have ivars (which are stateful) | |
* have local vars (which are stateless) | |
* are aspect oriented | |
* allow the creation of "complex types" that look like variables but internally function like methods | |
* can be used transparently in classes like methods |
This file contains hidden or 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
array = [ :a, :b, :c] | |
num = rand( 100 ) | |
if (0..60).include?( num ) | |
num = 0 | |
elsif (61..75).include?( num ) | |
num = 1 | |
elsif (76..100).include?( num ) | |
num = 2 | |
end | |
puts array[num] |
This file contains hidden or 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
/************ | |
* each * | |
************/ | |
VALUE rb_RPDB_DatabaseCursor_iterate( VALUE rb_database_cursor ) { | |
// If we don't have a block, we return an enumerator | |
R_ReturnEnumeratorIfNoBlock( rb_database_cursor, | |
0, | |
NULL ); |
This file contains hidden or 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
# Rpersistence::Adapter::Rbdb | |
# | |
# Rpersistence Adapter for Oracle's Berkeley Database (BDB) accessed with Rbdb | |
class Rpersistence::Adapter::Rbdb | |
attr_accessor :home_directory | |
ObjectIDDatabase = 'Rpersistence_Database_GlobalObjectID' | |
ObjectIDSequence = 'Rpersistence_Sequence_GlobalObjectID' |