Skip to content

Instantly share code, notes, and snippets.

@hirbod
hirbod / LeanText.tsx
Last active November 26, 2024 12:38
React Native LeanView and LeanText component
import { type ComponentType, createElement, forwardRef } from 'react'
import type { TextProps } from 'react-native'
// uncomment for NativeWind support
//import { cssInterop } from 'nativewind'
const LeanText = forwardRef((props, ref) => {
return createElement('RCTText', { ...props, ref })
}) as ComponentType<TextProps>
@stevoland
stevoland / babel-plugin-react-hook-form-no-memo.md
Last active December 6, 2024 09:08
babel-plugin-react-hook-form-no-memo

react-hook-form (as of v7.53) may behave incorrectly when user code is compiled with react-compiler.

This babel plugin can be applied before the compiler to opt-out all functions which reference useForm by inserting the "use no memo" directive.

Only supports using the named export:

// worky
import { useForm } from 'react-hook-form
const Component = () =&gt; {
@khalidx
khalidx / node-typescript-esm.md
Last active November 14, 2024 08:26
A Node + TypeScript + ts-node + ESM experience that works.

The experience of using Node.JS with TypeScript, ts-node, and ESM is horrible.

There are countless guides of how to integrate them, but none of them seem to work.

Here's what worked for me.

Just add the following files and run npm run dev. You'll be good to go!

package.json

@hyperupcall
hyperupcall / settings.jsonc
Last active September 19, 2024 16:20
VSCode config to disable popular extensions' annoyances (telemetry, notifications, welcome pages, etc.)
// I'm tired of extensions that automatically:
// - show welcome pages / walkthroughs
// - show release notes
// - send telemetry
// - recommend things
//
// This disables all of that stuff.
// If you have more config, leave a comment so I can add it!!
{
@badsyntax
badsyntax / paths.ts
Last active October 27, 2024 03:29
Fast & Flexible TypeScript dot notation key extraction that supports nested objects to a depth of 10
/**
* Example usage:
*
* // default depth of 3: (fastest)
* type keys = Paths<SomeNestedObject> // returns "property" | "nested.property" | "nested.nested.property"
*
* // depth of 10: (can be slow)
* type keys = Paths<SomeNestedObject, 10>
*
* // depth of 10 with keys of type string and number: (slowest)
@mcollina
mcollina / principles.md
Last active May 18, 2023 18:27
Matteo's Technical principles

Matteo Technical Principles

1. Conway’s Law is paramount.

Any organization that designs a system (defined broadly) will produce a design whose structure is a copy of the organization's communication structure.

In order to design a piece of software we need to “design” the team that is going to produce it.

2. Developer Experience is key to productivity

@badsyntax
badsyntax / s3Etag.ts
Last active December 19, 2021 07:10
Generate an S3 ETAG for multipart uploads in Node.js
/**
* Generate an S3 ETAG for multipart uploads in Node.js
* An implementation of this algorithm: https://stackoverflow.com/a/19896823/492325
* Author: Richard Willis <willis.rh@gmail.com>
*/
import fs from 'node:fs';
import crypto, { BinaryLike } from 'node:crypto';
const defaultPartSizeInBytes = 5 * 1024 * 1024; // 5MB

Cheat sheet: public prototype methods and accessors

const getterKey = Symbol('getterKey');
const setterKey = Symbol('setterKey');
const syncMethodKey = Symbol('syncMethodKey');
const syncGenMethodKey = Symbol('syncGenMethodKey');
const asyncMethodKey = Symbol('asyncMethodKey');
const asyncGenMethodKey = Symbol('asyncGenMethodKey');
.closed.octicon.octicon-issue-closed {
color: var(--color-danger-fg) !important;
}
.gh-header-meta .State--merged, .State--merged[title="Status: Closed"] {
background-color: var(--color-danger-fg) !important;
}
.TimelineItem-badge.color-bg-done-emphasis {
background-color: var(--color-danger-fg) !important;
@davidfowl
davidfowl / .NET6Migration.md
Last active December 2, 2024 11:08
.NET 6 ASP.NET Core Migration