Skip to content

Instantly share code, notes, and snippets.

@PaulMougel
PaulMougel / stream_leveldb.js
Last active December 30, 2015 03:08 — forked from leonardonsantos/stream_leveldb.js
Stream the output of a LevelDB into a socket, using a Transform stream
#!/usr/bin/nodejs
var levelup = require('levelup');
var http = require('http');
var util = require('util');
var Transform = require('stream').Transform || require('readable-stream').Transform;
var server = http.createServer(onRequest);
// Save something in db
@PaulMougel
PaulMougel / mime.js
Last active December 28, 2015 04:59 — forked from chmanie/gist:7441515
MIME checking using streams in Node.js
var stream = require('readable-stream');
var mmm = require('mmmagic');
var mimeChecker = new stream.Transform();
mimeChecker.data = [];
mimeChecker.mimeFound = false;
mimeChecker._transform = function (chunk, encoding, done) {
var self = this;
if (self.mimeFound) {
self.push(chunk);