Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
Freelance. Won't set foot in office again.

François-Marie de Jouvencel djfm

💭
Freelance. Won't set foot in office again.
View GitHub Profile
View findAmbiPalindromeDates.js
const digits = [0, 1, 2, 5, 8]
const isAmbiNumber = (number) => {
// return true if all digits of number are in digits array
const digitsOfNumber = number.toString().split('');
return digitsOfNumber.every(digit => digits.includes(parseInt(digit)));
}
const isPalindrome = (string) => {
const reversed = string.split('').reverse().join('');
View exampleScene.cpp
#include "exampleScenes.h"
HelloWorldScene::HelloWorldScene():
Scene(
Screen(1000, 800),
Camera(-800, 100, 100, 80)
)
{
add(
new RectangleShape(
@djfm
djfm / adb-autoconnect
Created Jul 27, 2021
a very simple bash script that helps connect an Android phone to adb when the USB connection is flaky
View adb-autoconnect
#!/usr/bin/env bash
nDevices="0"
nTries="0"
echo "Looking for connected Android devices..."
echo ""
while [ $nDevices -lt 1 ]
do
@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,