Skip to content

Instantly share code, notes, and snippets.

View alessioalex's full-sized avatar

Alexandru Vlăduţu alessioalex

View GitHub Profile
1) Scaling out to multiple processes (by default a LDB database can only be accessed by a single Node process):
- https://github.com/juliangruber/multilevel
- https://github.com/substack/level-party - no need to take care of multilevel sever and multilevel client, this module does that for us
2) Namespaces / namespacing
- https://www.npmjs.org/package/level-sublevel
- https://github.com/juliangruber/level-prefix
var fs = require('fs');
var lame = require('lame');
var Speaker = require('speaker');
fs.createReadStream(process.argv[2])
.pipe(new lame.Decoder())
.on('format', function (format) {
this.pipe(new Speaker(format));
});
@alessioalex
alessioalex / deps_autorun.js
Created June 20, 2014 13:38
Mimmicking Deps.autorun from Meteor in pure Node
"use strict";
var EventEmitter = require('events').EventEmitter;
var Session = new EventEmitter();
Session.data = {};
Session.get = function(key) {
return this.data[key] || null;
@alessioalex
alessioalex / rwd.css
Created July 31, 2014 15:15 — forked from trey/rwd.css
/* http://twitter.github.com/bootstrap/scaffolding.html#responsive */
/* Landscape phones and down */
@media (max-width: 480px) { ... }
/* Landscape phone to portrait tablet */
@media (max-width: 768px) { ... }
/* Portrait tablet to landscape and desktop */
@media (min-width: 768px) and (max-width: 940px) { ... }
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2014
Copyright (C) 2014 Addy Osmani @addyosmani
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@alessioalex
alessioalex / convert.js
Last active August 29, 2015 14:10 — forked from rf/convert.js
var fs = require('fs');
var infile = process.argv[2];
if (!infile) return console.log("need infile");
var data = fs.readFileSync(infile, 'utf8').split('\n');
var outlines = [];
data.forEach(function(item) {
@alessioalex
alessioalex / configurable-logger-example.js
Created November 22, 2014 08:25
configurable-logger-example.js
// TODO: given the log function previously created, create a prefixed logger
// function that takes a {String} as an argument.
// That string should be used as the first argument to the regular `log` function.
var log = function log() {
var args = Array.prototype.slice.call(arguments);
console.log(args.join(' '));
};
// log('hello', 'world', '!');
@alessioalex
alessioalex / async-cache-0.js
Created November 22, 2014 08:37
async-cache-0.js
// TODO: create a cache mechanism for asynchronous functions
// the async functions should look like this:
//
// function getSomething(id, callback) { .. }
//
// Our caching function should take 2 args: the original function and an
// async function that tries to grab the data from cache.
// This async function should return another function that we will use instead of
// the original one.