Skip to content

Instantly share code, notes, and snippets.

View gavrie's full-sized avatar

Gavrie Philipson gavrie

View GitHub Profile
@gavrie
gavrie / gist:ebfad1920d7c300ff9b55d68839adbc2
Last active January 12, 2025 02:08
Building Consistent Artifacts from Multiple Git Repositories

The following is based on this prompt to Claude:

Design a solution to build artifacts from several Git repos that all use the same compiler flags. We do not want to use a central makefile for this. The repos are all built using a specific Docker image that includes all the build tools. How should we store and cache the artifacts, and retrieve the relevant versions?

I'll design a solution that focuses on consistency, reusability, and efficient artifact management. Here's a comprehensive approach:

  1. Compiler Flags Management:
# compiler-config.yaml (stored in a separate config repo)
compiler:
@gavrie
gavrie / run.tpl
Last active October 30, 2023 10:33 — forked from efrecon/run.tpl
`docker inspect` template to regenerate the `docker run` command that created a container
docker run \
{{- with .HostConfig}}
{{- if .Privileged}}
--privileged \
{{- end}}
{{- if .AutoRemove}}
--rm \
{{- end}}
{{- range $b := .Binds}}
--volume {{printf "%q" $b}} \
@gavrie
gavrie / m1-mac-python-2.7.md
Last active July 29, 2021 08:34
Running Python 2.7 virtualenv on M1 Mac
# Start Rosetta shell
arch -x86_64 $SHELL

# Install x86_64 Homebrew in /usr/local/bin (as opposed to /opt/homebrew/bin):
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Create virtualenv for native macOS Python 2.7 (since we can't build vanilla Python 2.7 on M1):
# (Note: Due to the arm64e issue, we need to use x86_64 Python)
virtualenv -p python2.7 venv
@gavrie
gavrie / nmap-tls.md
Last active February 15, 2021 10:59
nmap TLS checks

Tools

Install nmap (and fix permissions):

snap install nmap
snap connect nmap:network-control

nmap supports XML output with the option -oX. Install xmllint for nicely formatting XML:

func (br *basicRetrier) TotalTimeout() (total time.Duration) {
r := *br // Make a copy to preserve unchanged original
for r.virtual.keepTrying() {
total += r.virtual.nextTimeout()
}
log.Printf("Total timeout: %v\n", total)
return total
}
type basicRetrier struct {
// ...
virtual retrier
}
func NewBasic(timeout time.Duration, retries int) *basicRetrier {
br := &basicRetrier{
timeout: timeout,
retries: retries,
}
type retrier interface {
nextTimeout() time.Duration
keepTrying() bool
}
func (er *exponentialRetrier) nextTimeout() time.Duration {
er.retries--
t := er.timeout
er.timeout *= 2
log.Printf("Next timeout: %v\n", t)
return t
}
package retry
import "time"
type retrier struct {
timeout time.Duration
retries int
}
func New(timeout time.Duration, retries int) *retrier {
@gavrie
gavrie / retry_test.go
Last active May 17, 2016 12:08
retry unit test
package retry_test
import (
"testing"
"time"
"github.com/gavrie/retry"
)
func TestBasic(t *testing.T) {