Skip to content

Instantly share code, notes, and snippets.

View pboothe's full-sized avatar
Always busy, always online, always ready for a cup of coffee

Peter Boothe pboothe

Always busy, always online, always ready for a cup of coffee
View GitHub Profile
@pboothe
pboothe / .golangci.yml
Created March 26, 2025 12:24
The golangci-lint configuration used for the Go code in Triple Pat as of 2025-03-26. Includes the reasoning behind each choice, and is set up for v2 of golangci-lint.
version: "2"
run:
issues-exit-code: 1
tests: true
output:
formats:
text:
path: stdout
print-linter-name: true
print-issued-lines: true
package main
import (
"bytes"
"context"
"io"
"net/http"
"testing"
"github.com/prometheus/client_golang/prometheus/testutil/promlint"
@pboothe
pboothe / clock.go
Created January 2, 2025 12:42
A clock for injecting deterministic times during unit tests and real times in production.
package timex
import "time"
type Clock interface {
Now() time.Time
Sleep(d time.Duration)
}
type SystemClock struct{}
run:
# Timeout for analysis, e.g. 30s, 5m.
# Default: 1m
timeout: 5m
# Exit code when at least one issue was found.
# Default: 1
issues-exit-code: 1
# Include test files or not.
# Default: true
tests: false
GeoIP_country_continent = [
"--", "AS", "EU", "EU", "AS", "AS", "NA", "NA", "EU", "AS", "NA", "AF",
"AN", "SA", "OC", "EU", "OC", "NA", "AS", "EU", "NA", "AS", "EU", "AF",
"EU", "AS", "AF", "AF", "NA", "AS", "SA", "SA", "NA", "AS", "AN", "AF",
"EU", "NA", "NA", "AS", "AF", "AF", "AF", "EU", "AF", "OC", "SA", "AF",
"AS", "SA", "NA", "NA", "AF", "AS", "AS", "EU", "EU", "AF", "EU", "NA",
"NA", "AF", "SA", "EU", "AF", "AF", "AF", "EU", "AF", "EU", "OC", "SA",
"OC", "EU", "EU", "NA", "AF", "EU", "NA", "AS", "SA", "AF", "EU", "NA",
"AF", "AF", "NA", "AF", "EU", "AN", "NA", "OC", "AF", "SA", "AS", "AN",
"NA", "EU", "NA", "EU", "AS", "EU", "AS", "AS", "AS", "AS", "AS", "EU",
package creds
func NewProvider() (Provider) {
}
type Provider interface {
FindCredentials() (Creds)
}
NewConnector() (Connector) {
return &sshConnector{...}
}
type sshConnector struct {
dialer dialer
}
func (s *sshConnector) NewConnection(...) {
s.dialer.Dial()
@pboothe
pboothe / fake.sh
Created June 6, 2018 17:34
A command that spies on a binary by being run in its place, calling the original and forking all input and output to logfiles as well as the called subprocess
#!/bin/bash
OUTPUT=$(mktemp -d --tmpdir=/tmp "$(date -Iseconds).$(basename $0).XXXXXXX")
echo "$@" > "${OUTPUT}/cmdline"
env > "${OUTPUT}/env"
cat - \
| tee "${OUTPUT}/input" \
| /usr/cni/bin/$(basename $0) $@ \
| tee "${OUTPUT}/output"
cd "${OUTPUT}"
#!/bin/bash
echo 'This worked!'
FROM ubuntu
ADD myscript.sh /myscript.sh
RUN chmod +x myscript.sh
CMD /myscript.sh