Skip to content

Instantly share code, notes, and snippets.


Rocco Musolino roccomuso

View GitHub Profile

Keybase proof

I hereby claim:

  • I am roccomuso on github.
  • I am roccomuso ( on keybase.
  • I have a public key ASDYVzLuaGmRCGjHViw8SM3gNsZmntfh7GDM8VYJ71lVawo

To claim this, I am signing this object:

roccomuso / streamloop.js
Created Sep 3, 2018
Stream a buffer in loop.
View streamloop.js
const {isBuffer} = Buffer
const {Readable} = require('readable-stream')
class StreamLoop extends Readable {
constructor(data, options = {}) {
if (!isBuffer(data)) throw new Error('data must be a Buffer')
super(options) // Readable opts = data
this.length = data.byteLength
this.offset = 0
roccomuso /
Last active Oct 29, 2018
Update all git repository under a given directory, maxdepth 1.
# store the current dir
# Let the person running the script know what's going on.
echo -e "\n[Pulling in latest changes for all repositories...]"
# Find all git repositories and update it to the master latest revision
for i in $(find ./* -maxdepth 1 -name ".git" | cut -c 3-); do
roccomuso / Interactive-SSH-Client.js
Created Apr 20, 2017
SSH Interactive shell session in Node.js
View Interactive-SSH-Client.js
var Client = require('ssh2').Client;
var readline = require('readline')
var conn = new Client();
conn.on('ready', function() {
console.log('Client :: ready');, stream) {
if (err) throw err;
// create readline interface
var rl = readline.createInterface(process.stdin, process.stdout)
roccomuso / index.html
Last active Apr 10, 2018
p2p-graph esnextbin sketch
View index.html
<!doctype html>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
background-color: #7f7a7a;
roccomuso / Client.js
Last active Oct 8, 2020
Node.js remote shell example
View Client.js
var net = require('net')
var readline = require('readline')
* @class Client
* @param host {String} the host
* @param post {Integer} the port
function Client (host, port) { = host
View debug.js
var path = require('path');
var config = require('config');
var chalk = require('chalk');
* DEBUG wrapper to enhance the debug module features. Include this wrapper into your projects to enable debug from a config file and make the files use the global namespace and their name.
* Use it along with the 'config' module. The provides at least this configuration:
* {namespace: "projectName", debug: true}
roccomuso / log-rotation.js
Last active Oct 29, 2018
stream and save stdout on log files. This snippet also manage automatic deletion for files older than X days.
View log-rotation.js
#!/usr/bin/env node
Don't forget to:
$ chmod 755 log-rotation.js
$ mkdir logs
Then you can save any generic stdout on logs piping it with log-roation.js:
$ node whatever.js | ./log-rotation.js
roccomuso / index.html
Last active Nov 5, 2015
Modular Javascript - How to create javascript modules and use event handling. Inspired by:
View index.html
<title>Modules in JS</title>
<script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>
roccomuso / oop in javascript.js
Last active Apr 5, 2017
Prototypal Pattern vs Classical OOP in JS.js
View oop in javascript.js
var human = {
species: "human",
create: function(values) {
var instance = Object.create(this);
Object.keys(values).forEach(function(key) {
instance[key] = values[key];
return instance;
saySpecies: function() {
You can’t perform that action at this time.