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 / example.sh
Last active May 26, 2025 15:50
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 / Mermaid Example.md
Last active June 10, 2025 13:22
Mermaid Diagram Examples #diagrams
@Integralist
Integralist / go work.md
Last active May 29, 2025 14:02
Go: go work #go #project

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 May 26, 2025 15:51
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 May 26, 2025 15:51
Make: 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
Last active May 26, 2025 15:51
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 / 1Password CLI.md
Last active June 5, 2025 08:51
1Password CLI #shell

list all accounts

op account list

check which account we're using

op whoami
@Integralist
Integralist / errgroup.md
Last active May 29, 2025 15:17
Go: errgroup #go #concurrency #errors

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
Last active May 26, 2025 15:59
macOS: automation with Hammerspoon #hammer #hammerspoon #os #automation #macos #shell #lua
@Integralist
Integralist / image-reduce.sh
Last active May 26, 2025 15:59
Image resize with ImageMagick #bash #shell #imagemagick #resize #image
brew install imagemagick
magick example.png -quality 70 optimised.jpg