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 / Math - How to identify a number.md
Created February 27, 2025 10:32
Math: How to identify a number

Here is how a number is divided up...

So how do we identify large numbers?

The "trick" is to always group the digits in threes from right to left, starting with the smallest unit (ones).

Here's how it works:

@Integralist
Integralist / dns.sh
Last active February 13, 2025 11:41
[DNS lookup of Host information] #dns #lookup #host
$ dig www.integralist.co.uk +noall +answer
; <<>> DiG 9.10.6 <<>> www.integralist.co.uk +noall +answer
;; global options: +cmd
www.integralist.co.uk. 14400 IN CNAME dreamy-wing-b0b998.netlify.com.
dreamy-wing-b0b998.netlify.com. 120 IN A 3.75.10.80
dreamy-wing-b0b998.netlify.com. 120 IN A 3.125.36.175
$ curl -so /dev/null -D - https://dreamy-wing-b0b998.netlify.com
@Integralist
Integralist / example.sh
Last active February 7, 2025 12:10
[Bash update same line for progress bar reporting] #bash #shell #progress
echo -ne "Getting the TLS entries from 1Password... ⌛\r"
sleep 2 # Simulate some processing
echo -ne "Getting the TLS entries from 1Password... ✅\n"
# -n prevents echo from automatically adding a newline.
# -e enables interpretation of escape sequences like \r (carriage return).
# \r moves the cursor back to the start of the line, so the next echo overwrites it.
# The final \n ensures the cursor moves to a new line after displaying the ✅.
@Integralist
Integralist / go work.md
Last active January 22, 2025 16:10
[Golang go work] #go #golang #gowork

Create a new directory for your project.

Inside the directory git clone your projects.

Next, from within the project directory (where the individual projects are cloned within), create your go.work file.

You can do this in one of two ways:

go work init ./cli ./go-fastly
@Integralist
Integralist / 1. xarg parallel processing.sh
Last active January 21, 2025 15:26
[xarg parallel processing] #xarg
# update --cursor value to acquire all the relevant domain data (see batch-identify-domains.sh)
fastly domain-v1 list --fqdn=test-tf --cursor=<REDACTED> --limit=100 --json | jq -r .data[].id >> /tmp/delete-domains
# now delete all those items
cat /tmp/delete-domains | xargs -P "$(sysctl -n hw.ncpu)" -I % fastly domain-v1 delete --domain-id=%
@Integralist
Integralist / Makefile.md
Last active January 14, 2025 10:33
[Makefile syntax] #make #makefile #shell

Make

Make is a build automation tool that uses a file called a Makefile to define how to build, test, or manage dependencies in a project.

It's commonly used to:

  • Compile and link code.
  • Automate repetitive tasks (e.g., testing, deploying).
  • Track changes in files and only rebuild what’s necessary.
@Integralist
Integralist / README.md
Created January 13, 2025 16:26
[OpenAPI feature flags use different schemas] #schemas #openapi #api #design

I don't know if this actually works but apparently you can use a discriminator like this...

Note

In this example, your API has to return a type property that might have a value like "base" or "feature_x".

If the API response contains "type": "base", then the OpenAPI schema will use the BaseResponse schema. Otherwise, if it's "type": "feature_x", the OpenAPI schema will use the eatureXResponse schema.

openapi: 3.1.0
@Integralist
Integralist / op.sh
Last active February 3, 2025 11:25
[1Password CLI Usage] #1Password #op #cli
# list all accounts
op account list
# check which account we're using
op whoami
# switch account
op signin
op signin --account my # account flag must be passed subset of the URL from `op account list` (e.g. `my` matches `my.1password.com`)
@Integralist
Integralist / errgroup.md
Created January 7, 2025 10:53
[When to use golang's errgroup] #golang #go #errgroup #concurrency

Tip

For a real-world example see [this gist][real-world].

errgroup.Group in Go is a great way to manage concurrent goroutines that return errors. It simplifies error handling and ensures that all goroutines finish or exit if any one of them fails. However, there are specific scenarios where it shines and others where it might not be the best fit.

When to use errgroup.Group

  1. Multiple Independent Goroutines:
    If you need to launch several goroutines concurrently, and each one performs an independent task (like querying different services), errgroup helps manage their lifecycle.
  2. Error-First Cancellation:
@Integralist
Integralist / 1. README.md
Created January 5, 2025 10:34
[macOS automation with Hammerspoon] #hammer #hammerspoon #os #automation #macos #shell #lua