Skip to content

Instantly share code, notes, and snippets.

Avatar
💡
I have an idea!

Peter Mescalchin magnetikonline

💡
I have an idea!
View GitHub Profile
@magnetikonline
magnetikonline / README.md
Created May 26, 2023 01:07
Node.js strict mode enabled?
View README.md

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); })());

Strict mode is enabled by default within Node.js ES module enabled packages:

@magnetikonline
magnetikonline / README.md
Last active March 22, 2023 05:05
Import all GPG keys for GitHub organisation users.
View README.md

Import all GPG keys for GitHub organisation users

Script to fetch a GitHub organisation member list and gpg --import the public GPG key(s) for each member with GPG key(s) associated against their profile.

Requires curl for GitHub API calls, jq for parsing GitHub REST API responses and (obviously) gpg.

Usage

Create a GitHub personal access token (classic or fine-grained) with read access to organisation members:

@magnetikonline
magnetikonline / .editorconfig
Created October 25, 2022 22:25
My .editorconfig template.
View .editorconfig
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 22, 2023 08:24
My ESLint configuration template.
View .eslintrc.json
{
"root": true,
"parserOptions": {
"sourceType": "module"
},
"env": {
"es2020": true,
"node": true
},
"extends": [
@magnetikonline
magnetikonline / README.md
Last active August 16, 2022 02:16
Python - hashing JSON data structures.
View README.md
@magnetikonline
magnetikonline / README.md
Last active August 3, 2023 06:06
Install jq on macOS from source.
View README.md

Install jq on macOS from source

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

  • autoconf.
  • automake.
  • libtool
  • jq - from source.

The aim/need was to create an M1 (ARM64) compile of jq - which isn't available (currently) via releases and avoid using Homebrew.

@magnetikonline
magnetikonline / README.md
Last active July 20, 2023 00:05
npm wrapper script to ensure `npm publish` from a clean Git repository commit.
View README.md

npm wrapper to ensure npm publish from clean Git commit

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.

The 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.
  • Local git clone the current repository to a temp directory - removing any unstaged files.
@magnetikonline
magnetikonline / README.md
Last active September 21, 2023 01:22
Datadog list all installed intergrations.
View README.md

Datadog list all installed intergrations

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.
View README.md

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
Created July 13, 2021 01:53
Python threaded workers using ThreadPoolExecutor().
View README.md