Skip to content

Instantly share code, notes, and snippets.

View vbatts's full-sized avatar
🧁

Vincent Batts vbatts

🧁
View GitHub Profile
@vbatts
vbatts / quickest.go
Created November 14, 2019 19:10
quickest rsync server response
package main
import (
"bufio"
"fmt"
"io"
"log"
"os"
"os/exec"
"sort"
@vbatts
vbatts / Corefile
Last active October 30, 2019 19:39
using coredns to route a split tunnel (like having wireguard connected to home network)
batts.lan. {
# i compiled in this unbound plugin, to get recursive lookups. On centos it needed the 'unbound-devel' package.
unbound
cache
forward . 192.168.0.1
errors
log
}
. {
@vbatts
vbatts / Dockerfile
Created March 7, 2019 19:17
I want repo:tag@digest from every layer in non-colliding values!
ARG IMAGE=fedora
ARG IMAGE_TAG=29
FROM ${IMAGE}:${IMAGE_TAG}
LABEL com.hashbangbash.image=${IMAGE}:${IMAGE_TAG}@${DIGEST}
LABEL com.hashbangbash.image.repo=${IMAGE}
LABEL com.hashbangbash.image.tag=${IMAGE_TAG}
LABEL com.hashbangbash.image.digest=${DIGEST}
@vbatts
vbatts / main.go
Created March 4, 2019 14:02
buffering features from go releases
package main
import (
"fmt"
)
func main() {
var str = "apples and bananas; apples and bananas; apples and bananas; apples and bananas;"
fmt.Println(ReplaceAll(str, "an", "op"))
}
@vbatts
vbatts / README.md
Last active May 23, 2023 23:08
knative+buildah deep dive

walkthrough: buildah on knative

The buildah utility is a versitile container build tool that does not require a daemon (everything is direct invocation). See my "deep dive" for a few hands on use-cases.

Recently knative was announced. It is a project to enable the kubernetes primitives needed to build a functions-as-a-service. There are a plumbing services needed around this use-case, "build" is one of them. Building containers is largely an indepenent goal and story of "serverless" or "FaaS", but I get why they are grouped together.

@vbatts
vbatts / Dockerfile
Last active February 5, 2023 16:34
buildah: quick deep dive
FROM buildpack-deps:stretch-scm
# gcc for cgo
RUN apt-get update && apt-get install -y --no-install-recommends \
g++ \
gcc \
libc6-dev \
make \
pkg-config \
&& rm -rf /var/lib/apt/lists/*
@vbatts
vbatts / main.go
Last active October 24, 2017 23:55
[golang] Looking for struct pointers in interface function signatures
package main
// spurred from discussion around https://github.com/kubernetes/kubernetes/pull/54257#issuecomment-338274869
import (
"flag"
"fmt"
"go/ast"
"go/build"
"go/parser"
@vbatts
vbatts / main.go
Created October 9, 2017 19:31
grafeas client trial
package main
import (
"log"
"github.com/davecgh/go-spew/spew"
grf "github.com/grafeas/client-go"
)
func main() {
@vbatts
vbatts / output.txt
Last active February 24, 2017 14:07
sl-feeds on stock slackware
root@slackware64-current:/home/vbatts# which go
/usr/bin/go
root@slackware64-current:/home/vbatts# go version
go version go1.4.2 gccgo (GCC) 5.4.0 linux/amd64
root@slackware64-current:/home/vbatts# export GOPATH=`mktemp -d`
root@slackware64-current:/home/vbatts# export GOBIN=/usr/local/bin
root@slackware64-current:/home/vbatts# go get github.com/vbatts/sl-feeds/cmd/sl-feeds
root@slackware64-current:/home/vbatts# sl-feeds --sample-config > /tmp/sl-feeds.conf
root@slackware64-current:/home/vbatts# sl-feeds --config /tmp/sl-feeds.conf -d /tmp/
Writing to: "/tmp/"
@vbatts
vbatts / crc4.go
Created January 16, 2017 21:57
CRC-4 for golang
package crc4
func Checksum(b []byte) uint8 {
crc := 0xFFFF
for bI := 0; bI < len(b); bI++ {
bit := uint8(0x80)
for bitI := 0; bitI < 8; bitI++ {
xorFlag := ((crc & 0x8000) == 0x8000)
crc = crc << 1
if ((b[bI] & bit) ^ uint8(0xFF)) != uint8(0xFF) {