Skip to content

Instantly share code, notes, and snippets.

View flockonus's full-sized avatar
🏯

Fabiano flockonus

🏯
View GitHub Profile
@flockonus
flockonus / fail later (native).js
Last active September 22, 2015 02:27
Promise Fail Test
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));
@flockonus
flockonus / +readme.sh
Last active August 29, 2015 14:20
Prevent Travis surprises to your nodes:
cat <<EOT > .git/hooks/pre-push
#!/bin/sh
npm test
EOT
chmod +x .git/hooks/pre-push
/*!
* 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
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.)
(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))
$('#some-answers').fadeIn()
@flockonus
flockonus / Phaser-#0.markdown
Created February 11, 2014 03:08
A Pen by FabianoPS.
@flockonus
flockonus / top_wines.json
Last active December 23, 2015 05:29
keen.io extraction
{
"result": [
{
"avg_distance": 3.475555555555557,
"keen": {
"created_at": "2013-09-16T22:21:02.326000+00:00",
"location": {
"coordinates": [
-122.472668,
37.785639
@flockonus
flockonus / sample.js
Created August 1, 2013 21:03
simple math cluster
// 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
@flockonus
flockonus / JavaScriptTranslation.js
Last active December 16, 2015 04:59
Loggly + Express.js/Connect middleware see full article: [http://wp.me/pfl8Y-7X]
var OBJECT, env, logglyConfig, logglyKey, logglyMiddleware, services;
logglyKey = "[SUPPRESS]";
env = process.env.API_ENV;
logglyConfig = {
subdomain: "fabian......",
json: true
};