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
| (define (is-awesome? name) | |
| (if (eq? name 'github) | |
| #t | |
| #f)) | |
| (is-awesome? 'pastie) ; => #f | |
| (is-awesome? 'github) ; => #t |
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 Object | |
| def try(method, *args, &block) | |
| respond_to?(method) ? send(method, *args, &block) : nil | |
| 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
| class Proc | |
| def curry(*arguments) | |
| if arguments.empty? | |
| return self | |
| else | |
| _proc = self.dup | |
| return lambda do |*args| | |
| return _proc.call(*arguments.concat(args)) | |
| 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
| module WithScopes | |
| def with_scopes(*named_scopes) | |
| named_scopes.inject(self) { |klass, scope| klass.send(scope) } | |
| end | |
| end | |
| ActiveRecord::Base.extend(WithScopes) |
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 to contain logic for fixing characters. | |
| var FigureFixer = { | |
| Map: { }, // Holds character/code pairs | |
| // Adds a character/code pairing, where the "code" | |
| // is the escaped string and the "character" is the | |
| // character that should replace it. | |
| add: function(code, character) { | |
| FigureFixer.Map[code] = character; | |
| }, |
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
| %w(rubygems sinatra).each { |lib| require lib } | |
| get '/' do | |
| "Fellow World!" | |
| 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
| %w(rubygems dm-core sinatra erb).each { |lib| require lib } | |
| # Easier on the eyes | |
| class String | |
| def erb_eval(b) | |
| ERB.new(self).result(b) | |
| end | |
| end | |
| # Blogs need posts |
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
| // Namespace for Bounce effects | |
| var Bounce = { | |
| squashStretch: function(options) { | |
| var settings = { | |
| maxDev: 13, // max deviation in pixels | |
| speed: 30, // speed of oscillation | |
| decay: 1.0 // how fast it slows down | |
| } | |
| options = options || { } |
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
| # Use this Capfile to deploy a gist via Capistrano. | |
| # | |
| # If the gist you want to deploy is here: http://gist.github.com/3401, | |
| # just fill in the appropriate server settings (domain, deploy_to, etc) | |
| # and run the following command: | |
| # | |
| # cap deploy GIST=3401 | |
| # | |
| # You might need to run cap deploy:setup first. | |
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 'johnson' | |
| require 'spec' | |
| RUNTIME = Johnson::Runtime.new | |
| RUNTIME.evaluate <<-JS | |
| var Person = function(name) { | |
| this.name = name; | |
| this.foods = []; | |
| } |
OlderNewer