Skip to content

Instantly share code, notes, and snippets.

View vbatts's full-sized avatar
🧁

Vincent Batts vbatts

🧁
View GitHub Profile
@vbatts
vbatts / gzip_with_attributes.go
Created October 25, 2016 17:54
Use gzip comment field for added info
package main
import (
"compress/gzip"
"crypto/sha256"
"encoding/json"
"flag"
"fmt"
"io"
"log"
@vbatts
vbatts / README.md
Last active January 27, 2018 16:12
🙏 📎 Emoji that checksum! 🎉 💩

emojisum

🙏 📎 Emoji that checksum! 🎉 💩

I attempted a curated list of 256 emojis that are not entirely similar. Using http://www.webpagefx.com/tools/emoji-cheat-sheet/ to compare them. I went with 256 as that is 8bit/1byte, and the hexadecimal output that is 2 hex characters.

So 1 emoji is 2 hex positions.

new home

@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) {
@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 / 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 / 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 / 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 / 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 / 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 / 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}