Skip to content

Instantly share code, notes, and snippets.

@LukeChannings
LukeChannings / host-x5c-x509.tpl.json
Created January 12, 2025 18:29
A step-ca x509 template for an x5c provisioner that enforces the provisioner's PermittedDNSDomains constraints.
{{/*
This template creates an x509 certificate given an x5c certificate issued by the Hosts CA.
Smallstep's step-ca reserves per-provisioner policies for their enterprise tier, so I'm implementing
the Permitted DNS Domain extension enforement in the template.
*/}}
{{ $permitted_domains := .AuthorizationCrt.PermittedDNSDomains }}
{{/* Combine the Subject Alt Name and Subject into one list so we can check everthing in one pass. */}}
{{ $requested_domains := concat (list (dict "Value" .Subject.CommonName "Type" "dns")) .SANs }}
@LukeChannings
LukeChannings / lukes-dns-blocklist.txt
Last active November 17, 2024 23:22
lukes-dns-blocklist.txt
$TTL 300
@ SOA localhost. root.localhost. 1731810420 43200 3600 86400 300
NS localhost.
;
; Title: Luke's list
; License: MIT
; Expires: 1 day
; Last modified: 17 Nov 2024 23:22 UTC
; Version: 2024.1117.0227.57
; Syntax: RPZ
@LukeChannings
LukeChannings / interpolate.js
Created January 6, 2024 18:34
Safe string interpolation function
/**
* interpolate
* @description replaces substrings within a string template with values in a context dictionary
* @example interpolate("hello ${name}", { name: "Jerry" })
* @param {string} template a template string
* @param {Record<string, string>} context
* @returns {string}
*/
const interpolate = (template, context) =>
template.replaceAll(/\${([a-z_$][a-z0-9_$]+?)}/gi, (raw, name) =>
@LukeChannings
LukeChannings / deno_install.sh
Last active January 5, 2024 02:31
Deno installation script
#!/bin/sh
# A modification of the standard Deno installation script (https://deno.land/install.sh)
# updated to support downloading a Linux arm64 binary from LukeChannings/deno-arm64
# MIT licence.
set -e
if ! command -v unzip >/dev/null; then
echo "Error: unzip is required to install Deno (see: https://github.com/denoland/deno_install#unzip-is-required)." 1>&2
exit 1
@LukeChannings
LukeChannings / WtFnZb-Renamer.py
Created February 13, 2022 20:21
WtFnZb-Renamer.py
#!/usr/bin/env python3
### NZBGET SCAN SCRIPT
# Extract filenames from subjects containing [PRiVATE]-[WtFnZb]
#
# This extensions extracts obfuscated filenames from .nzb files
# created by WtFnZb.
#
# Supported subject formats:
#
<meta name="viewport" content="width=device-width, initial-scale=1.0,viewport-fit=cover">
<title>Viewport Height Test</title>
<style>
body {
font-family: -apple-system, 'Helvetica Neue', sans-serif;
margin: 0;
}
main {
// a .crumb file is a UTF-8 JSON document with the following schema:
interface CroutonRecipe {
name: string;
uuid: string;
serves: number;
// Preparation time in minutes
duration: number;
// Cooking time in minutes
cookingDuration: number;
@LukeChannings
LukeChannings / AndroidManifest.xml
Created May 1, 2021 21:48
AndroidManifest.xml
<?xml version="1.0" encoding="utf-8" standalone="no"?><manifest xmlns:android="http://schemas.android.com/apk/res/android" android:compileSdkVersion="29" android:compileSdkVersionCodename="10" android:installLocation="auto" package="com.plexapp.android" platformBuildVersionCode="29" platformBuildVersionName="10">
<uses-permission android:name="com.android.vending.BILLING"/>
<uses-feature android:name="android.hardware.touchscreen" android:required="false"/>
<uses-feature android:name="android.hardware.screen.landscape" android:required="false"/>
<uses-feature android:name="android.hardware.location" android:required="false"/>
<uses-feature android:name="android.hardware.location.gps" android:required="false"/>
<uses-feature android:name="android.hardware.location.network" android:required="false"/>
<uses-feature android:name="android.hardware.telephony" android:required="false"/>
<uses-feature android:name="android.hardware.microphone" android:required="false"/>
<uses-featu
@LukeChannings
LukeChannings / serve_deno_cache.ts
Last active February 19, 2021 13:00
serve_deno_cache.ts
import { serve } from "https://deno.land/[email protected]/http/server.ts";
import { walk } from "https://deno.land/[email protected]/fs/walk.ts";
const PORT = 8001;
interface DenoInfo {
denoDir: string;
modulesCache: string;
typescriptCache: string;
}
@LukeChannings
LukeChannings / scriptable-prometheus-example.js
Created November 26, 2020 14:16
scriptable-prometheus-example.js
const PROMETHEUS_ENDPOINT = 'prometheus.example.com'
const fetchMetric = async (query) => {
const url = `https://${PROMETHEUS_ENDPOINT}/api/v1/query?query=${encodeURIComponent(query)}`
const req = new Request(url)
return req.loadJSON()
}
const getPVCAvailability = (pvc) => {
return fetchMetric(`kubelet_volume_stats_available_bytes{persistentvolumeclaim="${pvc}"}`)