This file contains 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
# | |
# Caches, renders, ands adds supports for partials and layout to underscore.js templating | |
# | |
# Pass in one options object to renderTemplate: | |
# dir: the root dir where all the templates are located, defaults to views. Paths are resolved as e.g dir/partial.html or dir/layout.html. | |
# partial(s): one or more partial names (without the *.html) to compile, cache, render, and optionally return. | |
# If layout is present, the partials will be passed to the layout template with keys as the partial names | |
# and the layout html will be returned. | |
# partialPrefix: (optional) a name to prepend to all partials. E.g. passing in "products." will load dir/products.partial.html | |
# layout: the name of a layout template (without the *.html). If missing the last or only partial html will be returned. |
This file contains 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
<?xml version="1.0" encoding="utf-8"?> | |
<project name="sample-require-js" default="" basedir="."> | |
<!-- properties --> | |
<property name="r.js" value="_build/rjs/r.js" /> | |
<property name="closure.jar" value="_build/closure/compiler.jar" /> | |
<property name="rhino.jar" value="_build/rhino/js.jar" /> | |
<property name="js.build" value="_build/js.build.js" /> | |
<property name="css.build" value="_build/css.build.js" /> |
This file contains 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
// (c) copyright unscriptable.com / John Hann | |
// License MIT | |
// For more robust promises, see https://github.com/briancavalier/when.js. | |
function Promise () { | |
this._thens = []; | |
} | |
Promise.prototype = { |
This file contains 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($){ | |
var settings, defaults = { | |
prop1 : 'value1', | |
prop2 : 'value2' | |
}; | |
var methods = { |
This file contains 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 JSFiddle: | |
http://jsfiddle.net/cowboy/6asBw/ | |
--> | |
<!-- unminified --> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script> |
This file contains 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
// A RequireJS module that wraps the jQuery UI Dialog in a jQuery.Deferred | |
// Advantages: | |
// Reuses a single DOM element for all the dialogs | |
// Keeps the dialog out of the DOM when it is not in use | |
// A much more elegant interface for using custom modals and working with the user's resolution | |
define("bocoup.confirm",["jquery.ui.widget"],function(factory,position,dialog) { | |
var d = $("<div>"), | |
defaults = { | |
title:"Confirmation" |
This file contains 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
<script type="application/javascript;version=1.8"> | |
var toString = Object.prototype.toString; | |
console.log( | |
[ i for each ( i in [ 1,2,3,4,5 ] ) ] | |
); |
This file contains 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
#!/bin/tcsh | |
# Create a new jQuery Relase | |
# Run like so: | |
# ./release.sh VERSION | |
# By John Resig | |
git pull | |
echo -n $1 > version.txt | |
git add version.txt |
This file contains 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 application = { | |
page_loaded : false, | |
page_init : function() { | |
var i; | |
application.page_loaded = true; | |
// Load scripts that have not already been loaded. | |
var script; | |
for (i=0; script = application.scripts_to_load[i]; i++) { |
This file contains 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
// from https://twitter.com/#!/LeaVerou/status/16613276313980929 | |
// this pattern below is common for using an incoming value otherwise using some default. | |
/* Bad: */ x = x ? x : y; // simple ternary. | |
// if x is truthy lets use it. | |
/* Better: */ x = x || y; // logical OR. | |
// you could string a bunch of these easily to grab the first non-falsy value: |