Skip to content

Instantly share code, notes, and snippets.

View matjahs's full-sized avatar

Matjah Sonneveld matjahs

View GitHub Profile
@barthap
barthap / __mocks__--fs--promises.js
Last active February 25, 2023 23:20
Mocking filesystem in Node.js with `memfs`
// __mocks__/fs/promises.js
const { fs } = require("memfs");
module.exports = fs.promises;
@rtfpessoa
rtfpessoa / nextdns.js
Last active January 10, 2025 04:16
nextdns.io Block Youtube Ads
// ID of the config, e.g. A1234BCD.
const configID = "A1234BCD";
// API key, found at the bottom of your account page in https://my.nextdns.io/account
const APIKey = "xxxxxxxxxxxxxxxxxxxxxxxxxx";
// Mark true or false. If true, failed links will be retried 3 times at progressively increasing intervals.
// If false, failed links will not be retried.
const retryFailedLinks = true;
// Time delay between requests in milliseconds.
// 800 seems to not give any errors but is rather slow while anything faster will give errors (in limited testing).
// If you want to go lower, it is recommended that "retryFailedLinks" is true
@m-radzikowski
m-radzikowski / script-template.sh
Last active April 21, 2025 17:51
Minimal safe Bash script template - see the article with full description: https://betterdev.blog/minimal-safe-bash-script-template/
#!/usr/bin/env bash
set -Eeuo pipefail
trap cleanup SIGINT SIGTERM ERR EXIT
script_dir=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd -P)
usage() {
cat <<EOF
Usage: $(basename "${BASH_SOURCE[0]}") [-h] [-v] [-f] -p param_value arg1 [arg2...]