Skip to content

Instantly share code, notes, and snippets.

Avatar

Matthieu Lemoine MatthieuLemoine

View GitHub Profile
@MatthieuLemoine
MatthieuLemoine / install-deps.js
Created May 19, 2018
Install dependencies for all projects in current dir
View install-deps.js
const fs = require('fs');
const path = require('path');
const { promisify } = require('util');
const { exec: childExec } = require('child_process');
const ProgressBar = require('ascii-progress');
const readDir = promisify(fs.readdir);
const exec = promisify(childExec);
const workingDir = process.cwd();
@MatthieuLemoine
MatthieuLemoine / index.js
Last active May 10, 2018
Parse RATP stops data & dump in an Algolia index
View index.js
const { promises: fs, createReadStream } = require('fs');
const { Transform } = require('stream');
const path = require('path');
const uuid = require('uuid/v4');
const ProgressBar = require('ascii-progress');
const algolia = require('algoliasearch');
const { ALGOLIA_APP_ID, ALGOLIA_API_KEY } = process.env;
const client = algolia(ALGOLIA_APP_ID, ALGOLIA_API_KEY);
@MatthieuLemoine
MatthieuLemoine / find-repo-dependencies.js
Created Dec 27, 2017
Find repository dependencies in all your projects
View find-repo-dependencies.js
// Usage : node find-repo-dependencies /path/to/projects/folder
const path = require('path');
const fs = require('fs');
const folder = path.resolve(process.argv[2]);
fs
.readdirSync(folder)
// Absolute path
.map(item => path.join(folder, item))
@MatthieuLemoine
MatthieuLemoine / refactor.js
Last active Aug 9, 2017
Refactor from dirname/filename(.test).js to dirname/filename/index(.test).js
View refactor.js
/*
node refactor.js --dirs src/actions src/components
Before :
- src
- actions
messenger.js
messenger.test.js
login.js
@MatthieuLemoine
MatthieuLemoine / index.js
Last active Apr 10, 2017
Mediasoup : Link audio/video streams with participants
View index.js
// You need to setup a working mediasoup SFU server first
// see : https://mediasoup.org/api/#webrtc
// Map userId => streamId
// Local to a room
const userStreams = {};
// Mediasoup peer
const mediaPeer = mediaRoom.Peer(participant.id);
@MatthieuLemoine
MatthieuLemoine / postbuild.js
Last active Feb 6, 2017
Post babel build. Copy missing files.
View postbuild.js
#!/usr/bin/env node
const glob = require('glob');
const fs = require('fs');
const sh = require('shelljs');
const SRC_DIR = 'src';
const DEST_DIR = 'build';
glob(`${SRC_DIR}/**/*(*.json|!(*.js))`, (err, files) => {
if (err) {
@MatthieuLemoine
MatthieuLemoine / crypto.js
Created Jan 23, 2017
Node crypto sign & verify
View crypto.js
const id = '__JUNK__';
// Public key need to be in PKCS8 format
// ssh-keygen -e -m PKCS8 -f id_rsa.pub > id_rsa.pkcs8
const publicKey = fs.readFileSync(path.join(__dirname, 'id_rsa.pkcs8'), { encoding : 'utf8' });
const privateKey = fs.readFileSync(path.join(__dirname, 'id_rsa'), { encoding : 'utf8' });
// Sign
const signer = crypto.createSign('RSA-SHA512');
signer.update(id);
const signature = signer.sign(privateKey, 'hex');
@MatthieuLemoine
MatthieuLemoine / .hyper.js
Last active Feb 20, 2017
Hyperterm sync settings
View .hyper.js
module.exports = {
config: {
// default font size in pixels for all tabs
fontSize: 12,
// font family with optional fallbacks
fontFamily: 'Menlo, "DejaVu Sans Mono", "Lucida Console", monospace',
// terminal cursor background color and opacity (hex, rgb, hsl, hsv, hwb or cmyk)
cursorColor: '#fff',