Skip to content

Instantly share code, notes, and snippets.

stefansundin /
Last active January 17, 2024 07:10
How to limit `docker buildx build` concurrency

If your computer is running out of memory during a docker build, or if the build is CPU intensive, you might want to try building one architecture at a time.

When creating the builder instance, specify a buildkitd config file with --config that limits the concurrency.

Create buildkitd.toml:

max-parallelism = 1
stefansundin / protected-dialer-control.go
Last active February 8, 2022 01:59
Golang dialer control to prevent untrusted input from connecting to private IP addresses.
package main
import (
stefansundin /
Last active February 5, 2021 08:25
Analyze long audio files with
#!/bin/bash -ex
mkdir -p audd
if (( $# < 2 )); then
echo "Please supply two arguments, the input file and the timestamp (HH:MM:SS)."
exit 1
pos=$(date -d "1970-01-01 $2" -u +%s)
stefansundin / ffmpeg.rb
Last active August 20, 2021 14:19
Download Twitch video that has muted sound.
#!/usr/bin/env ruby
files = Dir["*.ts"].sort_by { |fn| fn.split(".")[0].to_i }
puts "ffmpeg -i 'concat:#{files.join("|")}' -codec copy output.mkv"
puts "run this first:"
puts "ulimit -n 4096"
stefansundin / manifest.json
Created July 24, 2019 19:11
Make the list of items in Rollbar wider.
"name": "Rollbar",
"version": "1.0",
"description": "Make the list of items in Rollbar wider.",
"content_scripts": [
"matches": ["*"],
"css": ["rollbar.css"]
stefansundin / spf-lookup-counter.rb
Last active October 28, 2018 19:50
Count number of lookups in an SPF record.
#!/usr/bin/env ruby
# SPF implementations MUST limit the number of mechanisms and modifiers
# that do DNS lookups to at most 10 per SPF check, including any
# lookups caused by the use of the "include" mechanism or the
# "redirect" modifier. If this number is exceeded during a check, a
# PermError MUST be returned. The "include", "a", "mx", "ptr", and
# "exists" mechanisms as well as the "redirect" modifier do count
# against this limit. The "all", "ip4", and "ip6" mechanisms do not
stefansundin /
Last active February 2, 2021 09:27
Bash on Windows shell script file association
# Put this file in C:\ and then run z-register.bat by right clicking it and using "Run as Administrator"
# Translate the windows path to the equivalent Bash on Windows path, then run it!
dir=$(dirname "/mnt/${drive,,}${path//\\/\/}")
cd "$dir"
stefansundin / nginx.firewall.plist
Last active November 2, 2022 16:18
This lets you run nginx as a normal user and still receive connections on port 80 and 443. Setup nginx to listen to port 8080 for http and 8443 for https.
This is not actually necessary, as you can use the following commands to allow nginx to bind to privileged ports:
$ sudo chown root:wheel /usr/local/opt/nginx/bin/nginx
$ sudo chmod u+s /usr/local/opt/nginx/bin/nginx