Skip to content

Instantly share code, notes, and snippets.

View roccomuso's full-sized avatar

Rocco Musolino roccomuso

View GitHub Profile
@roccomuso
roccomuso / aws-kinesis-stream.js
Created February 11, 2021 10:26
Aws Kinesis stream upload example in JS - get rtsp stream with ffmpeg and use putMedia to upload it on Amazon Kinesis
const ffmpeg = require('fluent-ffmpeg')
const parseUrl = require('url').parse
// Polyfill, modifying the global Object
require('es6-object-assign').polyfill()
global.Promise = require('es6-promise').Promise
const aws4 = require('aws4')
const axios = require('axios')
const CancelToken = axios.CancelToken
const fs = require('fs')
const PipeViewer = require('pv')

Keybase proof

I hereby claim:

  • I am roccomuso on github.
  • I am roccomuso (https://keybase.io/roccomuso) on keybase.
  • I have a public key ASDYVzLuaGmRCGjHViw8SM3gNsZmntfh7GDM8VYJ71lVawo

To claim this, I am signing this object:

@roccomuso
roccomuso / streamloop.js
Created September 3, 2018 10:55
Stream a buffer in loop.
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
this.data = data
this.length = data.byteLength
this.offset = 0
@roccomuso
roccomuso / update_repos.sh
Last active October 29, 2018 23:51
Update all git repository under a given directory, maxdepth 1.
#!/bin/bash
# store the current dir
CUR_DIR=$(pwd)
# 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
roccomuso / Interactive-SSH-Client.js
Created April 20, 2017 13:56
SSH Interactive shell session in Node.js
var Client = require('ssh2').Client;
var readline = require('readline')
var conn = new Client();
conn.on('ready', function() {
console.log('Client :: ready');
conn.shell(function(err, stream) {
if (err) throw err;
// create readline interface
var rl = readline.createInterface(process.stdin, process.stdout)
@roccomuso
roccomuso / index.html
Last active April 10, 2018 18:44
p2p-graph esnextbin sketch
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ESNextbin Sketch</title>
<!-- put additional styles and scripts here -->
<style>
body{
background-color: #7f7a7a;
};
@roccomuso
roccomuso / Client.js
Last active February 19, 2023 21:19
Node.js remote shell example
var net = require('net')
var readline = require('readline')
/**
* @class Client
* @param host {String} the host
* @param post {Integer} the port
*/
function Client (host, port) {
this.host = host
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
roccomuso / log-rotation.js
Last active October 29, 2018 23:53
stream and save stdout on log files. This snippet also manage automatic deletion for files older than X days.
#!/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
roccomuso / index.html
Last active November 5, 2015 16:54
Modular Javascript - How to create javascript modules and use event handling. Inspired by: https://www.youtube.com/playlist?list=PLoYCgNOIyGABs-wDaaxChu82q_xQgUb4f
<html>
<head>
<title>Modules in JS</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mustache.js/2.1.3/mustache.min.js"></script>