Skip to content

Instantly share code, notes, and snippets.

View godfat's full-sized avatar

Lin Jen-Shin (godfat) godfat

View GitHub Profile
@godfat
godfat / list.ls
Last active December 20, 2015 17:49 — forked from caasi/list.ls
# 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) ->
@godfat
godfat / gist:4266074
Created December 12, 2012 08:24 — forked from fumin/futures.rb
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
@godfat
godfat / gist:3215178
Created July 31, 2012 08:53 — forked from lulalala/gist:3214537
rest-more facebook error
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)
@godfat
godfat / constants.rb
Created January 12, 2012 07:41 — forked from shugo/constants.rb
How to invoke Module#constants on Module itself
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 #=> []
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