Skip to content

Instantly share code, notes, and snippets.

@oofnikj
oofnikj / .gitlab-ci.yml
Created Aug 26, 2020
GitLab multiarch docker build
View .gitlab-ci.yml
# GitLab multi-arch docker build template
# https://badgateway.qc.to/multi-architecture-docker-builds
variables:
CI_IMAGE: $DOCKER_HUB_USER/$CI_PROJECT_NAME
before_script:
- docker login -u $DOCKER_HUB_USER -p $DOCKER_HUB_TOKEN
- docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
- docker buildx create --use
@oofnikj
oofnikj / docker-termux.md
Created Aug 23, 2020
Install Docker on Termux
View docker-termux.md

Docker on Termux [in a VM]

Just kidding, we're cheating by creating a Linux VM and installing Docker in it. It actually runs at okay-ish speed.

  • Install QEMU
pkg install qemu-utils qemu-common qemu-system-x86_64-headless
  • Download Alpine Linux 3.12 (virt optimized) ISO
@oofnikj
oofnikj / awsp.bash
Created Jul 3, 2020
awsp: AWS profile switcher
View awsp.bash
### This file is intended to be sourced from ~/.bashrc ###
# quickly switch between AWS profiles with auto-completion
# uses https://github.com/Nike-Inc/gimme-aws-creds to obtain credentials
# if using static credentials, just comment out lines 13-15
awsp() {
if [[ -n $1 ]] ; then
# validate input
grep -q -w "\[profile ${1}\]" ~/.aws/config || { echo "No such profile $1"; return 1; }
@oofnikj
oofnikj / totp
Created Jun 21, 2020
TOTP CLI generator
View totp
#!/usr/bin/env python
# put this file in your $PATH to generate TOTP from command line (don't forget to `chmod +x`)
import os
import sys
import pyotp
import pyperclip
try:
@oofnikj
oofnikj / gen-efi-image.sh
Last active Oct 27, 2020
Generate OpenWrt 19.07.2 EFI-compatible image
View gen-efi-image.sh
#!/usr/bin/env bash
### UPDATED SCRIPT AVAILABLE AT https://github.com/oofnikj/openwrt-efi-tools ###
# gen-efi-image.sh [DEST_IMG] [EFI_IMG] [SOURCE_IMG]
#
# Generates an EFI-compatible x86-64 disk image for OpenWrt
# by combining the rootfs and kernel from the latest stable release
# with the EFI image available in snapshot since @a6b7c3e.
#
@oofnikj
oofnikj / HostA.md
Created Jan 24, 2020
network config
View HostA.md

network config

HostA$ ip -d link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 promiscuity 0 addrgenmode eui64 
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP mode DEFAULT group default qlen 1000
    link/ether 94:c6:91:xx:xx:xx brd ff:ff:ff:ff:ff:ff promiscuity 1 
    bridge_slave state forwarding priority 32 cost 4 hairpin off guard off root_block off fastleave off learning on flood on addrgenmode eui64 
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN mode DEFAULT group default qlen 100
    link/none  promiscuity 0 
View wififix.sh
#!/bin/bash
# Script to reset wifi on a Raspberry Pi Zero W
# Outputs a message to systemd-journal every time it resets
#
# nothing else seemed to work
#
# Run it with crontab every minute
@oofnikj
oofnikj / arch.md
Last active Jan 12, 2020
Arch linux install notes
View arch.md

Installing Arch

set up wireless networking

wpa_supplicant -B -i wlan0 -c <(wpa_passphrase *SSID *password*)
dhcpcd --ipv4only

partitioning

  • use cfdisk:
@oofnikj
oofnikj / get_cloud.sh
Last active Oct 14, 2019
Download and install latest google-cloud-sdk on Alpine / Debian / Ubuntu
View get_cloud.sh
#!/bin/sh -e
######
# Tested with various flavors of Alpine, Ubuntu and Debian. CentOS / RedHat not supported (yet).
# Use:
# wget -qO- https://gist.githubusercontent.com/oofnikj/7a2fb1e6b20b397775d882ecd8980159/raw | sh
######
SDK_DIR=/usr/local/lib
which apt && apt update && apt install -y wget jq python3 ca-certificates --no-install-recommends || true
@oofnikj
oofnikj / pg_manage.sh
Last active Oct 14, 2019
PostgreSQL dump / restore to Google Cloud Storage
View pg_manage.sh
#!/bin/bash
PGUSER=${PGUSER:-"postgres"}
CATALOG_BUCKET="normalized-catalog"
_get_dbs() {
psql -U $PGUSER -c "COPY (
SELECT datname FROM pg_database
WHERE datname NOT IN (
'postgres',
You can’t perform that action at this time.