Skip to content

Instantly share code, notes, and snippets.

View Fasteroid's full-sized avatar
🤖
reject ai, embrace humanity

Fasteroid

🤖
reject ai, embrace humanity
View GitHub Profile
/* HOW TO USE:
1. Paste in chrome console and hit enter
2. Pick a file to paint; it must only use the wplace color palette
3. The first pixel you paint will now spill the chosen file down and to the right
4. Refresh the page to unload the script
*/
window.oldJsonStringify = window.oldJsonStringify ?? JSON.stringify;
JSON.stringify = function(){
@Fasteroid
Fasteroid / superJsonParse.js
Last active September 17, 2026 15:08
Parse json structures which might have strings that are also JSON structures, but recursively. Useful for diffing localstorage entries.
function superJsonParse(json){
let nested = json;
if( typeof json === 'string' ) try {
nested = JSON.parse(json);
}
catch(e){}
if( typeof json === 'object' ) for( [k, v] of Object.entries(nested) ){
nested[k] = superJsonParse(v);
}
/*
traits.ts - Easy ECS for TypeScript, powered by mixins!
Concepts and direction by Fasteroid;
Some TypeScript workarounds provided by Claude Sonnet 5.
*/
type Constructor<ARGS extends unknown[] = any[], TYPE = object> = new (...args: ARGS) => TYPE;
type TraitsMap = { readonly [key: symbol]: Constructor };
const oldJsonStringify = window.oldJsonStringify ?? JSON.stringify;
JSON.stringify = function(){
if( arguments[0]?.season !== undefined ){
arguments[0] = detour(arguments[0])
}
return oldJsonStringify( ...(arguments ?? []) )
}
function detour(n) {
@Fasteroid
Fasteroid / elementpicker.js
Last active April 30, 2026 15:51
created to stealthily inspect an css issue where the devtools overlays alone were enough to perturb it
let lastX = 0;
let lastY = 0;
let sameClicks = 0;
document.addEventListener('click', (e) => {
if( !e.ctrlKey ) return;
if( lastX == e.x && lastY == e.y ){
sameClicks++;
}
else {
sameClicks = 0;
@Fasteroid
Fasteroid / AggregateError2.experiment.ts
Last active March 17, 2026 17:48
Got sidetracked; made something silly.
/**
* Encapsulates multiple errors.\
* When thrown and not caught, throws all child errors (V8) (need to test in other JavaScript engines)
*
* Not to be confused with the native {@linkcode window.AggregateError | AggregateError}
*/
export class AggregateError2 extends Error {
/** List of all errors. */
public readonly errors: readonly Error[] = [];
export class Fire {
private timeout: number = -1;
private callbacks: (() => void)[] = [];
public refreshDuration( time: number ){
window.clearTimeout( this.timeout );
this.timeout = window.setTimeout( () => this.burnout(), time )
}
@Fasteroid
Fasteroid / MultipleInheritance.ts
Last active May 7, 2025 14:33
Multiple inheritance! The holy grail of programming!
type Class = (abstract new (...args: any) => any)
function pickFallback(sources: any[], prop: string | number | symbol) {
for (let fallback of sources) {
if( prop in fallback ){
return fallback;
}
}
return undefined;
}
@Fasteroid
Fasteroid / infinity.sql
Last active February 7, 2025 17:40
Generates ridiculous numbers of rows in Microsoft SQL Server
-- This query generates a list of as many numbers as you want, for Microsoft SQL Server.
DECLARE @Quantity INT = 100000; -- how many to generate
DECLARE @Growth INT = 10; -- exponential growth rate
WITH base AS (
SELECT number
FROM master..spt_values
WHERE type = 'P'
AND number < @Growth
@Fasteroid
Fasteroid / metaprogramming.ts
Last active June 9, 2026 15:29
Some random, probably inadvised things you can do with TypeScript's type system.
/**
* WARNING!
* Just because you can doesn't mean you should.
*
* It's not very hard to create types with exponential (or worse!) time complexity.
* These can create serious issues at build time, such as running out of memory.
* Use caution when doing metaprogramming like this. Nothing is truly free.
*
* This file is best viewed in an environment with intellisense.
*/