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 commented version, see https://gist.github.com/4259920/95d6d741d227c274be1ecf5238998c01f3658131 */ | |
function object(o){ | |
function ctor(){} | |
ctor.prototype = o; | |
return new ctor; | |
} | |
function inheritProto(subType,superType){ | |
var prototype = object(superType.prototype); | |
prototype.constructor = subType; |
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
<script> | |
var people = getData(); // however you get your data ... | |
/* structure | |
{ | |
people : [ | |
{ name : "Shiva Khomini Somar Kondar Krohm" }, | |
{ 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
/* how to bind `this` for callbacks, good example here too: | |
http://ejohn.org/apps/learn/#84 | |
*/ | |
var uiThing = { | |
parseResponse : function(data){ | |
this.data = data; | |
this.renderUI() | |
}, | |
renderUI : function(){ /* more code */ } |
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
// assumes Q.js has been loaded and available as Q | |
function ajaxCall(){ | |
var dfd = Q.defer(), | |
data = getData({ | |
success: function(response){ | |
dfd.resolve(response); | |
}, | |
error: function(error){ | |
dfd.reject(error); | |
} |
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 mod = (function(){ | |
var foo; // set from outside | |
function setItem(val){ | |
val && (foo = val); | |
} | |
return { setItem: setItem }; | |
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($){ | |
var slides, numSlides, | |
ct = 0, | |
settings = { | |
duration: 500, | |
easing: 'cubic-bezier(1.000, 0.000, 0.000, 1.000)' | |
}; | |
function transition(){ |
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
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8" /> | |
</head> | |
<body> | |
<script src="js/module-1.js"></script> | |
<script src="js/module-2.js"></script> | |
</body> |
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(['jquery', 'handlebars'],function($,Handlebars){ | |
/* use: | |
var tmpl = App.helpers.tmpl, | |
getCompiledTemplate = tmpl('foo', {}); | |
getCompiledTemplate.then(function(content){ | |
$('#something').html(content); | |
}); |
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
# If you have OpenSSL installed, we recommend updating | |
# the following line to use "https" | |
source 'http://rubygems.org' | |
gem "middleman", :github => "middleman/middleman" | |
gem 'middleman-sprockets', :github => "middleman/middleman-sprockets" | |
gem "stylus" | |
gem "slim" | |
gem "gist" |
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($){ | |
$(function(){ | |
// code in here | |
}) | |
})(window.jQuery) |