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
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.29.0/install.sh | bash | |
~/.nvm/nvm.sh |
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
/* | |
* Timer | |
*/ | |
function Timer(callback, interval) { | |
this.nextTick = window.requestAnimationFrame || window.setTimeout; | |
this.interval = interval || 50; | |
this.callback = callback; | |
} | |
Timer.prototype.start = 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
(function() | |
{ | |
var dependencies = [ | |
'myApp/model/Session', | |
'myApp/services/Authenticator', | |
'myApp/controllers/LoginController' | |
]; | |
define( dependencies, function( Session, Authenticator, LoginController ) |
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 keys(object, deep) { | |
'use strict'; | |
var keys = []; | |
function isObject(obj) { | |
var type = typeof obj; | |
return type === 'function' || type === 'object' && !!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 toYQL(url) { | |
var yqlUrl = 'http://query.yahooapis.com/v1/public/yql?q=', | |
query = 'select * from json where url="{url}"'.replace('{url}', url); | |
return yqlUrl + encodeURIComponent(query) + '&format=json'; | |
} | |
function getCORSRequest(method, url) { | |
return new Promise(function(resolve, reject) { |
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 toYQL(url) { | |
var yqlUrl = 'http://query.yahooapis.com/v1/public/yql?q=', | |
query = 'select * from json where url="{url}"'.replace('{url}', url); | |
return yqlUrl + encodeURIComponent(query) + '&format=json'; | |
} |
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
jsonp('//api.flickr.com/services/feeds/photos_public.gne?format=json&jsoncallback=?') | |
.then(function(data) { console.log('flickr', data); }) | |
.catch(function(err) { console.log(err); }); | |
jsonp('//api.stackexchange.com/2.2/info?site=stackoverflow') | |
.then(function(data) { console.log('stackoverflow', data); }) | |
.catch(function(err) { console.log(err); }); |
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
$.ajax({ | |
url: 'http://api.flickr.com/services/feeds/photos_public.gne?format=json&jsoncallback=?', | |
dataType: 'jsonp' | |
}).then(function(data) { | |
console.log(data); | |
}); |
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
/* | |
* From http://stackoverflow.com/a/22780569/141363 modified | |
* to return Promise. | |
* | |
* Usage: jsonp(url) | |
* .then(success) | |
* .catch(error); | |
*/ | |
var jsonp = (function(global, body) { | |
'use strict'; |
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 person = { shoeSize: 43, name: 'nekman' }; | |
Object.observe(person, function(changes) { | |
var change = changes[0]; | |
console.log('Changed property "%s" from %s to %s.', | |
change.name, | |
change.oldValue, | |
change.object[change.name] | |
); | |
}); |