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 / .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:
@magnetikonline
magnetikonline / README.md
Last active August 18, 2021 12:32
Rudimentary JavaScript object deep copy.

Rudimentary JavaScript object deep copy

Function to perform a deep copy of an object - rudimentary in that it will only handle the following types:

  • Primitives
  • Array
  • Object

Basically can perform the following, but also copy undefined:

@magnetikonline
magnetikonline / README.md
Last active March 18, 2024 01:27
Python threaded workers using ThreadPoolExecutor().

Python threaded workers using ThreadPoolExecutor()

A pattern for using concurrent.futures.ThreadPoolExecutor() to execute a series of "worker" functions in parallel, processing a queue of assigned "work".

How it works:

  • worker_init() creates:
    • Queues for "work" and "results".
    • A threading.Event() to denote "no more work in queue".
    • A futures.ThreadPoolExecutor().
@magnetikonline
magnetikonline / README.md
Last active July 23, 2024 00:23
Cleanup legacy GitHub Actions workflow runs.

Cleanup legacy GitHub Actions workflow runs

Python utility to bulk delete GitHub Actions runs for a given workflow, either current or legacy/since removed. The GitHub web UI currently allows removal of individual workflow runs - but this becomes tedious quickly when performed in bulk.

Usage

Create a new Personal access token allowing the workflow scope:

image

@magnetikonline
magnetikonline / README.md
Last active December 10, 2023 10:53
Quick example for using the GitHub Container (Docker) registry.

Quick example for using the GitHub Container registry

Human user access

Create a new Personal access token with the following permissions:

delete:packages
read:packages
write:packages
@magnetikonline
magnetikonline / README.md
Last active March 12, 2025 13:52
Enable GitHub Dependabot for Golang based repositories.