Instantly share code, notes, and snippets.

View spawnP.js
const { spawn } = require('child_process');
const spawnP = async command => {
return new Promise((res, rej) => {
const cmdParts = command.split(' ');
const cmdSpawm = spawn(
cmdParts[0],
cmdParts.length > 1 ? cmdParts.slice(1) : [],
{
stdio: 'inherit'
View pick.js
const typeOf = _ => Object.prototype.toString.call(_);
// Result can be used with db.collection.find : PARTIALLY
const arrayToSchema = keys =>
keys.reduce((schema, _) => {
if (_.indexOf('.') > -1) {
const [key, rest] = _.split('.');
schema[key] = {
...schema[key],
...arrayToSchema([rest]),
View package.json
{
"name": "...",
"version": "1.0.0",
"description": "...",
"main": "index.js",
"scripts": {
"build": "...",
"test": "...",
"deploy": "..."
},
View filterAndGroup.js
function filterAndGroup(data, filterFunc, groupByKey) {
return data.reduce((acc, item) => {
if (filterFunc(item)) {
if (item[groupByKey] in acc) {
acc[item[groupByKey]].push(item);
} else {
acc[item[groupByKey]] = [item];
}
}
View JS: Async load js file
var s = document.createElement('script');
s.type = 'text/javascript';
s.async = true;
s.src = 'http://yourdomain.com/script.js';
var x = document.getElementsByTagName('script')[0];
x.parentNode.insertBefore(s, x);
View sm-annotated.html
<script type="text/javascript">
(function () {
"use strict";
// once cached, the css file is stored on the client forever unless
// the URL below is changed. Any change will invalidate the cache
var css_href = './index_files/web-fonts.css';
// a simple event handler wrapper
function on(el, ev, callback) {
if (el.addEventListener) {
el.addEventListener(ev, callback, false);
View gist:5003922
@-webkit-keyframes {name} {
0% { {from} }
100% { {to} }
}
@-moz-keyframes {name} {
0% { {from} }
100% { {to} }
}
@-o-keyframes {name} {
0% { {from} }
View gist:4707701
<!doctype html>
<html class="no-js" lang="fr">
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/png" href="http://alexgalinier.com/static/images/alexgalinier-site-favicon_32x32.png" /> <!-- 32x32 image-->
<!-- Safari standalone web app config -->