Skip to content

Instantly share code, notes, and snippets.

View ycmjason's full-sized avatar
😆

YCM Jason ycmjason

😆
View GitHub Profile
@ycmjason
ycmjason / .prettierrc.json
Created October 26, 2023 09:54
Best Prettier Config In The World
{
"printWidth": 100,
"semi": true,
"singleQuote": true,
"trailingComma": "all",
"arrowParens": "avoid"
}
@ycmjason
ycmjason / timeline.md
Last active August 10, 2023 15:05
Life in the UK Test - UK History Timeline
Time Events
50 million years ago The Giant’s Causeway was formed. Located on the north-east coast of Northern Ireland, the Giant’s Causeway is a land formation of columns made from volcanic lava.
@ycmjason
ycmjason / README.md
Created April 16, 2023 08:42
Reasons to hate safari as a frontend developer / Why Safari is the new IE

Reasons to hate safari as a frontend developer / Why Safari is the new IE

This is an on-going list of things that I constantly find missing in Safari, (and possibly ways to work around them)

RegExp Positive/Negative Lookbehind

I cannot believe my eyes when positive/negative lookbehind is still not available on safari. Here is how you can work around it:

Instead of

@ycmjason
ycmjason / example-usage.ts
Created April 11, 2023 06:36
A fancy way to type your react router config
const routes = [
{
path: '/',
element: <App />,
errorElement: <CircularProgress />,
children: [
{
index: true,
element: <LandingPage />,
},
@ycmjason
ycmjason / AppLink.vue
Last active April 4, 2023 22:22
A totally over-engineered way to make a """type-safe""" `AppLink` with vue-router
@ycmjason
ycmjason / groupBy.ts
Created March 23, 2023 23:23
A beautiful implementation of groupBy in typescript
export const groupBy = <X, K extends PropertyKey>(
getKey: (x: X) => K,
xs: readonly X[],
): { readonly [k in K]?: readonly (X | undefined)[] } => {
const grouped: { [k in K]?: (X | undefined)[] } = {};
for (const x of xs) {
const key = getKey(x);
grouped[key] ??= [];
// we have initialised ^ so grouped[key] won't be undefined
@ycmjason
ycmjason / machine.js
Created January 19, 2023 12:09
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@ycmjason
ycmjason / removeKeyRecursive.ts
Created November 26, 2020 17:11
removeKeyRecursive.ts
type OmitRecursive<T extends object, O extends string> = Omit<
{ [K in keyof T]: T[K] extends object ? OmitRecursive<T[K], O> : T[K] },
O
>
const removeKeysRecursive = <T extends object, K extends readonly string[]>(
object: T,
keys: K,
): OmitRecursive<T, K[number]> => {
@ycmjason
ycmjason / BASIC_CONFIG.md
Last active October 1, 2019 10:57
Basic Configs

This file contains some config files.

export const requestAnimationFrameRecursive = (
fn: (
highResTimestamp: DOMHighResTimeStamp,
additionalInfo: {
stop: () => void;
totalTimelapse: DOMHighResTimeStamp;
timelapseSinceLast: DOMHighResTimeStamp;
},
) => void,
o?: {