Skip to content

Instantly share code, notes, and snippets.

View practicingruby's full-sized avatar

Gregory Brown practicingruby

View GitHub Profile
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
if RUBY_VERSION < "1.9"
def ruby18
yield
end
def ruby19
false
end
else
def ruby18
false
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
# 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
We couldn’t find that file to show.
# 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
#!/usr/local/bin/ruby
require "rubygems"
require "rake"
require "erb"
def ProcessTemplate(file)
ERB.new(File.read(file)).result(binding)
end
class Foo
def bar
blah
end
end