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
<!DOCTYPE html> | |
<!--[if lte IE 6 ]><html class="ie ie6 non-js"><![endif]--> | |
<!--[if IE 7 ]><html class="ie ie7 non-js"><![endif]--> | |
<!--[if IE 8 ]><html class="ie ie8 non-js"><![endif]--> | |
<!--[if gte IE 9 ]><html class="ie ie9 non-js"><![endif]--> | |
<!--[if !IE]>--> | |
<html class="non-js"> | |
<!--<![endif]--> |
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
// use: String.subs('There is no ${foo} foo', { foo: 'bar' }) | |
String.subs = String.subs || function (str, props) { | |
return str.replace(/\$\{([^{}]*)}/g, function (a, b) { | |
var r = props[b]; | |
return typeof r === 'string' || typeof r === 'number' ? r : a; | |
}); | |
}; |
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
Create a git repo and push to remote: | |
mkdir new_git_repo | |
cd new_git_repo | |
git init | |
touch README | |
git add README | |
git commit -m 'first commit' | |
git remote add origin git@my.remote.com/new_git_repo.git | |
git push -u origin master |
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
/** | |
* Creates or decorates an object with observable behavior. | |
* @param {[type]} o object to decorate | |
* @return {[type]} the observable object | |
*/ | |
function makeObservable (o) { | |
var undef; | |
o = o || {}; |
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"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>name</key> | |
<string>Espresso Soda</string> | |
<key>settings</key> | |
<array> | |
<dict> | |
<key>settings</key> |
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
Assuming you have created a submodule 'mysub' in repo 'myrepo' | |
Set the sparse checkout config property in the submodule | |
myrepo/.git/modules/mysub/config: | |
[core] | |
repositoryformatversion = 0 | |
filemode = true | |
bare = false |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>ko: parameterized template</title> | |
<style type="text/css"> | |
li.inline { | |
display: inline-block; |
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
/* | |
an example of how we can reuse common sets of bindings | |
by wrapping them in a single custom binding | |
*/ | |
ko.bindingHandlers.myCompositeBinding = { | |
init: function(element, valueAccessor, allBindingsAccessor, vm){ | |
ko.applyBindingsToNode(element, { | |
text: vm.text, | |
hidden: vm.isHidden, |
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
/** | |
* Nice implementation of Crockford's beget / object.create | |
* @param {Function} base - the base constructor | |
* @return undefined | |
* example: Dog.inherit(Animal); | |
*/ | |
Function.prototype.inherit = function (base) { | |
function Inheriter() { } | |
Inheriter.prototype = base.prototype; | |
this.prototype = new Inheriter(); |
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
// using a promise | |
$.when(doStuff('eat'), doStuff('sleep')).then(function(a, b){ | |
console.log(a + ' and ' + b +' are done'); | |
}); | |
// define the function that returns a promise | |
function doStuff (subject) { | |
var defer = new $.Deferred(); | |