Skip to content

Instantly share code, notes, and snippets.

View cpuguy83's full-sized avatar
🐶

Brian Goff cpuguy83

🐶
View GitHub Profile
@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 / 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 / loading_spinner.coffee
Last active August 30, 2020 13:49
Simple loading spinner for long requests with turbolinks and bootstrap modal
@PageSpinner =
spin: (ms=500)->
@spinner = setTimeout( (=> @add_spinner()), ms)
$(document).on 'page:change', =>
@remove_spinner()
spinner_html: '
<div class="modal hide fade" id="page-spinner">
<div class="modal-head card-title">Please Wait...</div>
<div class="modal-body card-body">
<i class="icon-spinner icon-spin icon-2x"></i>
@cpuguy83
cpuguy83 / logforwarder.go
Last active August 7, 2020 06:37
libswarm logger demo
package backends
import (
"fmt"
"io"
"strings"
"sync"
"time"
"github.com/docker/libswarm"
@cpuguy83
cpuguy83 / custom_kernel
Last active December 9, 2019 12:52
Boot Ubuntu with custom kernel on Digital Ocean
apt-get install kexec-tools
# Insert this at the top of /etc/init.d/rcS
if grep -qv ' kexeced$' /proc/cmdline ;then
kexec --load /vmlinuz --initrd=/initrd.img --append='root=LABEL=DOROOT kexeced' &&
mount -o ro,remount / &&
kexec -e
fi
# Then just use apt/dpkg to install whatever kernel you want, e.g. from http://kernel.ubuntu.com/~kernel-ppa/mainline/
@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)
(