Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
# http://blog.sigfpe.com/2009/05/three-projections-of-doctor-futamura.html
Coin = Struct.new(:currency)
def minter(blank)
blank.currency = :dollars
end
def interpreter(blank, currency)
blank.currency = currency
We couldn’t find that file to show.
# COMMUNITY CHALLENGE
#
# How would you test this Quiz#problem method? No mocks/stubs allowed.
#
# (Here's @seacreature's take)
class Quiz
def initialize(input = STDIN, output = STDOUT)
@input = input
@output = output
require "ffi"
module MilesDavis
class Client
def initialize
@server_id = API.PCMSOpenServer(0,0)
end
def practical_distance(loc1, loc2)
API.PCMSCalcDistance(@server_id, loc1, loc2) / 10.0
if RUBY_VERSION < "1.9"
def ruby18
yield
end
def ruby19
false
end
else
def ruby18
false
module API
extend FFI::Library
ffi_lib "C:/Windows/pcmsrv32.dll"
attach_function :PCMSOpenServer, [:int, :int], :short
attach_function :PCMSCloseServer, [:short], :int
attach_function :PCMSCalcDistance, [:short, :string, :string], :long
end
module API
extend FFI::Library
ffi_lib "C:/Windows/pcmsrv32.dll"
attach_function :PCMSOpenServer, [:int, :int], :short
attach_function :PCMSCloseServer, [:short], :int
attach_function :PCMSCalcDistance, [:short, :string, :string], :long
end
/* Initialize the server engine. The arguments are currently not used. */
/* Returns a unique ID for this server engine connection. */
short PCMSOpenServer(int hAppInst, int hWnd);
/* Calculate distance from origin to destination. */
long PCMSCalcDistance (short serv, const char *orig, const char *dest);
/* Clean up and dismiss the engine: */
int PCMSCloseServer(short server);