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
| # 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
| # 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
| 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
| 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
| 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
| 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
| /* 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); |