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 TimeZoneFinder | |
| def self.find_gmt_offset(lat,lng) | |
| uri = URI.parse("http://ws.geonames.org/timezone?lat=#{lat}&lng=#{lng}") | |
| doc = Hpricot.XML(Net::HTTP.get(uri)) | |
| (doc/"geonames"/"timezone"/"gmtOffset").innerHTML.to_f | |
| end | |
| end | |
| offset = TimeZoneFinder.find_gmt_offset(some_lat, some_lng) | |
| timezone = ActiveSupport::TimeZone[offset] |
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
| some_function = lambda { |node| puts "Hello" } | |
| nodeList.inject { |individualNode,accumulator| individualNode.function_that_starts_lambdas(some_function) } |
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
| lists:foldl(fun(Elem,Acc) -> % Anonymous function taking two params | |
| Pid = spawn(Elem, fun() -> io:format("Hello",[]) end ), % Spawn a process to run the fun | |
| Acc ++ [Pid] % Add the Pid of the new remote process into our accumulator so we can get it again later | |
| end, [], nodes()) % The [] is our empty accumulator and nodes() will be every node we're connected to |
NewerOlder