View regex-ignored-indexes.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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: |
View inference.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function identity<T>(arg: T): T { | |
return arg; | |
} | |
const val = identity(1 as const); | |
// ^ 1 | |
// ---------------------- Works with classes too --------------------------------------------- | |
class IdentityWithMeta<T> { |
View loosen.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* ["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>] |
View package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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" |
View app.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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/> |
View setTimeoutGrossPolyfill.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
View after.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... | |
let theme = document.documentElement.className; | |
toggleButtonIcon(theme); | |
themeToggleBtn.addEventListener('click', () => { | |
theme = theme === 'light' ? 'dark' : 'light'; | |
toggleButtonIcon(theme); | |
}); |
View minimal-angular-from-scratch.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Zone { | |
constructor() { | |
this.tasks = []; | |
} | |
// Add a new task to the zone | |
add(task) { | |
this.tasks.push(task); | |
} |
View tabs-border-roundness.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ul.tabs__tab-list:has(> .tabs__tab:first-child:not([aria-selected="true"])) | |
~ .tabs__tab-panel { | |
border-radius: var(--code-block-corner-radius_inner); | |
} | |
ul.tabs__tab-list:has(> .tabs__tab:first-child[aria-selected="true"]) | |
~ .tabs__tab-panel { | |
border-radius: 0 var(--code-block-corner-radius_inner) | |
var(--code-block-corner-radius_inner); | |
} |
View react-add-children-to-component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ComponentType, PropsWithChildren } from "react"; | |
import { Text } from "react-native"; | |
import { Wrapper } from "aws-amplify-react-native"; | |
// 🪄 This is the magic | |
type AddChildrenToComponent<T> = T extends ComponentType<infer P> | |
? ComponentType<PropsWithChildren<P>> | |
: never; | |
const WrapperWithChildren = Wrapper as AddChildrenToComponent<typeof Wrapper>; |
NewerOlder