Skip to content

Instantly share code, notes, and snippets.

View magnetikonline's full-sized avatar
💡
I have an idea!

Peter Mescalchin magnetikonline

💡
I have an idea!
View GitHub Profile
@magnetikonline
magnetikonline / README.md
Created March 3, 2024 05:39
macOS execute command upon directory change via launchd.

macOS execute command upon directory change via launchd

Using launchd to watch a filesystem directory and upon create/change to a file with the directory, execute a command.

Install

For this example:

  • Watching directory of: /path/to/watch.
  • Upon file change, execute: /path/to/command argument1 argument2.
@magnetikonline
magnetikonline / README.md
Last active July 11, 2025 02:21
Docker volume backup and restore scripts.

Docker volume backup and restore scripts

Backup a Docker volume to tar archive:

$ ./docker-volume-backup.sh \
  DOCKER_VOLUME_NAME \
  ARCHIVE_NAME.tgz
@magnetikonline
magnetikonline / README.md
Last active February 12, 2024 02:12
Node.js strict mode enabled?

Node.js strict mode enabled?

A quick test, this relies on the fact that this will not exist and point to the global scope when running in strict mode.

console.log('strict:',(function() { return (this === undefined); })());

Tip

Strict mode is enabled by default within ES module enabled packages.

@magnetikonline
magnetikonline / README.md
Last active September 24, 2024 04:37
Import all GPG keys for GitHub organisation users.

Import all GPG keys for GitHub organisation users

Fetches a GitHub organisation member list and proceeds to gpg --import public GPG key(s) for each member associated against their profile.

Requires:

  • curl for GitHub API calls
  • jq for parsing GitHub REST API responses
  • and (obviously) gpg
@magnetikonline
magnetikonline / .editorconfig
Created October 25, 2022 22:25
My .editorconfig template.
root = true
[*]
charset = utf-8
end_of_line = lf
indent_size = 2
indent_style = tab
insert_final_newline = true
trim_trailing_whitespace = true
@magnetikonline
magnetikonline / .eslintrc.json
Last active May 7, 2024 14:46
My ESLint configuration template.
{
"root": true,
"parserOptions": {
"sourceType": "module"
},
"env": {
"es2020": true,
"node": true
},
"extends": [
@magnetikonline
magnetikonline / README.md
Last active January 22, 2025 19:54
Python - hashing JSON data structures.

Python - hashing JSON data structures

A function hash_json(data), accepting a structure loaded from json.load() and computing a hash.

Example

$ ./hashjson.py
Hash a.json: 8212462b8e9ce805cac2f0758127c5cfd7710baf
Hash b.json: 8212462b8e9ce805cac2f0758127c5cfd7710baf
@magnetikonline
magnetikonline / README.md
Last active May 3, 2024 12:20
Install jq on macOS from source.

Install jq on macOS from source

Note: as of jq v1.7 the project offers pre-built native macOS releases for ARM64 based architechtures.

A quick n' dirty Bash script to install the following:

  • autoconf.
  • automake.
  • libtool
  • jq - from source.
@magnetikonline
magnetikonline / README.md
Last active April 20, 2024 04:18
npm wrapper script to ensure `npm publish` from a clean Git repository.

npm wrapper to ensure npm publish from clean Git repository

Tip

By default npm publish will publish all files within a working directory - excluding .gitignore / .npmignore / package-lock.json.

This is typically fine, but often I find myself leaving un-staged files (e.g. TODO.txt files) in a repository root and these of course get accidently taken along for the publish ride.

Helper script npm-publish-wrap.sh will catch calls to npm publish and:

  • Ensure I'm at the root of a repository (.git directory) found.
@magnetikonline
magnetikonline / README.md
Last active January 29, 2024 23:38
Datadog list all installed integrations.

Datadog list all installed integrations

From what I can see, there is no simple way to extract a list of installed Datadog integrations for documentation/etc. purposes.

Here is a lo-fi method of pulling it from the web UI DOM:

  • Visit the Integrations page for your Datadog account.
  • Open browser web developer tools.
  • Execute the following from the JavaScript console: