Skip to content

Instantly share code, notes, and snippets.

View djfm's full-sized 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
@djfm
djfm / saturate-disk.sh
Created November 23, 2023 20:07
Try to saturate a hard-disk to check its capacity using standard Linux commands
#!/bin/env bash
target="$1"
if ! [ -d "$target" ]; then
echo "Usage: $0 <directory>"
exit 1
fi
#supposed capacity of the disk in GB
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('');
#include "exampleScenes.h"
HelloWorldScene::HelloWorldScene():
Scene(
Screen(1000, 800),
Camera(-800, 100, 100, 80)
)
{
add(
new RectangleShape(
@djfm
djfm / adb-autoconnect
Created July 27, 2021 13:52
a very simple bash script that helps connect an Android phone to adb when the USB connection is flaky
#!/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 17:11
NodeJS + TS + Linting - My current preferred quick & safe setup method as of May 2021

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 14:37
Search all the man-pages in one command.

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 April 28, 2021 11:13
Visual Studio Code Settings Sync Gist
{"lastUpload":"2021-04-28T11:12:04.357Z","extensionVersion":"v3.4.3"}
// 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 April 22, 2021 20:14
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"
const pluralize = (n, [singular, plural]) => (n === 1 ? `${n} ${singular}` : `${n} ${plural}`);
const translateBiggestUnit = (
n,
[divisor, ...divisors],
[unit, ...units],
candidateDivisor,
divisorsUsed,
unitsUsed,
) => {
const scale = {
c: 0,
'c#': 1,
d: 2,
'd#': 3,
e: 4,
f: 5,
'f#': 6,
g: 7,
'g#': 8,