Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Freelance.

François-Marie de Jouvencel djfm

💭
Freelance.
View GitHub Profile
@djfm
djfm / NodeJS-TS-Setup-May2021.md
Last active May 8, 2021
NodeJS + TS + Linting - My current preferred quick & safe setup method as of May 2021
View NodeJS-TS-Setup-May2021.md

Intro

This document aims to describe how to get a quick setup of a cool web dev stack without using black-magick templates and reasolably understanding what you're doing.

It's, and will remain forever, a work in progress.

Create GitHub repo first

@djfm
djfm / README.md
Last active May 16, 2021
Search all the man-pages in one command.
View README.md

whichMan, a CLI tool that lets you find the right manpage

Usage

whichMan.sh "some string that may appear in some package's manpage"

Why ?

@djfm
djfm / cloudSettings
Last active Apr 28, 2021
Visual Studio Code Settings Sync Gist
View cloudSettings
{"lastUpload":"2021-04-28T11:12:04.357Z","extensionVersion":"v3.4.3"}
View flattenNodes.js
// Flatten an array of nodes, returning all nodes
// of the tree without their children.
const flattenNodeTree = (node) => {
const { children, ...otherProps } = node;
if (!children) {
return [{ ...otherProps }];
}
return [{ ...otherProps }, ...[].concat(...children.map(flattenNodeTree))];
@djfm
djfm / humanDuration.js
Last active Apr 22, 2021
Translate a number of seconds to a human-readable duration, e.g. 700000 is converted to "1 week, 1 day, 2 hours, 26 minutes and 40 seconds"
View humanDuration.js
const pluralize = (n, [singular, plural]) => (n === 1 ? `${n} ${singular}` : `${n} ${plural}`);
const translateBiggestUnit = (
n,
[divisor, ...divisors],
[unit, ...units],
candidateDivisor,
divisorsUsed,
unitsUsed,
) => {
View song.js
const scale = {
c: 0,
'c#': 1,
d: 2,
'd#': 3,
e: 4,
f: 5,
'f#': 6,
g: 7,
'g#': 8,
View song.js
const scale = {
c: 0,
'c#': 1,
d: 2,
'd#': 3,
e: 4,
f: 5,
'f#': 6,
g: 7,
'g#': 8,
View couchbase-easier-api.js
const {
Cluster,
N1qlQuery,
MutationState,
} = require('couchbase');
const URL = require('url');
const addQueryParams = params => url => {
const parsed = URL.parse(url);
View chain-do-maybe.js
const just = x => Promise.resolve(x);
const nothing = () => Promise.reject();
chain(
() => just(1),
() => nothing(),
(_, x, y) => just(x / y)
)()
.should.be.rejected;
View chain-do.js
const chainStep = fn => (argSource, history) => {
if (argSource && (typeof argSource === 'object')) {
const then = argSource.then;
if (typeof then === 'function') {
return Promise.all(history).then(
settledHistory =>
then.call(argSource, arg => fn(arg, ...settledHistory))
);
}
}