Skip to content

Instantly share code, notes, and snippets.

View Fasteroid's full-sized avatar
🪐

Fasteroid

🪐
View GitHub Profile
@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 February 20, 2025 19:18
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.
*/
@Fasteroid
Fasteroid / memoryleak.js
Created January 14, 2025 20:07
Memory leak via improper use of FinalizationRegistry
( () => {
let custodian = new FinalizationRegistry((x) => console.log(x))
let leak = {haha: "funni"}
custodian.register(leak, {leak})
} )()
@Fasteroid
Fasteroid / __TypewriterControllers.tst
Last active January 28, 2025 17:58
The ultimate Typewriter template for your MVC controllers!
${
using Typewriter.Extensions.Types;
using System.Text.RegularExpressions;
using System.Reflection;
/*
__TypewriterControllers.tst v1.1.1 - https://gist.github.com/Fasteroid
Features:
- Automatically imports type dependencies from the same assembly
@Fasteroid
Fasteroid / __TypewriterModels.tst
Last active January 28, 2025 17:47
The ultimate Typewriter template for C# files that have models in them.
${
using Typewriter.VisualStudio;
static ILog console;
Template(Settings settings){
console = settings.Log;
}
/*
__TypewriterModels.tst v1.2.0 - https://gist.github.com/Fasteroid
@Fasteroid
Fasteroid / angular.dev.accessible.css
Last active November 12, 2024 20:08
Makes the new Angular docs site more accessible by getting rid of gradients on text.
@-moz-document domain("angular.dev") {
/*
Angular.dev "accessible" edit
Revision 2
*/
.docs-dark-mode, .docs-light-mode {
--red-to-pink-horizontal-gradient: var(--hot-red);
--red-to-pink-to-purple-horizontal-gradient: var(--vivid-pink);
--pink-to-highlight-to-purple-to-blue-horizontal-gradient: var(--electric-violet);
@Fasteroid
Fasteroid / Maps.ts
Last active September 16, 2024 19:26
Variations of javascript's "Map"
/**
* Like a normal {@link Map}, but if you get a key that doesn't exist, it will automatically make it exist.
*/
export class AutoMap<K, V> extends Map<K, V> {
/**
* @param computer Instantiates default value for keys that don't exist
*/
public constructor( private computer: (key: K) => V ){ super(); }
public override get(key: K): V {
@Fasteroid
Fasteroid / dropschema.sql
Last active September 4, 2024 15:31
Rui Romano's implementation of DROP SCHEMA CASCADE for MSSQL Server
/****** Object: StoredProcedure [dbo].[DropSchema] Script Date: 31/01/2013 16:51:00 ******/
/* https://ruiromanoblog.wordpress.com/2011/01/27/drop-a-sql-server-schema-and-all-objects-related/ */
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
DROP PROCEDURE IF EXISTS [dbo].[DropSchema]
GO
CREATE PROCEDURE [dbo].[DropSchema]
(
@Fasteroid
Fasteroid / white-space.svg
Last active August 29, 2024 18:30
This SVG is not rendered correctly according to the W3C's specifications (if you're on a chromium browser)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Fasteroid
Fasteroid / bracing_spacing.regex
Last active September 19, 2024 20:42
Substitution regex for adding spaces around braces. Works on regex101 but seems broken in Visual Studio...
(""(?>[^""]|\\"")*?"")|(?!\( )(\()(?!\))(\1??(?>(?>""(?>[^""]|\\"")*?"")|.){4,})(\))(?<! \))
$1$2 $3 $4
For use in Visual Studio (.NET Regex Engine)
FEATURES
- Inserts space after opening and before closing parenthesis if contents between parentheses is longer than <x> (4 in this example)
- Does not do anything to strings
- Ignores parentheses that already have space
- Can be used multiple times to hit nested offenders