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
function BFS(root, predicate, { traversers = null, chunk_size = 512, verbose = false } = {}) {
// populate default options
traversers ??= [BFS.traversers.key_via_reflect];
// tracks already-seen nodes
const seen = new Set([root]);
// wrappper around predicate so caller doesn't need to manually catch errors
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;

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

/*
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__
@adrianmgg
adrianmgg / new_file_without_extension.reg
Last active October 21, 2021 01:17
windows registry stuff
Windows Registry Editor Version 5.00
; add 'file without extension' to file explorer's right click > new > ... dialog
; .file_without_extension is a dummy name since afaik we need to have some extension
; associated in order to add it to the menu.
[HKEY_CLASSES_ROOT\.file_without_extension]
@="FileWithoutExtension"
[HKEY_CLASSES_ROOT\.file_without_extension\ShellNew]
; create an empty file (as opposed to from a template)