Skip to content

Instantly share code, notes, and snippets.

View z2lai's full-sized avatar

Zheng Lai z2lai

View GitHub Profile

The provided TypeScript code defines a utility type RecursivePartial. This type is used to create a version of an existing type, but with all of its properties (and their nested properties) made optional and able to be partially provided.

The RecursivePartial type is defined as a mapped type that iterates over all properties (Prop) of a given type (Type):

export type RecursivePartial<Type> = {
  [Prop in keyof Type]?: ...
};
@thebuilder
thebuilder / hookWithRef.js
Last active January 16, 2024 13:50
Hook with ref callback
import React, {useCallback, useRef} from 'react'
function useHookWithRefCallback() {
const ref = useRef(null)
const setRef = useCallback(node => {
if (ref.current) {
// Make sure to cleanup any events/references added to the last instance
}
if (node) {

FWIW: I (@rondy) am not the creator of the content shared here, which is an excerpt from Edmond Lau's book. I simply copied and pasted it from another location and saved it as a personal note, before it gained popularity on news.ycombinator.com. Unfortunately, I cannot recall the exact origin of the original source, nor was I able to find the author's name, so I am can't provide the appropriate credits.


Effective Engineer - Notes

What's an Effective Engineer?

@AdamMarsden
AdamMarsden / sassas.md
Last active December 8, 2025 15:31
Sass Architecture Structure

Sass Architecture Structure

sass/
|
|– base/
|   |– _reset.scss       # Reset/normalize
|   |– _typography.scss  # Typography rules
|   ...                  # Etc…
|
@OnesimusUnbound
OnesimusUnbound / quote.txt
Last active September 3, 2024 12:53
Programming Quotes
[T]he difference between a bad programmer and a
good one is whether he considers his code or his
data structures more important. Bad programmers
worry about the code. Good programmers worry about
data structures and their relationships.
-- Linus Torvalds
~~~
Clarity and brevity sometimes are at odds.
When they are, I choose clarity.
-- Jacob Kaplan-Moss