Skip to content

Instantly share code, notes, and snippets.

View afirth's full-sized avatar

Alastair Firth afirth

View GitHub Profile
@afirth
afirth / gist:8ab37f9a672e1f57388e189a5b7cf219
Last active January 3, 2024 22:00
ubuntu fix deep sleep (change from s2idle)
# check deep is not selected and also available
cat /sys/power/mem_sleep
# temp set
sudo su -
root@:~# echo "deep" > /sys/power/mem_sleep
exit
# test
systemctl suspend -i
kubectl get secret NAME -o json | jq '.data | map_values(@base64d)'
kubectl get secret NAME -o go-template='{{range $k,$v := .data}}{{printf "%s: " $k}}{{if not $v}}{{$v}}{{else}}{{$v | base64decode}}{{end}}{{"\n"}}{{end}}'
@afirth
afirth / ita_parser.sh
Created August 2, 2022 21:32
parse ita matrix json into csv with jq
for f in *.json; do
jq -r '. | .ext.totalPrice, (.itinerary.slices[].segments[] |[.carrier.code, .flight.number, .legs[].origin.code, .legs[].departure, .legs[].destination.code, .legs[].arrival] | @csv)' < $f
done
#!/bin/bash
# From http://spargelkohl.livejournal.com/65263.html - 2016-04-08 -AF]
# This script creates a RAMFS disk with an HFS+ partition on it and
# mounts it so it is visible in the OS X filesystem (including the
# Finder).
PATH=/sbin:/usr/sbin:/bin:/usr/bin:/opt/local/bin:$HOME/bin
umask 077
@afirth
afirth / Makefile
Created May 6, 2022 19:48
Makefile for helm template + kustomize
#!make
include .env
MAKEFLAGS += \
--warn-undefined-variables
SHELL = /usr/bin/env bash
.SHELLFLAGS := -O globstar -eu -o pipefail -c
.SUFFIXES:
# consistent sorting on OSX/nix
Codecov
Product
Solutions
Customers
@afirth
afirth / go get binaries available on path
Last active January 2, 2021 13:51
Make binaries installed with go get available on path
# add to [bash/zsh]rc and source
# Golang
which go > /dev/null && \
export GOPATH=$(go env GOPATH) && \
export PATH=$GOPATH/bin:$PATH
@afirth
afirth / kustomization.yaml
Created August 21, 2020 20:50
kustomize patch service for NEGs ingress (GKE)
patchesJSON6902:
- target:
version: v1
kind: Service
name: NAME
namespace: NS
patch: |-
- op: add
path: "/metadata/annotations"
@afirth
afirth / gist:fb3b4dcd3ce1db9adc58993ff09cd02d
Created August 13, 2020 15:57
recover staged or reset files in git (ran git add but somehow discarded without committing)
export UNIQUE_CODE=sops_version
#from https://stackoverflow.com/a/14988152/13484536
for b in $(git fsck --lost-found | grep blob | awk '{print $3}'); do git cat-file -p $b | grep -q ${UNIQUE_CODE} && echo $b && git cat-file -p $b && echo; done
@afirth
afirth / gist:35f2e422fd056c776a4463a5948cf6fd
Created July 31, 2020 14:18
JSON logs for ingress-nginx (stackdriver compatible)
log-format-escape-json: "true"
http-snippet: |
map $msec $timestamp_secs { ~(.*)\..* $1; }
map $msec $timestamp_nanos { ~.*\.(?<tsn>.*) "${tsn}000000"; }
log-format-upstream: '{"timestampSeconds":"$timestamp_secs", "timestampNanos":"$timestamp_nanos", "time_epoch":"$msec", "time_iso8601":"$time_iso8601", "remote_addr":"$proxy_protocol_addr", "x-forward-for":"$proxy_add_x_forwarded_for", "request_id":"$req_id", "remote_user":"$remote_user", "bytes_sent":$bytes_sent, "request_time":$request_time, "status":$status, "vhost":"$host", "request_proto":"$server_protocol", "path":"$uri", "request_query":"$args", "request_length":$request_length, "duration":$request_time, "method":"$request_method", "http_referrer":"$http_referer", "http_user_agent":"$http_user_agent" }'