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
| // For Mike. | |
| Bocoup.utils.template = (function($) { | |
| // Request a template from the server. Returns a Deferred object. | |
| function fn(key) { | |
| return $.Deferred(function(dfd) { | |
| if (key in fn.cache) { | |
| dfd.resolve(fn.cache[key]); | |
| } else { | |
| $.getScript(fn.url + key, 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
| // jQuery BBQ ideas | |
| // ============================================================================ | |
| // MESSAGING BUS | |
| // ============================================================================ | |
| var publish = function(message) { | |
| location.hash = '#' + message; | |
| }; |
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
| // Not great because `addOne` is always created in the current scope (which is | |
| // global when addone.js is included normally). | |
| var addOne = (function() { | |
| return function(n) { | |
| n + 1; | |
| }; | |
| }()); | |
| addOne(2) // 3 |
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
| /*! | |
| * "IIFE" - v0.2 - 9/14/2011 | |
| * http://benalman.com/ | |
| * | |
| * Copyright (c) 2011 "Cowboy" Ben Alman | |
| * Dual licensed under the MIT and GPL licenses. | |
| * http://benalman.com/about/license/ | |
| */ | |
| // Usage: |
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
| /*! | |
| * Backbone Module Manager - v0.1pre - 9/9/2011 | |
| * http://benalman.com/ | |
| * | |
| * Copyright (c) 2011 "Cowboy" Ben Alman | |
| * Dual licensed under the MIT and GPL licenses. | |
| * http://benalman.com/about/license/ | |
| */ | |
| function ModuleManager(fn) { |
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
| <?PHP | |
| # JSONP "callback" param explanation, via basic PHP script. | |
| # | |
| # "Cowboy" Ben Alman | |
| # http://benalman.com/ | |
| # Set $data to something that will be serialized into JSON. You'll undoubtedly | |
| # have your own code for this. | |
| $data = array("some_key" => "some_value"); |
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
| # No yielding | |
| class NormPerson | |
| attr_accessor :first, :last | |
| def initialize(first = nil, last = nil) | |
| @first = first | |
| @last = last | |
| end | |
| def hello | |
| puts "#{@first} #{@last} says hello!" |
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
| /**********************************************/ | |
| /* | |
| /* IR_Black Skin by Ben Truyman - 2011 | |
| /* | |
| /* Based on Todd Werth's IR_Black: | |
| /* http://blog.toddwerth.com/entries/2 | |
| /* | |
| /* Inspired by Darcy Clarke's blog post: | |
| /* http://darcyclarke.me/design/skin-your-chrome-inspector/ | |
| /* |
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
| // See http://javascriptweblog.wordpress.com/2011/08/08/fixing-the-javascript-typeof-operator/ | |
| (function(global) { | |
| // Maintain a map of already-encountered types for super-fast lookups. This | |
| // serves the dual purpose of being an object from which to use the function | |
| // Object.prototype.toString for retrieving an object's [[Class]]. | |
| var types = {}; | |
| // Return a useful value based on a passed object's [[Class]] (when possible). | |
| Object.toType = function(obj) { |
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 dateIfValid(y, m, d) { | |
| var date = new Date(y, --m, d); | |
| return !isNaN(+date) && date.getFullYear() == y && date.getMonth() == m && date.getDate() == d && date; | |
| } |