View SoundManager2
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(window, _undefined){ | |
if ( window === _undefined ) | |
throw new Error('SoundManager requries a window object!'); | |
// here be the lib code | |
// use can attach what you must to the window object here! | |
if ( typeof module === "object" && module && typeof module.exports === "object" ) { | |
//CommonJs | |
// the "strict" way is to never expose as a global object if possible, so no sm2 on the window |
View gist:8981812
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
Promise.castEmitter = function (item, resolveEvents, rejectEvents) { | |
var methods = { | |
on: _.has(item, 'on') ? 'on' : 'bind', | |
off: _.has(item, 'off') ? 'off' : _.has(item, 'removeListener') ? 'removeListener' : 'unbind' | |
}; | |
function unbindAll(events, fn) { | |
for (var i = 0; i < events.length; i++) |
View gist:9fc74f777f1ddd74ca2b
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 xhr = $.ajax({}).then(null, function(){}) | |
var promise = Promise.cast(xhr) | |
xhr.abort() |
View gist:8017e71e4d7ce19827ce
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
request('http://ugenr.dk/', function (error, response, html) { | |
if (!error && response.statusCode == 200) { | |
var $ = cheerio.load(html); | |
$('span#ugenr').each(function(i, element){ | |
var ugeNr = $(this).text(); | |
ugeNr = ugeNr.split(" "); | |
ugeNr = ugeNr[1] | |
request('http://skema1.domain.com/services/elevSkema.ashx?idx=randomNumber&week='+ugeNr, secondCallback); |
View gist:19c34095b1dc71101caf
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 getDay(callback) { | |
request('http://www.timeanddate.com/', function date(error, response, html){ | |
if (!error && response.statusCode == 200) { | |
var $ = cheerio.load(html); | |
$('span#ij1').each(function(i, element){ | |
var dag = $(this).text(); | |
console.log(dag); | |
View gist:051207cee99ec7c643a5
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 joinClasses(){ | |
var args = [].slice.call(arguments, 0) | |
return args.reduce(function(current, next){ | |
if(!current) return next | |
if( next) return (current ? current + " " : "") + next | |
}) | |
} |
View gist:6508bfce7a248f85434e
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 strict'; | |
var React = require('react') | |
, hasOwn = Object.prototype.hasOwnProperty | |
, version = React.version.split('.').map(parseFloat) | |
, RESERVED = { | |
className: resolve(joinClasses), | |
children: function(){}, | |
key: function(){}, | |
ref: function(){}, | |
style: resolve(extend) |
View gist:44315ee5eb506a2aafe6
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
// my thing | |
Thing = { | |
addPromise: function(fn){ | |
Promise.resolve(fn.call(this, 'input')) | |
.then(function(val){ | |
//do wahtever | |
}) | |
}, |
View with callbacks
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
compose([your, code, looks, like, shit]); | |
function compose(_chain) { | |
chain = _chain.reverse(); | |
(function next(index, args) { | |
args.push(callback) | |
if(index < chain.length) | |
chain[index].apply(this, args) |
View gist:c78d72ddd1523095f95c
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(msg){ | |
dispatcher.dispatch('CREATE_MSG', msg); | |
api.saveMsg(msg).then(msg => { | |
dispatcher.dispatch('CREATE_MSG_COMPLETE', msg) //id is available here | |
}) | |
} |
OlderNewer