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
| function sayHello(name){ | |
| console.log("Hi " + name + "!"); | |
| }; | |
| var name = "Bill"; | |
| { | |
| var name = "Bob"; | |
| sayHello(name); | |
| }; |
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 'redcarpet' | |
| require 'pathname' | |
| path = Pathname.new(ARGV.shift) | |
| raise "Input path must be absolute." unless path.absolute? | |
| raise "Input path must point to a file that exists" unless path.exist? | |
| raise "Input path must point to a file that is readable" unless path.readable? |
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
| // #suite is a helper method to more concisely list | |
| // #describe groups. Example usage: | |
| // | |
| // suite("Examples", { | |
| // | |
| // "before" : function(){ | |
| // // ... setup | |
| // }, | |
| // | |
| // "should one" : function(){ |
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
| (function(window) { | |
| // stuff that uses window a lot here... | |
| })(window); |
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
| var test = function(){ | |
| var args = arguments; | |
| args.push(4); | |
| console.log(args); | |
| } | |
| // Results in a TypeError, as arguments isn't actually an array object. | |
| // To coerce arguments to an array, call Array's slice method: | |
| var test = function(){ |
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
| config.assets.compress = true | |
| config.assets.compile = true | |
| config.assets.digest = true |
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
| # Random idea to use a single integer attribute to store information | |
| # about a group of predefined items on any given object. More about | |
| # bitwise operations and bit shifting: http://en.wikipedia.org/wiki/Bitwise_operation | |
| require 'groupable' | |
| class User | |
| include Groupable | |
| group :roles, %w{ basic admin } | |
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
| # Toss this in your ~/.irbrc file for a convenient way | |
| # to peruse Ruby source code in TextMate. This | |
| # only works in Ruby 1.9! | |
| # | |
| # Use it in irb like so: | |
| # | |
| # >> require 'active_record' | |
| # >> ActiveRecord::Base.source_for_method(:create) | |
| class Object |
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
| Copyright (c) 2011 Jed Schmidt, http://jed.is | |
| Permission is hereby granted, free of charge, to any person obtaining | |
| a copy of this software and associated documentation files (the | |
| "Software"), to deal in the Software without restriction, including | |
| without limitation the rights to use, copy, modify, merge, publish, | |
| distribute, sublicense, and/or sell copies of the Software, and to | |
| permit persons to whom the Software is furnished to do so, subject to | |
| the following conditions: | |
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
| function HostInformation(target, opts){ | |
| var opts = opts || {}, | |
| output = {}, | |
| target = target.location || target; | |
| this.host = function() | |
| { | |
| return target.host; | |
| } |