Skip to content

Instantly share code, notes, and snippets.

View Fasteroid's full-sized avatar
🪐

Fasteroid

🪐
View GitHub Profile
@Fasteroid
Fasteroid / module_tree_explorer.py
Created July 17, 2024 16:52
Ever been in an unknown python environment and needed to learn more about it?
import sys
import pkgutil
import importlib
def get_all_modules():
all_modules = set(sys.modules.keys())
# Add all discoverable modules
for module in pkgutil.iter_modules():
all_modules.add(module.name)
@Fasteroid
Fasteroid / DegenerateTypescript.ts
Created June 12, 2024 22:27
Ever wanted to write horrible type-unsafe code without using 𝚊𝚗𝚢 or 𝚞𝚗𝚔𝚗𝚘𝚠𝚗 ?
type Fruit = {
name: string
color: string
sweetness: number
}
type Apple = Fruit & {
variety: string
color: "red" | "green" | "yellow"
}
@Fasteroid
Fasteroid / TypeSafeTree.ts
Created June 12, 2024 14:30
Ever needed to define a tree-like type in TypeScript with strict rules about what's on each level?
// PLEASE CREDIT EVERYONE IN HERE IF YOU USE THIS PLEASE AND THANKS 🙏🙏🙏
// https://itnext.io/implementing-arithmetic-within-typescripts-type-system-a1ef140a6f6f
// These types let you do (buggy) arithmetic within typescript's type system
type BuildTuple<L extends number, T extends any[] = []> =
T extends { length: L } ? T : BuildTuple<L, [...T, any]>;
type Length<T extends any[]> =
T extends { length: infer L } ? L : never;
@Fasteroid
Fasteroid / AngularThemeExposer.scss
Created May 22, 2024 18:48
Ever wondered how to expose your entire Angular Material theme as normal CSS variables?
@use 'sass:map';
@use '@angular/material' as mat;
@include mat.core();
$my-app-primary: mat.define-palette(mat.$indigo-palette);
$my-app-accent: mat.define-palette(mat.$pink-palette);
$my-app-warn: mat.define-palette(mat.$amber-palette);
$my-app-theme: mat.define-light-theme(
(
@Fasteroid
Fasteroid / StateEmitter.ts
Last active July 11, 2024 19:39
Ever wanted an EventEmitter you can't miss if you subscribe late?
import { EventEmitter } from "@angular/core";
import { Subscription } from "rxjs";
export class StateEmitter<T> extends EventEmitter<T> {
private ready: boolean = false;
private snapshot: T | undefined = undefined;
get value() { return this.snapshot; }
@Fasteroid
Fasteroid / ParallelUtils.cs
Last active July 3, 2024 19:21
Some C# utilities for parallelization
using System.Collections.Generic;
using System.Threading.Tasks;
using System;
using System.Linq;
namespace Fasteroid {
public static class ParallelUtils {
// ------------ Polyfill for older versions of C# ------------
/*
Shadertoy '84 by Fasteroid
Inspired by Robb Owen's "SynthWave '84" theme for VSCode
Revision 2
*/
@-moz-document domain("shadertoy.com") {
:root {
--site-gutter: #171520;
--site-bg: #241b2f;
--site-text: #ffffffe6;
@Fasteroid
Fasteroid / webassign-dark-theme.css
Last active September 6, 2023 08:29
Dark theme for Cengage WebAssign
/*
WebAssign Dark Theme by Fasteroid
Revision 11
*/
@-moz-document url-prefix("https://www.webassign.net/web/Student") {
.mainContainerLayout {
display: grid;
min-height: 100%;
grid-template-rows: auto 1fr auto;
background: #222;
@Fasteroid
Fasteroid / desmos-dark-theme.css
Last active September 30, 2021 15:35
Dark Theme for Desmos Graphing Calculator
/*
Desmos Dark Theme by Fasteroid
Revision 16
*/
@-moz-document url-prefix("https://www.desmos.com/calculator") {
.dcg-exppanel {
background: rgb(35,35,35) !important;
}
.dcg-calculator-api-container #graph-container .dcg-container {
font-size: 100%;