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
version: '2'
services:
broker:
image: eclipse-mosquitto:latest
restart: always
container_name: mqtt-broker
ports:
- 1883:1883
- 8883:8883
- 9001:9001
version: '2'
services:
proxy:
restart: always
image: jwilder/nginx-proxy:alpine
ports:
- "80:80"
- "443:443"
volumes:
- ./certs/:/etc/nginx/certs:ro
@parrotmac
parrotmac / launchbot-pregen.py
Created June 26, 2024 01:40
Python Script to generate pggen-compatible queries from a PostgreSQL schema scraped using PSQL
#!/usr/bin/env python
import re
import subprocess
from textwrap import dedent
from pathlib import Path
def inspect_table(table_name: str):
output = subprocess.check_output([
"sh", "-c", f"psql 'postgres://postgres:postgres@localhost:54339/postgres' -c '\\d {table_name}'"
@parrotmac
parrotmac / ts-tricks.ts
Created May 7, 2024 00:11
Collection of useful TS Snippets
// Inclusive overlap of two types
type CommonProperties<T, U> = {
[K in keyof T & keyof U]: T[K] extends U[K] ? U[K] extends T[K] ? T[K] : never : never;
};
// Function signature that varies second arg type based on type of first
type Args<T> = T extends number ? Foo : T extends string ? Bar : never;
function dependentFunction<T extends number | string>(arg1: T, arg2: Args<T>): void {
if (typeof arg1 === "number") {
@parrotmac
parrotmac / data_tags.py
Created December 14, 2023 18:44
Specialized Django `json_script` template tag for more complex data types.
import dataclasses
from django import template
from django.utils import html
from django.utils.safestring import mark_safe
from rest_framework.renderers import JSONRenderer
from rest_framework.utils import encoders
register = template.Library()
@parrotmac
parrotmac / illustrator-batch-generate.js
Created August 5, 2023 17:28
Illustrator Batch Generate
/* global app, $ */
var names = [
"Alfa",
"Bravo",
"Charlie",
"Delta",
"Echo",
"Foxtrot",
"Golf",
isaac@lineage-build:~/android/lineage/device/huawei/angler$ git diff
diff --git a/lineage-proprietary-blobs.txt b/lineage-proprietary-blobs.txt
index 0054b74..6d84efc 100644
--- a/lineage-proprietary-blobs.txt
+++ b/lineage-proprietary-blobs.txt
@@ -38,7 +38,6 @@ lib/libdmengine.so
lib/libdmjavaplugin.so
lib/libfilterpack_facedetect.so
-app/HwSarControlService/HwSarControlService.apk
--app/Tycho/Tycho.apk;PRESIGNED
@parrotmac
parrotmac / comcast-slc-corrupt-unpkg.md
Created March 7, 2023 23:56
Log showing a different response for the same resource when requesting the resource via Comcast and T-Mobile

Log showing a different response for the same resource when requesting the resource via Comcast and T-Mobile

T-Mobile

Response Headers:

$ curl -fsSLD - -o /dev/null https://unpkg.com/graphiql@2.2.0/graphiql.min.js
HTTP/2 200
date: Tue, 07 Mar 2023 23:52:10 GMT
content-type: application/javascript; charset=utf-8
access-control-allow-origin: *
@parrotmac
parrotmac / ilo-force-reset.json
Created March 1, 2023 03:50
Send this JSON payload to an iLO API endpoint to force the system to reset
{"ResetType": "ForceRestart"}
@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 \