Skip to content

Instantly share code, notes, and snippets.

// 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];
<#
.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

list of useful programs. originally only focused on tools for reverse engineering, asset ripping, etc. but now it's also got some general stuff too

contents

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):
# 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;
function createElementHelper(tagName, {style:{vars:styleVars={}, ...style}={}, attrs={}, events={}, classList=[], children=[], parent=null, insertBefore=null, ...props}={}) {
let elem = document.createElement(tagName);
for(let k in style) elem.style[k] = style[k];
for(let k in styleVars) elem.style.setProperty(k, styleVars[k]);
for(let k in attrs) elem.setAttribute(k, attrs[k]);
for(let k in events) elem.addEventListener(k, events[k]);
if(classList.length > 0) elem.classList.add.apply(elem.classList, classList);
for(let k in props) elem[k] = props[k];
for(let c of children) elem.appendChild(c);
if(parent !== null) {
/*
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__