Skip to content

Instantly share code, notes, and snippets.

View flockonus's full-sized avatar
🏯

Fabiano flockonus

🏯
View GitHub Profile
@flockonus
flockonus / Phaser-#0.markdown
Created February 11, 2014 03:08
A Pen by FabianoPS.
$('#some-answers').fadeIn()
(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))
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.)
@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
@flockonus
flockonus / minimal.js
Last active August 29, 2015 14:20
Express get lost in co() context --WRONG
var express = require('express');
var app = express();
var co = require('co');
function * sleep(){
var p = new Promise(function(w,f){
setTimeout(w,1000,'winning');
});
return yield p;
@flockonus
flockonus / gist:ee26abd6887cc79ec3f0
Created June 5, 2015 19:37
consistency-ui-design-creativity
already have downloaded too
http://www.uxpin.com/consistency-ui-design-creativity.html
@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 / development.log
Created October 26, 2010 23:41
Fabiano's dev log, slow?
# Logfile created on Tue Oct 26 21:16:39 -0200 2010* Loaded locales: ["brca", "da", "de", "el", "en", "eo", "es", "es-419", "fr", "gl", "ia", "id", "it", "ja", "ko", "mk", "nl", "pt-BR", "pt-PT", "ru", "te"]
admin['$cmd'].find({:ismaster=>1}, {}).limit(-1)
shapado-development['$cmd'].find({"$eval"=>"db.system.js.save({_id: 'find_tags', value: function find_tags(collection, regex, query, limit) {\n var counts = db.eval(\n function(collection, regex, query){\n var counts = {};\n db[collection].find(query, {\"tags\":1}).limit(500).forEach(\n function(p){\n if ( p.tags ){\n for ( var i=0; i<p.tags.length; i++ ){\n var name = p.tags[i];\n if(name.match(regex) != null)\n counts[name] = 1 + ( counts[name] || 0 );\n }\n }\n }\n );\n return counts;\n },\n collection,\n regex,\n query\n );\n\n var tags = [];\n for ( var tag in counts ){\n tags.push( { name : tag , count : counts[tag]
@flockonus
flockonus / ActionLogger - FlockonUS.rb
Created November 1, 2010 23:15
/lib/action_logger.rb
class ActionLogger
@@queue = []
@@limit = (Rails.env == 'development' ? 0 : 100 )
def self.add(str)
@@queue.push(str)
store! if @@queue.size >= @@limit
end
def self.store!