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 Foo | |
| autoload :Bar, 'foo/bar' | |
| autoload :Baz, 'foo/baz' | |
| 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
| @instance_store = {} | |
| class App.Model extends Backbone.Model | |
| cache_enabled: false | |
| cache_key: "id" | |
| constructor: (attr) -> | |
| @on "destroy", @_removeFromStore |
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
| # ### Point.angleForCircle( origin, point ) -> Number | |
| # | |
| # * **origin** ( `Point` ): Origin of circle. | |
| # * **point** ( `Point` ): Point to find angle of. | |
| # | |
| # Get the angle (in degrees) of a point for a given origin of a circle. | |
| Point.angleForCircle = (origin, point) -> | |
| x = origin.x - point.x | |
| y = origin.y - point.y | |
| r = Math.sqrt Math.pow(x, 2) + Math.pow(y, 2) |
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
| # Find closest point to a set of points. | |
| findClosestPoint = (needle, haystack) -> | |
| (init = new Point).diff = Number.MAX_VALUE | |
| comparator = (memo, point) -> | |
| point.diff = Math.abs(needle.x - point.x) + Math.abs(needle.y - point.y) | |
| if point.diff < memo.diff then point else memo | |
| _.foldl haystack, comparator, init | |
| # Find closest point to a set of points based on angles. | |
| findClosestPointByAngle = (needle, haystack, origin) -> |
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
| # Find closest point to a set of points. | |
| findClosestPoint = (needle, haystack) -> | |
| (init = new Point).diff = Number.MAX_VALUE | |
| comparator = (memo, point) -> | |
| point.diff = Math.abs(needle.x - point.x) + Math.abs(needle.y - point.y) | |
| if point.diff < memo.diff then point else memo | |
| _.foldl haystack, comparator, init | |
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 'rake/clean' | |
| BIN = "public_html" | |
| HAML = FileList['**/*.haml'] | |
| LESS = FileList['**/*.less'] | |
| COFFEE = FileList['**/*.coffee'] | |
| SASS = FileList['**/*.scss'] | |
| HTML = HAML.ext('html') |
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.exports = (function(){ | |
| const MS = | |
| { seconds: 1000 | |
| , minutes: 60 * 1000 | |
| , hours: 60 * 60 * 1000 | |
| , days: 24 * 60 * 60 * 1000 | |
| , weeks: 7 * 24 * 60 * 60 * 1000 | |
| , months: 30 * 7 * 24 * 60 * 60 * 1000 | |
| , years: 365 * 24 * 60 * 60 * 1000 } |
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
| #!/usr/bin/env zsh | |
| # git-feature | |
| # Written by: Gianni Chiappetta <gianni@runlevel6.org> | |
| # Requires: git 1.7.5+, zsh 4.3.11+ | |
| # Screenshot: http://cloud.gf3.ca/6TPb | |
| function c_list { echo " \033[1;32mβ\033[0m $1"; } | |
| function e_list { echo " \033[1;31mβ\033[0m $1"; } |
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 elemDisplays = {}, | |
| // Store the iframe outside the function to reuse it | |
| iframe; | |
| function defaultDisplay( nodeName ) { | |
| if ( !elemDisplays[ nodeName ] ) { | |
| // Try the classical method first, which is far faster | |
| var elem = document.createElement( nodeName ), | |
| display; | |
| document.body.appendChild( elem ); |
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 User( options ) { | |
| (this.options = options || {} ).__proto__ = User.options | |
| // Private | |
| function utilityMethod() { return "oh hai" } | |
| // Public | |
| this.say = function say() { | |
| return this.options.awesome ? utilityMethod() : ':(' | |
| } |