Skip to content

Instantly share code, notes, and snippets.

View Integralist's full-sized avatar
🎯
Making an impact

Mark McDonnell Integralist

🎯
Making an impact
View GitHub Profile
@Integralist
Integralist / async.sh
Created June 5, 2023 12:29
[find files asynchronously] #xargs #async #find
#!/bin/bash
replacement_patterns() {
echo "Processing file: $1"
}
replacement_patterns "$@"
@Integralist
Integralist / 0. README.md
Last active October 5, 2023 08:34
[Golang stream new-line delimited JSON to Server] #go #golang #api #stream #json #ndjson

The application/x-ndjson MIME type refers to a type of data format called Newline delimited JSON (NDJSON). NDJSON is a way of storing structured data as a sequence of JSON (JavaScript Object Notation) objects, separated by newline characters.

Each line of an NDJSON file contains a complete JSON object, which means that a single NDJSON file can contain multiple JSON objects. This format is commonly used for streaming large datasets, as it allows data to be processed in a continuous and efficient manner.

The application/x-ndjson MIME type is used to indicate that a file or data stream contains NDJSON formatted data. The x in the MIME type indicates that it is an unregistered type, which means that it is not an official MIME type defined by the Internet Assigned Numbers Authority (IANA). However, it is widely used and supported by many applications and APIs that deal with structured data.

Here's an example of how you could use Go to send an NDJSON-formatted payload to an API:

package main
@Integralist
Integralist / 1.Makefile
Last active February 13, 2024 09:28
[Makefile help output] #make #makefile #help #docs
# IMPORTANT: The help target requires variables to have whitespace stripped.
# But only for variables whose line ends with comment docs (e.g. ## ...)
# To strip whitespace use `$(strip $(VARIABLE_NAME))`
# Alternative was worse, i.e. remove space between value and doc comment.
# Then updating the last line of the help target to account for closed space.
# returns any tag associated with the given HEAD commit.
tag_check: ## A
@if [[ ! $$(git tag --points-at $$(git rev-parse --short HEAD)) ]]; then echo "no git tag found on HEAD commit"; exit 1; fi
@Integralist
Integralist / API Versioning Strategies.md
Created April 25, 2023 13:20
[API Versioning Strategies] #api #versioning

Terraform Analysis

Terraform uses SDKs for interacting with provider APIs. There isn’t a distinction to be made for Terraform. You just bump the SDK version and it’s down to the individual provider APIs ‘under the covers’ to handle versioning. So in that case I looked at the top providers listed on https://registry.terraform.io/browse/providers which are AWS, Azure and Google Cloud Platform.

AWS

AWS versions its APIs using a versioning system based on the format “YYYY-MM-DD”. The YYYY-MM-DD format is based on the date of the API release. Each API has its own version number, which is incremented with each new release.

For example, an API released on January 1st, 2020, would have a version number of “2020-01-01”.

@Integralist
Integralist / OpenSSL Generate Certificate for Code Signing.md
Last active January 4, 2024 07:22
[OpenSSL Generate Certificate for Code Signing] #openssl #cert #codesign #AI

NOTE: The explanation of the code was auto-generated by AI (so some of the explanations could be incorrect).

openssl genrsa -des3 -out rootCA.key 4096

This code generates a new RSA private key with a length of 4096 bits and encrypts it using the Triple DES algorithm with a passphrase. The private key is saved in a file named rootCA.key. This command is commonly used to generate a root certificate authority (CA) key, which is used to sign and issue digital certificates for other entities.

openssl req -x509 -new -nodes -key rootCA.key -sha256 -days 1024 -out rootCA.crt
@Integralist
Integralist / changelog.bash
Last active March 30, 2023 12:49
[Generate change log between two tags] #changelog #git
#!/bin/bash
tags=$(git for-each-ref --sort=-creatordate --format '%(refname) %(creatordate)' refs/tags | grep -Eo 'client/rust@v?[^ ]+')
latest_tag=$(echo "$tags" | head -n 1)
second_tag=$(echo "$tags" | head -n 2 | tail -1)
release_version=$(echo "$latest_tag" | cut -d @ -f 2)
# echo "all tags for this language: $tags"
# echo "latest tag: $latest_tag"
# echo "second tag: $second_tag"
@Integralist
Integralist / extract-first-changelog-entry.md
Last active March 23, 2023 09:01
[AWK extract first changelog entry] #awk #changelog

We want just the 'v1.0.0-beta.2' changelog block, not 'v1.0.0-beta.1'...

# Changelog

## [v1.0.0-beta.2](...)

**Bug fixes:**

- ...
@Integralist
Integralist / main.go
Created February 13, 2023 17:06
[Golang spinner] #go #golang #spinner
package main
import (
"time"
"github.com/theckman/yacspin"
)
func main() {
spinner, _ := yacspin.New(yacspin.Config{
@Integralist
Integralist / main.go
Last active January 31, 2023 16:52
[Go recursively search for a file until reaching user's home directory] #go #golang #search #file #recursive
package main
import (
"errors"
"fmt"
"os"
"path/filepath"
)
func main() {
@Integralist
Integralist / playground.go
Created January 16, 2023 12:43
[Go Playground multiple files] #go #golang #playground
package main
import (
"play.ground/foo"
)
func main() {
foo.Bar()
}