Skip to content

Instantly share code, notes, and snippets.

@jrson83
jrson83 / todo.md
Last active September 27, 2024 18:36
Nelaya todo

Todo

Import

Produkte & SEO Urls

  • Import automatisch
  • Als Storefront importiert
  • SEO URLs überprüfen
  • Lieferzeit Feld manuell
@jrson83
jrson83 / lazy.ts
Created April 13, 2024 19:44 — forked from goran-peoski-work/lazy.ts
Dynamic import of omponent
import React, { ComponentType, LazyExoticComponent } from "react";
type Transformer = <T>(name: keyof T) => (module: T) => { default: T[keyof T] };
const transformer: Transformer = (
(name) => (module) => ({ default: module[name] })
);
/*
analyze reserved properties from bundled dts for terser
$ pnpm tsm analyze.ts src/*.{ts, tsx} -i src/index.ts
{
"reservedProperties": [
"result",
"value",
"pubTypeKey",
"ikey",
@jrson83
jrson83 / program.ts
Created March 12, 2024 22:36
typescript: how to infer array of generic objects as union
/**
* Helper type-level function to expand a given type to show all of its inferred fields when hovered.
*
* @see {@link https://stackoverflow.com/a/57683652}
* @see {@link https://gist.github.com/trevor-atlas/b277496d0379d574cadd3cf8af0de34c}
*/
type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never
/**
* Represents an argument.
@jrson83
jrson83 / file.ts
Last active March 6, 2024 05:29
typescript-discriminated-unions
// https://dev.to/darkmavis1980/what-are-typescript-discriminated-unions-5hbb
export type Expand<T> = T extends infer O ? { [K in keyof O]: O[K] } : never
export type ParseArgsArgumentConfig = Expand<
{
required?: boolean
desc?: string
} & (
| {
@jrson83
jrson83 / expand.ts
Created February 13, 2024 02:43 — forked from msichterman/expand.ts
use conditional type inference to "copy" a type T into a new type variable O and then an identity-like mapped type which iterates through the copied type's properties. The conditional type inference is conceptually a no-op, but it's used to distribute union types and to force the compiler to evaluate the "true" branch of the conditional (if you …
// https://stackoverflow.com/a/69288824
export type Expand<T> = T extends (...args: infer A) => infer R
? (...args: Expand<A>) => Expand<R>
: T extends infer O
? { [K in keyof O]: O[K] }
: never;
export type ExpandRecursively<T> = T extends (...args: infer A) => infer R
? (...args: ExpandRecursively<A>) => ExpandRecursively<R>
@jrson83
jrson83 / isz-glitch-fix-test.md
Created February 4, 2024 23:25
isz-glitch-fix-test

New Quick Code

[Isz Glitch Cure]
80010008 03000000 - Searches for 8 bytes of 03 00 00 00 05 00 01 00 once using Default Offset
05000100 00000000
92000000 00000DD1 - Adjusts the pointer offset by adding a value of 3537 dec = DD1 hex to the pointer
D8000000 020130FF - Tests and skips the following two code lines if 2 bytes from pointer equal `FF 30`
D8000000 0103C0FF - Tests and skips the following code line if 2 bytes from pointer equal less than `FF C0`
08000001 00000030 - Writes 1 byte with 1 offset from pointer, replacing a value less than `C0` with `30` (partial Isz glitch fix)
interface Messenger {
sendText: () => void;
sendFile: () => void;
checkStatus?: () => void;
}
type RequiredFields<T> = {
[K in keyof T as T[K] extends Required<T>[K] ? K : never]: T[K];
};
@jrson83
jrson83 / index.ts
Created January 28, 2024 23:08 — forked from vmlf01/index.ts
TypeScript training - module 2 sample
// sample shopping cart data
const shopping_cart = {
items: [
{ id: '1', name: 'T-Shirt Game of Thrones', size: 'XL', taxCode: 'IVA23', quantity: 1, unitPrice: 24.99 },
{ id: '2', name: 'T-Shirt Big Bang Theory', size: 'L', taxCode: 'IVA23', quantity: 2, unitPrice: 12.50 },
],
subTotal: 0,
tax: 0,
total: 0,
};
const { PerformanceObserver, performance } = require('perf_hooks');
let arraySize = 1000000;
let iterations = 100;
console.log("Starting performance test with %d array size and %d iterations", arraySize, iterations);
let values = {
FORIN: 0,
FOROF: 0,