Skip to content

Instantly share code, notes, and snippets.

@l4u
l4u / gist:3050396
Created July 5, 2012 01:15
installing erlang reloader
cd ~/bin
wget https://github.com/mochi/mochiweb/raw/master/src/reloader.erl
# Compile
erlc reloader.erl
# Edit ~/.erlang
code:load_abs(“/Users/leo/bin/reloader”).
reloader:start().
@l4u
l4u / gist:3047475
Created July 4, 2012 13:53
erlang cowboy 404 onresponse_hook
%% Hook for the above onresponse tests.
onresponse_hook(Status, Headers, Req) ->
case Status of
404 ->
{ok, Html} = file:read_file("www/404.html"),
{ok, Req2} = cowboy_http_req:reply(404, [], Html, Req),
Req2;
_ ->
Req
end.
@l4u
l4u / gist:2923332
Created June 13, 2012 10:35
aria2c read from firefox mac cookie
aria2c -x4 -s4 --load-cookies=/Users/Leo/Library/Application\ Support/Firefox/Profiles/3kztyzg0.default/cookies.sqlite
@l4u
l4u / gist:2643736
Created May 9, 2012 11:01
AdWhirl cocoapods spec
exts = [
'BrightRoll',
'GoogleAdMobAds',
'GoogleAdSense',
'Greystripe',
'IAd',
'InMobi',
'JumpTap',
'MdotM',
'Millennial',
@l4u
l4u / gist:2626643
Created May 7, 2012 08:25
assaf/rack-oauth2-server reuse mongoid config
mongoid_config = Mongoid.load! Rails.root.join('config/mongoid.yml')
config.oauth.database = Mongo::Connection.new(mongoid_config['host'], mongoid_config['port']).db(mongoid_config['database'])
@l4u
l4u / gist:2625795
Created May 7, 2012 03:48
mongoid devise_invitable
#invitable
field :invitation_token, :type => String
field :invitation_sent_at, :type => Time
field :invitation_accepted_at, :type => Time
field :invitation_limit, :type => Integer
field :invited_by_id, :type => String
field :invited_by_type, :type => String
@l4u
l4u / gist:2625600
Created May 7, 2012 03:01
Rails OAuth Provider
https://github.com/applicake/doorkeeper/tree/mongoid-support
https://github.com/applicake/doorkeeper
https://github.com/socialcast/devise_oauth2_providable
https://github.com/assaf/rack-oauth2-server (MongoDB only, with admin interface)
https://github.com/nov/rack-oauth2
https://github.com/pelle/oauth-plugin
@l4u
l4u / gist:2622816
Created May 6, 2012 15:04
web view javascript
https://github.com/marcuswestin/WebViewJavascriptBridge
https://github.com/newyankeecodeshop/GAJavaScript
@l4u
l4u / gist:2584103
Created May 3, 2012 07:47
Allow Rack Static to serve files with HTTP POST, for the stupid Facebook canvas apps
module Rack
class File
ALLOWED_VERBS = %w[GET HEAD POST]
end
end
@l4u
l4u / gist:2583070
Created May 3, 2012 04:07
Chicagoboss tutorial output json
-module(cb_tutorial_greeting_controller, [Req]).
-compile(export_all).
hello('GET', []) ->
{json, [{greeting, "Hello, world!"}]}.
list('GET', []) ->
Greetings = boss_db:find(greeting, []),
case Greetings of
[] ->
{output, <<"[]">>, [{"Content-Type", "application/json"}]};