Skip to content

Instantly share code, notes, and snippets.

View lpenaud's full-sized avatar
💻
Working

Loïc Penaud lpenaud

💻
Working
View GitHub Profile
@lpenaud
lpenaud / AllOfFutureHelpers.md
Last active December 4, 2024 14:18
AllOfFuturesHelpers

All of futures

Create futures from list and function.

Usage

final var list = List.of('A', 'B', 'C');
AllOfFutureHelpers.<> builder()
 .function(e -&gt; someIOFunction(e))
@lpenaud
lpenaud / ArrayMatcherAnswer.java
Created November 14, 2024 13:42
Multi-Answer Mockito
import java.util.LinkedList;
import java.util.List;
import org.mockito.ArgumentMatcher;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
import lombok.AllArgsConstructor;
import lombok.Setter;
@lpenaud
lpenaud / HashMap.md
Created October 15, 2024 13:52
HashMap number mapping

From number of mapping

Java 19 add newHashMap(int) to HashMap and LinkedHashMap.

See: Java doc HashMap

Calculate capacity from load factory

private static final short DEFAULT_LOAD_FACTOR = .75;
@lpenaud
lpenaud / Split-cue.md
Created October 8, 2024 19:18
Split cue file

Split cue file to flac tracks

Dependencies

  • flac
  • shnsplit
  • file

Optional dependencies

@lpenaud
lpenaud / rsync-english.md
Last active February 25, 2025 09:00
Backup files

Backup files with rsync

Incremental backup

rsync -a --delete -Pau INDIR [INDIRS...] OUTDIR
  • -a: Archive mode copy the access rights.
  • --delete: Remove files if there aren't in the source directory anymore.
@lpenaud
lpenaud / header.html
Last active January 18, 2025 05:00 — forked from killercup/pandoc.css
Add style to pandoc HTML render.
<script type="module">
import mermaid from 'https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.esm.min.mjs';
mermaid.initialize({ startOnLoad: false });
await mermaid.run({
nodes: document.querySelectorAll('pre.mermaid > code:first-child'),
});
function findMermaidSvg(child) {
if (child.tagName === "A" || child.tagName === "BUTTON") {
return null;
@lpenaud
lpenaud / bash-random.md
Last active August 21, 2024 16:23
Bash random

Bash random

Functions utils to play with random number.

Examples

Get randomly a number between 0 to 10 or 5.

if rand::boolean; then
@lpenaud
lpenaud / slideshow.md
Last active February 4, 2025 10:02
Gnome slideshow

Gnome slideshow

Generate a slideshow to GNOME desktop background.

Usage

slideshow.sh INDIR > "slideshow.$(date -I).xml"
@lpenaud
lpenaud / walk-series.ts
Last active January 28, 2025 22:19
Create physical link between download and media directory
#!/usr/bin/env -S deno run --allow-read --allow-write
import { walk } from "https://deno.land/[email protected]/fs/walk.ts";
import * as cli from "https://deno.land/[email protected]/cli/mod.ts";
import * as path from "https://deno.land/[email protected]/path/mod.ts";
interface UnixFilesystemOptions {
uid: number | null;
gid: number | null;
filemod: number;
dirmod: number;
@lpenaud
lpenaud / lnr.ts
Last active March 4, 2025 19:38
Create physical link recursively
#!/usr/bin/env -S deno run --allow-read --allow-write
import {
walk,
type WalkEntry,
type WalkOptions,
} from "https://deno.land/[email protected]/fs/walk.ts";
import * as path from "https://deno.land/[email protected]/path/mod.ts";
async function* multiWalk(roots: string[], options?: WalkOptions) {
for (const root of roots) {