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
| include js file: http://connect.facebook.net/en_US/all.js | |
| // load facebook api | |
| $('<div id="fb-root"></div>').appendTo("body"); | |
| FB.init({ | |
| appId : '168055643260227', | |
| status : true, // check login status | |
| cookie : true, // enable cookies to allow the server to access the session | |
| xfbml : true // parse XFBML | |
| }); |
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
| include js file: http://connect.facebook.net/en_US/all.js | |
| // load facebook api | |
| $('<div id="fb-root"></div>').appendTo("body"); | |
| FB.init({ | |
| appId : '168055643260227', | |
| status : true, // check login status | |
| cookie : true, // enable cookies to allow the server to access the session | |
| xfbml : true // parse XFBML | |
| }); |
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 'rspec' | |
| # TODO: class vars? | |
| # TODO: better just alias_method_chain method_missing for the duration of running the method | |
| module Tdef | |
| def self.check_args(args, rules) | |
| rules.each_pair do |name, klass| | |
| unless args[name.to_s].kind_of?(klass) | |
| raise "Wrong type: #{name} should be #{klass.to_s}, but is #{args[name].class.to_s}" | |
| 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
| # run with rspec filename.rb | |
| require 'rspec' | |
| # TODO: class vars? | |
| # TODO: better just alias_method_chain method_missing for the duration of running the method | |
| module Tdef | |
| def self.check_args(args, rules) | |
| rules.each_pair do |name, klass| | |
| unless args[name.to_s].kind_of?(klass) | |
| raise "Wrong type: #{name} should be #{klass.to_s}, but is #{args[name].class.to_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
| require 'rubygems' | |
| require 'mongoid' | |
| class User | |
| include Mongoid::Document | |
| include Mongoid::Timestamps | |
| end | |
| # Connect to MongoDB | |
| Mongoid.identity_map_enabled = false |
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
| % Total % Received % Xferd Average Speed Time Time Time Current | |
| Dload Upload Total Spent Left Speed | |
| 100 9979 100 9979 0 0 9705 0 0:00:01 0:00:01 --:--:-- 86025 | |
| Turning on auto mode. | |
| Downloading RVM from wayneeseguin branch stable | |
| % Total % Received % Xferd Average Speed Time Time Time Current | |
| Dload Upload Total Spent Left Speed | |
| 100 1047k 100 1047k 0 0 550k 0 0:00:01 0:00:01 --:--:-- 980k | |
| Upgrading the RVM installation in /home/mrbrdo/.rvm/ |
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
| # null object pattern Objective-C style (togglable) | |
| # more elegant: https://gist.github.com/3792804 | |
| def null_chain | |
| unless NilClass.instance_variable_defined?(:@null_chain) | |
| NilClass.class_eval do | |
| alias_method :nc_mm_orig, :method_missing | |
| def method_missing(name, *args, &block) | |
| if self.class.null_chain? |
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
| # null object pattern Objective-C style (togglable) | |
| def null_chain | |
| begin | |
| return yield | |
| rescue NoMethodError | |
| end | |
| nil | |
| 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
| class NullChainer < BasicObject | |
| def initialize(obj) | |
| @obj = obj | |
| end | |
| def get | |
| @obj | |
| end | |
| def method_missing(name, *args, &block) |