Skip to content

Instantly share code, notes, and snippets.

View anonhostpi's full-sized avatar
📝
Studying...

Blue Falcon anonhostpi

📝
Studying...
View GitHub Profile
@anonhostpi
anonhostpi / tree.yaml.ts
Last active November 4, 2025 19:31
Generate a yaml tree representing a directory
#!/usr/bin/env -S deno run --allow-read
import { parseArgs } from "jsr:@std/cli/parse-args";
import { resolve, normalize } from "jsr:@std/path";
interface Tree {
[key: string]: string | Tree;
}
async function treeToObject(
@anonhostpi
anonhostpi / unlazy.js
Last active November 1, 2025 17:05
Unlazy a JS Generator Function
// primes the generator function from arguments provided up to the first yield
// no priming performed without arguments/initial call
export default function unlazy(lazyGeneratorFunction) {
const generatorProxy = function (...args) {
const lazy = lazyGeneratorFunction.apply(this, args);
const first = lazy.next(); // run up to first yield
// create a proxy generator that replays that first result once
let sentFirst = false;
const proxy = {
@anonhostpi
anonhostpi / wasm.ps1
Last active September 14, 2025 08:42
How to do wasm in powershell
# iex (iwr 'https://gist.github.com/anonhostpi/e33c2fb4e3282ff75962cf12a2a9af6a/raw/wasm.ps1').content
& {
# Install-Package "Wasmtime" -ProviderName NuGet
$package = Get-Package -Name "Wasmtime"
$directory = $package.Source | Split-Path
$runtime = "win-x64" # "win/linux/osx-arm64/x64"
@anonhostpi
anonhostpi / cloud-init.yaml
Last active September 8, 2025 00:41
Archive-Wasm builder for Wasmtime
# $init = path/to/cloud-init.yaml
# # (iwr "https://gist.github.com/anonhostpi/05aa300aa56a3b1baf19561b3bc607f5/raw/cloud-init.yaml").Content | Out-File $init
#
# multipass launch --name archive-wasm --memory 6G --disk 20G --cloud-init $init --network "<your-network-adapter>"
# multipass mount "$(Resolve-Path . <# or wherever #>)" archive-wasm:/home/ubuntu/shared
# multipass stop archive-wasm
# multipass start archive-wasm
# multipass shell archive-wasm
#
# # Inside the VM:
@anonhostpi
anonhostpi / wasm.ps1
Last active September 5, 2025 02:25
Wasm in PowerShell
# iex (iwr 'https://gist.github.com/anonhostpi/c82d294d7999d875c820e3b2094998e9/raw/wasm.ps1').Content
$engine = & {
$package = "Wasmtime"
$runtime = & (nmo {iex "using namespace System.Runtime.InteropServices" }) {
$runtime = @{}
$is = { param([OSPlatform] $platform); return ([RuntimeInformation]::IsOSPlatform($platform)) }
@anonhostpi
anonhostpi / webserver.ps1
Last active September 1, 2025 10:05
Webserver Example
# iex (iwr "https://gist.github.com/anonhostpi/1cc0084b959a9ea9e97dca9dce414e1f/raw/webserver.ps1").Content
function New-Webserver {
param(
[string] $Binding = "http://localhost:8080/",
[string] $BaseDirectory = "$(Get-Location -PSProvider FileSystem)",
[string] $Name = "PowerShell Web Server",
[System.Collections.IDictionary] $Routes = @{
Before = { param( $Server, $Command, $Listener, $Context ) return $true }
@anonhostpi
anonhostpi / 11112.dat
Created August 27, 2025 16:23
Chima Croc Fly Wheel Cover
0 TOP SHELL, NO. 3 Ø4,85 (Needs Work)
0 Name: 11112.dat
0 Author: <AuthorRealName> [<AuthorLDrawName>]
0 !LDRAW_ORG Unofficial_Part
0 !LICENSE Redistributable under CCAL version 2.0 : see CAreadme.txt
0 BFC CERTIFY CCW
0 !HISTORY 2013-08-14 {LEGO Digital Designer} Original part shape
0 !HISTORY 2013-08-14 [<AuthorLDrawName>] File preparation for LDraw Parts Tracker
@anonhostpi
anonhostpi / temp-ironpython.ps1
Last active July 8, 2025 16:53
Setup Temp IronPython
# See https://github.com/IronLanguages/ironpython3/pull/1957#discussion_r2187237475
& {
$ironpython = 'https://raw.githubusercontent.com/IronLanguages/ironpython3/main/eng/scripts/Install-IronPython.ps1'
$returns = @{ path = "$env:TEMP\$([guid]::NewGuid().ToString())" }
& {
"Installing IronPython to temp ('$($returns.path)')..."
& ([scriptblock]::Create((iwr `
@anonhostpi
anonhostpi / python.ps1
Created July 2, 2025 02:07
Embedding IronPython Demo
$url = 'https://raw.githubusercontent.com/anonhostpi/ironpython3/iex-web-support/eng/scripts/Install-IronPython.ps1'
iex ((New-Object System.Net.WebClient).DownloadString($url))
Import-Module ".\IronPython.dll"
& {
[IronPython.Hosting.Python]::CreateEngine().
CreateScriptSourceFromString("print('Hello from embedded IronPython!')").
Execute()
}
@anonhostpi
anonhostpi / simgeom.ksy
Created September 7, 2024 16:06
A Kaitai Struct for DBPF Geom Entries
meta:
id: geom
file-extension: geom
endian: le
imports:
- path/to/mtnf.ksy
seq:
- id: header
type: header
- id: shader