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
| 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 |
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
| if RUBY_VERSION < "1.9" | |
| def ruby18 | |
| yield | |
| end | |
| def ruby19 | |
| false | |
| end | |
| else | |
| def ruby18 | |
| false |
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 "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 |
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
| # 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 |
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
| # 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 |
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 Jia |
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 Jia |
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
| #!/usr/local/bin/ruby | |
| require "rubygems" | |
| require "rake" | |
| require "erb" | |
| def ProcessTemplate(file) | |
| ERB.new(File.read(file)).result(binding) | |
| end |
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
| class Foo | |
| def bar | |
| blah | |
| end | |
| end |