Skip to content

Instantly share code, notes, and snippets.

View briceburg's full-sized avatar

Brice Burgess briceburg

  • toil over toil
  • albuquerque, nm
View GitHub Profile
@briceburg
briceburg / git.md
Created November 22, 2015 05:42
git - checking fast-forward-ness
git merge-base --is-ancestor master HEAD

from man git merge-base

A common idiom to check "fast-forward-ness" between two commits A and B is (or at least used to be) to compute the merge base between A and B, and check if it is the same as A, in which case, A is an ancestor of B. You will see this idiom used

@briceburg
briceburg / nc-httpd.sh
Last active April 28, 2022 16:04
quickie nectcat httpd server
#!/usr/bin/env bash
port="${1:-8888}"
cmd="ls /home"
while true; do echo -e "HTTP/1.1 200 OK\\n\\n $($cmd)\\n" | nc -l -p $port ; done
@briceburg
briceburg / versioning-and-releases.md
Last active December 8, 2021 16:29
eight bullet versioning and release process

releases

  • semantic versioning is used
  • a branch is created for every major release, e.g. release-1.x, release-2.x, &c.
  • when ready to make a release;
    • update any changelogs and documentation with release information, commit/merge to main. ensure CI passes.
    • if backporting fixes into past releases, follow the backporting procedure from containerd, else merge main into the current release branch. e.g. main -> release-2.x.
    • checkout current release branch and update files/version with the current point release, e.g. change 'main' to 2.1.18-rc1.
      • make a release commit (e.g. with message "RELEASE 2.1.18-rc1").
  • tag the release using v as a prefix, e.g. git tag v2.1.18-rc1 && git push --tags
@briceburg
briceburg / .bashrc
Last active August 22, 2021 02:57
PS1 prompt with non-zero exit codes in red
# error code is in red, starting with \e[31m and ending with \e[0m escape codes.
# only non-zero exit codes appear.
export PS1='[\u@\h \W]\[\e[31m${?#0}\e[0m\]\$ '
@briceburg
briceburg / Dockerfile
Last active August 21, 2021 06:02
laravel 5 - running in a docker container
FROM alpine
ENV \
APP_DIR="/app" \
APP_PORT="80"
# the "app" directory (relative to Dockerfile) containers your Laravel app...
COPY app/ $APP_DIR
RUN apk add --update \
@briceburg
briceburg / packer.json
Last active August 5, 2021 19:33
convert Ubuntu AMI from MBR partitioning to GPT partitioning
// the following assumes AWS nitro (e.g. t3.*, m5.*, &c) instances (which use /dev/nvme0n1 as root disk)
// "safely" switches from MBR to GPT partitioning in Ubuntu < 21.04 or other AMIS.
// Tested using gdisk 1.0.3 from 18.04 / Bionic.
// after the change, you can use >2TB root disks. either initially, or by resizing a smaller one -- in nitro and non-nitro types
provisioners: [
{
"type": "shell",
"inline": [
"echo Converting to GPT - AWS nitro type instance",
@briceburg
briceburg / local-var-test.sh
Created December 10, 2016 15:05
bash - local variable assignment not respecting command substitution exit status
#!/usr/bin/env bash
get/value(){
echo "error getting value" >&2
return 66
}
main(){
local lvar=$(get/value) || echo "local var assignment error"
var=$(get/value) || echo "global var assignment error"
@briceburg
briceburg / main.go
Created January 13, 2021 03:18 — forked from walm/main.go
Simple Golang DNS Server
package main
import (
"fmt"
"log"
"strconv"
"github.com/miekg/dns"
)
@briceburg
briceburg / gist:81d2c8d95a7cf4f61c0a
Created May 17, 2014 00:57
simple linux shell script to adjust backlight - useful for xmonad
#!/bin/bash
# backlight brightness controls. use freely
# and adjust sysfs directory if not on toshiba
# $author Brice Burgess @iceburg
sysfs="/sys/class/backlight/toshiba"
max=`cat ${sysfs}/max_brightness`
level=`cat ${sysfs}/brightness`
@briceburg
briceburg / docker-entrypoint.sh
Created April 9, 2020 16:50
forward local ports in a docker container to the docker host (host.docker.internal)
#!/usr/bin/env bash
main(){
set -eo pipefail
# sysctl is a readonly filesystem in containers, so this must be set at run;
# [[ "$OSTYPE" =~ darwin|macos* ]] || docker_flags+=("--add-host host.docker.internal:host-gateway")
# docker run -it "${docker_flags[@]}" --cap-add=NET_ADMIN --sysctl net.ipv4.conf.all.route_localnet=1 ...
sysctl -w net.ipv4.conf.all.route_localnet=1
docker_host_ip=$(getent ahostsv4 host.docker.internal | head -n1 | awk '{print $1}')