This file contains 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
# List monad implementation: | |
# hmmm..., not sure | |
concat = (xs, ys) -> | |
| xs is Empty => ys | |
| ys is Empty => xs | |
| otherwise => | |
Cons do xs, concat(xs.tail, ys) | |
flatten1 = (xss) -> |
This file contains 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 'rest-core' | |
class BlockingClient | |
def initialize *args | |
@client = RC::Universal.new(*args) | |
end | |
def get path, params={}, opts={} | |
@client.get(path, params, opts).tap{} | |
end | |
end |
This file contains 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
client = RestCore::Facebook.new(log_method: method(:puts), app_id: FACEBOOK_APP_ID, secret: FACEBOOK_APP_SECRET) | |
client.post("1234567/feed", params: post_params) | |
# error: | |
# RestCore::Facebook::Error::InvalidAccessToken: {"error"=>{"message"=>"(#200) This API call requires a valid app_id.", "type"=>"OAuthException", "code"=>200}} from https://graph.facebook.com/1234567/feed | |
# secret access token: | |
client.post("1234567/feed", params: post_params, {}, :secret => true) |
This file contains 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
X = 1 | |
# Module.constants returns constants accessible at the place where the | |
# method is called. | |
p Module.constants.include?(:X) #=> true | |
# Module#constants returns constants defined in the receiver. However, | |
# you need a trick to invoke Module#constants on Module itself. | |
p Module.instance_method(:constants).bind(Module).call #=> [] |
This file contains 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
desc 'Runs test:units, test:functionals, test:integration together (also available: test:benchmark, test:profile, test:plugins)' | |
task :test do | |
tests_to_run = ENV['TEST'] ? ["test:single"] : %w(test:units test:functionals test:integration) | |
errors = tests_to_run.collect do |task| | |
begin | |
Rake::Task[task].invoke | |
nil | |
rescue => e | |
{ :task => task, :exception => e } | |
end |