Skip to content

Instantly share code, notes, and snippets.

View drKreso's full-sized avatar

Kresimir Bojcic drKreso

View GitHub Profile
@drKreso
drKreso / gist:5070534
Last active December 14, 2015 10:10 — forked from anonymous/gist:5070416
char *lib_name_2;
/* Initialize the object; grab native call part of its body. */
NativeCallBody *body = get_nc_body(interp, $1);
/* Try to load the library. */
body->lib_name = lib_name;
body->lib_handle = dlLoadLibrary(strlen(lib_name) ? lib_name : NULL);
if (!body->lib_handle) {
@drKreso
drKreso / when.rb
Created December 6, 2011 07:05 — forked from avdi/when.rb
Experimenting with Object#when in Ruby
class Object
def when(matcher)
if matcher === self then yield(self) else self end
end
end
# I read it like this : if "when" lambda/proc is true execute block, otherwise return self
#deeply confused
#Proc#=== is equivalent to Proc#call
@drKreso
drKreso / dependency_injection_example.rb
Created November 20, 2011 22:40 — forked from bravoecho/dependency_injection_example.rb
Flexibility with and without Dependency Injection
require 'minitest/autorun'
class UsTaxCode
def generate(id)
"US-#{id}"
end
end
class BrazilTaxCode
def generate(id)