Skip to content

Instantly share code, notes, and snippets.

View parrotmac's full-sized avatar
🔨
Making things!

Isaac Parker parrotmac

🔨
Making things!
View GitHub Profile
@parrotmac
parrotmac / build-5.10-firecracker-kernel-image.sh
Created May 28, 2022 04:55
Build Linux Kernel (v5.10) for use in a Firecracker VM
#!/usr/bin/env bash
# Note that this doesn't work on Ubuntu 22.04, but works on 20.04. This seem to be due to the newer kernel used by default on newer Ubuntu versions (YMMV)
set -euo pipefail
# Install system deps
apt-get update && apt-get upgrade -y && sudo apt-get install \
bison \
build-essential \
flex \
@parrotmac
parrotmac / apple-silicon-shell-shortcuts.sh
Created February 16, 2022 21:55
Three little helpers when living on an Apple silicon Mac
function i() {
arch -x86_64 $@
}
alias ish='arch -x86_64 zsh'
alias ibrew='arch -x86_64 brew'
@parrotmac
parrotmac / caddy_cookie_reverse_proxy.json
Created August 9, 2021 22:38
Caddy - Reverse proxy to hosts based on a cookie (or other header) value.
# In most cases, `terminationMessagePolicy: FallbackToLogsOnError` must be set!
kubectl --namespace "${NAMESPACE}" -l app="${APP}" get pods -o jsonpath='{.items[?(@.status.containerStatuses[*].state.waiting)].status.containerStatuses[*].lastState.terminated.message}'
version: "3.4"
# More info at https://github.com/pi-hole/docker-pi-hole/ and https://docs.pi-hole.net/
services:
pihole:
container_name: pihole
image: pihole/pihole:latest
ports:
- "10.42.0.0:53:53/tcp"
- "10.42.0.0:53:53/udp"
@parrotmac
parrotmac / mitm-events.py
Created June 8, 2021 05:01
Modify HTTP requests & responses with Mitmproxy
"""HTTP-specific events."""
import mitmproxy.http
class Events:
filter = "news.ycombinator.com"
def http_connect(self, flow: mitmproxy.http.HTTPFlow):
"""
An HTTP CONNECT request was received. Setting a non 2xx response on
import * as React from "react";
import * as ReactDOM from "react-dom";
import { useEffect, useRef, useState } from "react";
interface MediaDeviceSelectorProps {
kind: MediaDeviceKind;
availableDevices: Array<MediaDeviceInfo>;
selectedDeviceID?: string;
onDeviceUpdated: (newDeviceID: string) => void;
}
@parrotmac
parrotmac / monitor-shortcuts-macos
Last active April 26, 2021 19:36
Shell aliases to control my monitor setup using DDC
# Source this from e.g. `.zshrc`
# Ensure `ddcctl` from https://github.com/kfix/ddcctl is installed and available in your `$PATH`
#
# Other resources to learn how this works:
# http://boichat.ch/nicolas/ddcci/specs.html
# http://boichat.ch/nicolas/ddcci/method.html
# https://developer.apple.com/documentation/iokit/1410388-ioi2cinterfaceopen?language=objc
# https://github.com/MonitorControl/MonitorControl
Pacific/Pago_Pago −11:00
Pacific/Honolulu −10:00
America/Anchorage −09:00
America/Los_Angeles −08:00
America/Denver −07:00
America/Chicago −06:00
America/New_York −05:00
America/La_Paz −04:00
America/Nuuk −03:00
America/Noronha −02:00
@parrotmac
parrotmac / hci_socket_list.py
Created August 20, 2020 00:03
List Processes with open HCI Sockets
#!/usr/bin/env python3
import os
hci_sockets = []
with open('/proc/net/hci') as hcif:
for line in hcif:
if 'Inodes' in line:
continue