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 failPromise = new Promise(function(accept,reject){ | |
setTimeout(reject,1000,'fail'); | |
}); | |
// won't see the numbers logged, will skip to the fail | |
failPromise.then(()=> console.log(1)) .then(()=> console.log(2)) .catch((e)=> console.log(':::%s',e)); |
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
cat <<EOT > .git/hooks/pre-push | |
#!/bin/sh | |
npm test | |
EOT | |
chmod +x .git/hooks/pre-push |
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
/*! | |
* Velocity.js: Accelerated JavaScript animation. | |
* @version 0.0.0 | |
* @requires jQuery.js | |
* @docs julian.com/research/velocity | |
* @license Copyright 2014 Julian Shapiro. MIT License: http://en.wikipedia.org/wiki/MIT_License | |
*/ | |
!function(e,t,a,r){function o(e){for(var t=-1,a=e?e.length:0,r=[];++t<a;){var o=e[t];o&&r.push(o)}return r}function i(e){return"[object Function]"===Object.prototype.toString.call(e)}function l(t){if(t)for(var a=(new Date).getTime(),o=0,i=e.velocity.State.calls.length;i>o;o++)if(e.velocity.State.calls[o]){var s=e.velocity.State.calls[o],g=s[0],d=s[2],f=s[3];f||(f=e.velocity.State.calls[o][3]=a-16);for(var y=Math.min((a-f)/d.duration,1),m=0,h=g.length;h>m;m++){var v=g[m],x=v.element;if(e.data(x,u)){var P=!1;d.display&&"none"!==d.display&&(p.setPropertyValue(x,"display",d.display),e.velocity.State.calls[o][2].display=!1);for(var b in v)if("element"!==b){var V=v[b],S=V.currentValue,k;if(1===y)k=V.endValue;else if(k=V.startValue+(V.endValue-V.startValue)*e.easing[V.easing](y),!/translate/i |
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
import java.util.Arrays; | |
public class MakeChange | |
{ | |
// Returns the count of all possible ways to make exact change for the | |
// given total using the coin denominations in the coins[] array. | |
// | |
// Each coin can be used more than once, but the order of the coins is | |
// irrelevant (in other words, "1, 1, 2" and "1, 2, 1" count as a | |
// single possibility.) |
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
(defun allpossibilities (total coins) | |
"Given a total amount of money, and a list of denominations, return the total number of possible combinations of denominations that would sum up to total" | |
(let ((ans-table (make-hash-table :test 'equal))) | |
(labels ((iter (left ans) | |
(cond ((= left 0) (setf (gethash (sort (copy-list ans) #'>) ans-table) 1)) | |
((< left 0) nil) | |
(t (dolist (coin coins) | |
(iter (- left coin) | |
(cons coin ans))))))) | |
(iter total nil)) |
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
$('#some-answers').fadeIn() |
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
{ | |
"result": [ | |
{ | |
"avg_distance": 3.475555555555557, | |
"keen": { | |
"created_at": "2013-09-16T22:21:02.326000+00:00", | |
"location": { | |
"coordinates": [ | |
-122.472668, | |
37.785639 |
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
// https://npmjs.org/package/smeans | |
// create 4 clusters, why? (?) | |
var data = []; for(var i = 0; i < 10000; i++){ data.push(i*Math.random()) }; clusters = Object.keys( require('smeans').cluster( data ) ).length |
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 OBJECT, env, logglyConfig, logglyKey, logglyMiddleware, services; | |
logglyKey = "[SUPPRESS]"; | |
env = process.env.API_ENV; | |
logglyConfig = { | |
subdomain: "fabian......", | |
json: true | |
}; |