Skip to content

Instantly share code, notes, and snippets.

View ishan-marikar's full-sized avatar

Ishan Marikar ishan-marikar

View GitHub Profile

I have a question, and it's something I've been trying to learn for a while (and if I can't find something like it, I guess I'll have to build it).

I'm looking for something where I can have a template with a standardized format that would look a little something like this:

let x = new Extracter("Account: {{accountNumber}}, Location: {{location}}, Date: {{date}}, Amount: {{amount}}");

... where we could pass in strings that would fit that format and we could extract the data out of the strings:

@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');

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 / 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",
{
"watch": [
"src"
],
"ext": "ts",
"ignore": [
"src/**/*.spec.ts"
],
"exec": "ts-node ./src/server.ts"
}
FROM node:alpine
# http://jdlm.info/articles/2016/03/06/lessons-building-node-app-docker.html
RUN useradd --user-group --create-home --shell /bin/false deploy
ENV HOME=/home/deploy
USER deploy
RUN npm install pm2 -g
RUN npm install yarn -g
@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 / 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 / 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 / Event-stream based GraphQL subscriptions.md
Created April 12, 2017 11:54 — forked from OlegIlyenko/Event-stream based GraphQL subscriptions.md
Event-stream based GraphQL subscriptions for real-time updates

In this gist I would like to describe an idea for GraphQL subscriptions. It was inspired by conversations about subscriptions in the GraphQL slack channel and different GH issues, like #89 and #411.

Conceptual Model

At the moment GraphQL allows 2 types of queries:

  • query
  • mutation

Reference implementation also adds the third type: subscription. It does not have any semantics yet, so here I would like to propose one possible semantics interpretation and the reasoning behind it.