Skip to content

Instantly share code, notes, and snippets.

View crutchcorn's full-sized avatar
📒
Writing like whoa

Corbin Crutchley crutchcorn

📒
Writing like whoa
View GitHub Profile
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width"/>
</head>
<body style="height: 300vh">
<svg style="position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);"
width="655" height="209" viewBox="0 0 655 209" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M653 207V62C653 28.8629 626.228 2 593.091 2C519.318 2 391.639 2 292.675 2C270.583 2 252.717 19.9124 252.717 42.0038C252.717 63.5378 252.717 81.7221 252.717 81.7221C252.717 81.7221 252.717 81.7221 252.717 81.7221V167C252.717 189.091 234.808 207 212.717 207H2"
stroke="#EAECF0" stroke-width="4" stroke-linecap="round"/>
@crutchcorn
crutchcorn / step-1.ts
Created March 19, 2024 18:53
A basic implementation of Signals from scratch written in 5 minutes for ngConf 2024
function signal<T>(initialValue: T) {
let value: T = initialValue;
function getValue() {
return value;
}
getValue.set = (newValue: T) => {
value = newValue;
}
@crutchcorn
crutchcorn / App.jsx
Created February 25, 2024 20:37
Why does this not preserve the `useRef` value between strict mode runs?
function generateState() {
if (!window.executeCount) {
window.executeCount = 0
}
window.executeCount++
return {
count: window.executeCount,
}
}
@crutchcorn
crutchcorn / installed-apps-winget.txt
Created January 17, 2024 23:30
Apps I have installed on an old Windows device
Polypane 15.0.1 Firstversionist.Polypane 15.0.1 winget
Open Video Downloader 2.5.4 jely2002.youtube-dl-gui 2.5.4 winget
Mullvad VPN 2023.6.0 MullvadVPN.MullvadVPN 2023.6.0 winget
ModernFlyouts (Preview) ModernFlyouts.ModernFlyouts 0.9.3.0 winget
NVM for Windows CoreyButler.NVMforWindows Unknown 1.1.11 winget
Plexamp 4.8.4 Plex.Plexamp 4.8.4 4.9.4 winget
SideQuest 0.10.38 SideQuestVR.SideQuest 0.10.38 0.10.39 winget
GDLauncher 1.1.30 GorillaDevs.GDLauncher 1.1.30 winget
Cisco Webex Meetings Cisco.CiscoWebexMeetings
@crutchcorn
crutchcorn / regex-ignored-indexes.js
Created November 28, 2023 08:36
A method to generate ignored indexes and do partial replacement in a regex
// Given an input
const input = "header 123 {#custom-id}"
// Provide a tranformation of said input that keeps the same length
// IE: "Capitalizing" a title in a markdown file
const transformedInput = input.toUpperCase();
// However, we don't want to transform this regex
// IE: A custom ID
const ignored = ["{#custom-id}"]
// From this, our output should be:
@crutchcorn
crutchcorn / inference.ts
Last active September 10, 2023 22:53
known working examples of TS generics inferencing
function identity<T>(arg: T): T {
return arg;
}
const val = identity(1 as const);
// ^ 1
// ---------------------- Works with classes too ---------------------------------------------
class IdentityWithMeta<T> {
/**
* ["a", "b", "c"] => ["a" | "b" | "c", "a" | "b" | "c", "a" | "b" | "c"]
*
* Assumes keys are unique
*/
export type LoosenTuple<
Arr extends readonly any[],
OriginalArr extends readonly any[] = Arr,
> = Arr extends readonly [unknown, ...infer Tail]
? readonly [OriginalArr[number], ...LoosenTuple<Tail, OriginalArr>]
{
"name": "@mitosis.template/templating-base",
"version": "0.0.1",
"description": "",
"repository": {
"type": "git",
"url": "git+https://github.com/crutchcorn/mitosis-template.git"
},
"bugs": {
"url": "https://github.com/crutchcorn/mitosis-template/issues"
@crutchcorn
crutchcorn / app.component.html
Created June 4, 2023 16:07
Weird framework idea
<button data-on-click="updateCount()">Count</button>
<p>Count: {{count.value}}</p>
<p>Double: {{double.value}}</p>
<p data-if="count.value % 2 === 0">{{count.value}} is even</p>
<p data-if="count.value % 2 !== 0">{{count.value}} is odd</p>
<Child/>
@crutchcorn
crutchcorn / setTimeoutGrossPolyfill.js
Created May 29, 2023 10:04
Eww, a JS-only setTimeout polyfill??
globalThis.setTimeout = (cb, num) => {
const start = Date.now();
function loop() {
return new Promise((resolve) => {
queueMicrotask(() => {
const now = Date.now();
const diff = now - start;
if (diff < num) {
loop()