Skip to content

Instantly share code, notes, and snippets.

View MatthieuLemoine's full-sized avatar

Matthieu Lemoine MatthieuLemoine

View GitHub Profile
@MatthieuLemoine
MatthieuLemoine / index.js
Last active April 10, 2017 15:57
Mediasoup : Link audio/video streams with participants
// 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 / ssh_config
Last active May 2, 2017 15:26
SSH config proxy host
# ~/.ssh/config
Host <custom-name>
HostName <remote-host>
User <remote-user>
Port <remote-ssh-port>
IdentityFile ~/.ssh/id_rsa
ForwardAgent yes
ProxyCommand ssh -o 'ForwardAgent yes' <proxy-user>@<proxy-host> 'ssh-add && nc %h %p'
npm init --scope=<orgName>
npm publish --access public
@MatthieuLemoine
MatthieuLemoine / refactor.js
Last active August 9, 2017 08:53
Refactor from dirname/filename(.test).js to dirname/filename/index(.test).js
/*
node refactor.js --dirs src/actions src/components
Before :
- src
- actions
messenger.js
messenger.test.js
login.js
@MatthieuLemoine
MatthieuLemoine / find-repo-dependencies.js
Created December 27, 2017 13:25
Find repository dependencies in all your projects
// 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 / junk.js
Created January 10, 2018 15:52
Sync settings
//
@MatthieuLemoine
MatthieuLemoine / index.js
Last active May 10, 2018 22:03
Parse RATP stops data & dump in an Algolia index
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 / install-deps.js
Created May 19, 2018 12:22
Install dependencies for all projects in current dir
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();
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->
@MatthieuLemoine
MatthieuLemoine / crypto.js
Created January 23, 2017 14:36
Node crypto sign & verify
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');