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 'rubygems' | |
| require 'benchmark' | |
| require 'riak' | |
| require 'json' | |
| require 'pp' | |
| class Time | |
| def ms_from_epoc | |
| k = 1000 |
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 'rubygems' | |
| require 'riak' | |
| require 'json' | |
| require 'benchmark' | |
| require 'pp' | |
| $client = Riak::Client.new :protocol => :pbc | |
| def count_all_keys | |
| mr = Riak::MapReduce.new($client). |
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 'rubygems' | |
| require 'riak' | |
| require 'json' | |
| require 'benchmark' | |
| require 'pp' | |
| $client = Riak::Client.new :protocol => :pbc | |
| def count_all_keys | |
| mr = Riak::MapReduce.new($client). |
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
| (ns lambda-list) | |
| ;;; basic linked list using lambdas | |
| ; construct a pair containing x and y | |
| (defn pair [x y] | |
| (fn [b] | |
| (if b x y))) | |
| ; construct a singleton list containing x |
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 Huffman where | |
| import Data.Map | |
| import Data.Word | |
| import Data.Ord | |
| import Data.List | |
| import Data.Maybe | |
| data Tree a = Node {small::Tree a, big::Tree a} | |
| | Leaf {occurrences::Int, symbol::a} |
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
| # compose lambdas f & g | |
| # (f << g).(x) | |
| class Proc | |
| def <<(g) | |
| -> x { self.(g.(x)) } | |
| end | |
| 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
| require 'pp' | |
| raw = File.read 'redis.conf' | |
| pp raw.lines.reject { |line| line =~ %r{^\s*[#]} } | |
| pp raw.lines.reject do |line| | |
| line =~ %r{^\s*[#]} | |
| 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
| threeven = -> n { n % 3 == 0 } | |
| fourven = -> n { n % 4 == 0 } | |
| fiven = -> n { n % 5 == 0 } | |
| rs = (0..10000).to_a.sample(30) | |
| rs.each do |r| | |
| case r |
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 r == P | |
| #do_something ... | |
| elsif r * 2 < Q | |
| #do_something ... | |
| elsif some_test(r) | |
| #do_something ... | |
| else | |
| raise "unpossible" | |
| 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
| puts $0 | |
| puts $0.size | |
| puts | |
| $0 = 'abc' * 20 | |
| puts $0 | |
| puts $0.size | |
| puts |