Skip to content

Instantly share code, notes, and snippets.

View cpuguy83's full-sized avatar
:shipit:
Reviewing your code, maybe?

Brian Goff cpuguy83

:shipit:
Reviewing your code, maybe?
View GitHub Profile
#!/usr/bin/env bash
set -u
: "${PREFIX:=/usr/local}"
PATH="${PREFIX}/go/bin:${PATH}"
if ! command -v jq > /dev/null; then
echo "Installing jq" >&2
@cpuguy83
cpuguy83 / policy.json
Created August 12, 2023 19:04
Example buildkit policy
{
"rules": [
{
"action": "CONVERT",
"selector": {
"identifier": "docker-image://docker.io/library/golang:1.20-bullseye"
},
"updates": {
"identifier": "docker-image://mcr.microsoft.com/oss/go/microsoft/golang:1.20-bullseye"
}
@cpuguy83
cpuguy83 / vscode.sh
Last active August 4, 2023 20:49
Script to connect back to a vscode-server and open the specified path
#! /usr/bin/env bash
script="$(find ~/.vscode-server/bin -iname code | tail -n 1)"
if [ -z "${script}" ]; then
echo "VSCode remote script not found"
exit 1
fi
sockets="$(find /run/user/${UID}/ -iname vscode-ipc-* 2>/dev/null)"
for s in $sockets; do
@cpuguy83
cpuguy83 / debug.sh
Created July 31, 2023 22:51
Debugging stuff
set -e
prev_cmd=""
this_cmd=""
prev_line=""
this_line=""
debug_trap() {
prev_cmd="${this_cmd}"
this_cmd="${BASH_COMMAND}"
prev_line="${this_line}"
@cpuguy83
cpuguy83 / README.md
Last active November 13, 2019 03:59

This script helps to clean up vmss nodes that may have Azure disks attached to it that should not be due to bugs in Kubernetes. The specific case for this is that a disk has been re-attached to by Kubernetes when it should not have been.

This DOES NOT detect a bad node/disk, only assists in cleaning it up.

Usage

$ ./vmssfix.sh NODE_NAME PV_NAME
@cpuguy83
cpuguy83 / gist:530e8a40eb03dc08c4072686cfaff053
Last active January 22, 2019 17:49
splice vs userspace copy on containerd/fifo using Go
goos: linux
goarch: amd64
pkg: github.com/containerd/fifo
BenchmarkRawCopy/8B-4 300000 4869 ns/op 1.44 MB/s 176 B/op 8 allocs/op
BenchmarkRawCopy/16B-4 300000 4688 ns/op 3.20 MB/s 176 B/op 8 allocs/op
BenchmarkRawCopy/32B-4 300000 4312 ns/op 7.19 MB/s 176 B/op 8 allocs/op
BenchmarkRawCopy/64B-4 300000 4447 ns/op 14.16 MB/s 176 B/op 8 allocs/op
BenchmarkRawCopy/1024B-4 300000 4415 ns/op 231.66 MB/s 176 B/op 8 allocs/op
BenchmarkRawCopy/4096B-4 300000 4410 ns/op 928.50 MB/s 176 B/op 8 allocs/op
BenchmarkRawCopy/8192B-4 300000 5215 ns/op 1570.37 MB/s 176 B/op 8 allocs/op
@cpuguy83
cpuguy83 / gitsynch.sh
Created September 12, 2018 20:46
Synchronize a git fork with origin
#!/bin/bash
set -e -u -o pipefail
export ORIGIN="${1}"
export FORK="${2}"
dir=$(mktemp -d)
(
@cpuguy83
cpuguy83 / pull.go
Last active December 9, 2021 06:18
package main
import (
"context"
"fmt"
"io/ioutil"
"os"
"github.com/containerd/containerd/content/local"
"github.com/containerd/containerd/images"
@cpuguy83
cpuguy83 / Vagrantfile
Created December 6, 2017 21:10
Sometimes I need to setup a small kube cluster without thinking about it...
Vagrant.configure(2) do |config|
CNI_LOOPBACK = <<-EOF
{
"cniVersion": "0.3.0",
"type": "loopback"
}
EOF

Keybase proof

I hereby claim:

  • I am cpuguy83 on github.
  • I am cpuguy83 (https://keybase.io/cpuguy83) on keybase.
  • I have a public key ASAo08bHNxNOVVkkmpl5T8GZMOgan7PmdCC7zM0-zVNcsQo

To claim this, I am signing this object: