Skip to content

Instantly share code, notes, and snippets.

# a little helper script i use to clear out various compilation/package install caches
# uses the voidtools everything cli
@(es '\target\.rustc_info.json') | get-item | %{ $_.Directory.Parent } | %{ $_; pushd $_; cargo clean; popd }
# uses https://github.com/matthiaskrgr/cargo-cache/
cargo cache --autoclean --gc
py -3 -m pip cache purge
// run a breadth-first search, logging all matches to the console along with the path followed to get there.
// this is designed for interactive use in e.g. browser dev console,
// I use it when i'm writing userscripts to look for places where certain data is exposed through the global scope
// by amgg.
// license: you can do whatever you want forever
function BFS(root, predicate, { traversers = null, chunk_size = 512, verbose = false } = {}) {
// populate default options
traversers ??= [BFS.traversers.key_via_reflect];
import itertools, json, sys
def pairwise_sentinel(iterable):
return itertools.pairwise(itertools.chain(iterable, (pairwise_sentinel.sentinel,)))
pairwise_sentinel.sentinel = object()
def iter_capinfo(iterable):
"""like enumerate(), but gives you (item, is_first, is_last) pairs"""
first = True
for cur, nxt in pairwise_sentinel(iterable):
<#
.SYNOPSIS
quickly initialize a new rust project tailored for doing quick temporary testing of stuff
.PARAMETER ProjectTemplate
one of: Bin, Lib
.PARAMETER OpenInVSCode
open created project in a new vscode window
# powershell one-liner to generate a regex that rejects filenames containing invalid characters
# NOTE: currently this only handles invalid *characters* - reserved names e.g. COM1 won't be matched by this.
# TODO would be good to handle that too though - either just hardcode it or try one of these
# https://stackoverflow.com/a/70794363/8762161 https://stackoverflow.com/a/54643724/8762161
$valid_filename_pattern = [regex]::new(([System.IO.Path]::GetInvalidFileNameChars() | ForEach-Object {[regex]::Escape($_)} | Join-String -Separator '' -op '^[^' -os ']*$'), 'Compiled, CultureInvariant')
$ErrorActionPreference = 'Stop'
$timestamp_str = Get-Date -AsUTC -Format 'yyyy_MM_dd__HH_mm_ss'
$outdir = $PSScriptRoot
function backupregkeyhelper {
[CmdletBinding(SupportsShouldProcess)]
Param(
[Parameter(Mandatory)]
<svg viewBox="0 0 512 512" width="256" height="256" xmlns="http://www.w3.org/2000/svg" style="position:absolute;top:0px;left:0px;width:100vw;height:100vh;">
<style>
:root {
--grass-dark: #7ebe54;
--grass-light: #97c667;
--dirt-dark: #79553a;
--dirt-light: #b9855c;
<svg viewBox="0 0 512 512" width="256" height="256" xmlns="http://www.w3.org/2000/svg" style="position:absolute;top:0px;left:0px;width:100vw;height:100vh;">
<style>
:root {
--grass-dark: #7ebe54;
--grass-light: #97c667;
--dirt-dark: #79553a;
--dirt-light: #b9855c;
/*
user-defined string literal operator to parse windows api GUIDs from strings at compile time.
any of these will work:
- "XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"_guid
- "{XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}"_guid
- "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"_guid
*/
#pragma once
#ifndef __GUID_LITERAL_H__