Skip to content

Instantly share code, notes, and snippets.

@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/std@0.83.0/http/server.ts";
import { walk } from "https://deno.land/std@0.83.0/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}"}`)
This file has been truncated, but you can view the full file.
[zigbee2mqtt-5555976c54-vkh8k] Using '/app/data' as data directory
[zigbee2mqtt-5555976c54-vkh8k]
[zigbee2mqtt-5555976c54-vkh8k] > zigbee2mqtt@1.13.0-dev start /app
[zigbee2mqtt-5555976c54-vkh8k] > node index.js
[zigbee2mqtt-5555976c54-vkh8k]
[zigbee2mqtt-5555976c54-vkh8k] zigbee2mqtt:info 2020-05-19 19:12:34: Logging to console and directory: '/app/data/log/2020-05-19.19-12-34' filename: log.txt
[zigbee2mqtt-5555976c54-vkh8k] zigbee2mqtt:info 2020-05-19 19:12:34: Starting zigbee2mqtt version 1.13.0-dev (commit #134f671)
[zigbee2mqtt-5555976c54-vkh8k] zigbee2mqtt:info 2020-05-19 19:12:34: Starting zigbee-herdsman...
[zigbee2mqtt-5555976c54-vkh8k] CREATED DECONZ ADAPTER
[zigbee2mqtt-5555976c54-vkh8k] zigbee2mqtt:info 2020-05-19 19:12:35: zigbee-herdsman started
---
apiVersion: v1
kind: ConfigMap
metadata:
name: sample-grafana-dashboard
labels:
grafana_dashboard: "1"
data:
unifi-poller-client-dpi-prometheus_rev3.json: |-
{