Skip to content

Instantly share code, notes, and snippets.

View ishan-marikar's full-sized avatar

Ishan Marikar ishan-marikar

View GitHub Profile
@ishan-marikar
ishan-marikar / email.mjml
Created April 21, 2017 09:23 — forked from anonymous/email.mjml
Made with MJML App
<mjml>
<mj-body>
<mj-container background-color="#d6dde5">
<mj-section
locked="true"
padding-bottom="20"
padding-top="20">
<mj-column
width="66.66666666666666%"
@ishan-marikar
ishan-marikar / stateful.js
Created April 23, 2017 14:11 — forked from foca/stateful.js
Stateful is a simple implementation of the State Pattern for JavaScript.
// Stateful is a simple implementation of the state pattern for javascript.
//
// Read more on this design pattern here:
// -> http://sourcemaking.com/design_patterns/state
//
// Initialize Stateful by passing it an object, the name of the initial state
// (defaults to "default"), and an optional hash of interfaces that will be
// applied for each state. If these interfaces are not passed, they default to
// the object's constructor's States property. So, for example:
//
@ishan-marikar
ishan-marikar / gist:1b9a3c7ef905fe55df9a076a1bafb92c
Last active August 31, 2017 12:08 — forked from jrgcubano/gist:56e3204ecc661b09c16a
Facial recognition and training with node js
// Starkflow comments + github project node js
// + https://github.com/jrgcubano/face-detection-node-opencv
// + http://blog.stevenedouard.com/stroll-node-facial-recognition-3rd-party-apis
/*I believe that you're using the node-opencv library ? You will need some more steps. You have to train your opencv system which than allows you to use the method "predictSync" from FaceRecongizer().
The node-opencv library has a FaceRecognizer Object which you first initialize.
Initialize FaceRecognizer: var FaceRecognizer = new cv.FaceRecognizer();
You have to read all the images, create a specific array and train your FaceRecognizer with that. For my purpose, I'm saving each user in a DB and they get a unique ID which I'm using to create a specific subfolder and this is later used. Here is my code:
@ishan-marikar
ishan-marikar / shipitfile.js
Created September 13, 2017 07:36 — forked from thelinuxlich/shipitfile.js
Shipitfile example
var project_name = "YOUR_PROJECT_NAME",
project_url = 'YOUR_GIT_URL',
project_destination_server = 'USER@SERVER',
project_destination_dir = '/PROJECT_DIRECTORY',
webhookUri = "SLACK_TOKEN_URI",
Slack = require('slack-node'),
slack = new Slack(),
notify = function(text) {
slack.webhook({
channel: "#notifications",

Shipit Deploy

Shipit is a pretty awesome universal automation and deployment tool written in JavaScript.

Setup your server

(this would ideally be done with automated provisioning)

  • add a deploy user with password-less ssh see this gist
  • install forever npm install -g pm2

Install shipit

  • npm install -g shipit-cli
@ishan-marikar
ishan-marikar / crypto-stream.js
Created November 1, 2017 11:17 — forked from chris-rock/crypto-stream.js
Encrypt and decrypt streams
// Part of https://github.com/chris-rock/node-crypto-examples
// Nodejs encryption of buffers
var crypto = require('crypto'),
algorithm = 'aes-256-ctr',
password = 'd6F3Efeq';
var fs = require('fs');
var zlib = require('zlib');
@ishan-marikar
ishan-marikar / random.js
Created January 4, 2018 20:15 — forked from kerimdzhanov/random.js
JavaScript: get a random number from a specific range
/**
* Get a random floating point number between `min` and `max`.
*
* @param {number} min - min number
* @param {number} max - max number
* @return {number} a random floating point number
*/
function getRandomFloat(min, max) {
return Math.random() * (max - min) + min;
}

Minimum Viable Async with Node 6

With the release of Node 6.0.0, the surface of code that needs transpilation to use ES6 features has been reduced very dramatically.

This is what my current workflow looks like to set up a minimalistic and fast microservice using micro and async + await.

The promise

@ishan-marikar
ishan-marikar / deezer-mp3-download.js
Created January 14, 2018 06:12
Download - stream a deezer song / playlist / album in 320kbps, for educational purposes only ;). Strongly inspired by https://github.com/jaimehrubiks/deezer-download
const Promise = require("bluebird");
const request = require("request-promise");
const ID3Writer = require('browser-id3-writer');
const crypto = require('crypto');
const format = require('util').format;
const fs = require("fs");
const http = require('http');
// Download a deezer song / playlist / album
@ishan-marikar
ishan-marikar / introrx.md
Created January 19, 2018 07:12 — forked from lolocoo/introrx.md
The introduction to Reactive Programming you've been missing