Skip to content

Instantly share code, notes, and snippets.

View lishine's full-sized avatar
🎯
Focusing

Pavel Ravits lishine

🎯
Focusing
View GitHub Profile
@jdegenstein
jdegenstein / build123d-OCP.code-snippets
Last active January 25, 2024 02:44
VSCode Snippet for build123d + OCP CAD Viewer modeling / speed running
{
// Place your global snippets here. Each snippet is defined under a snippet name and has a scope, prefix, body and
// description. Add comma separated ids of the languages where the snippet is applicable in the scope field. If scope
// is left empty or omitted, the snippet gets applied to all languages. The prefix is what is
// used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders.
// Placeholders with the same ids are connected.
// Example:
//
// recommended to bind "Snippets: Fill file with Snippet" to e.g. CTRL + ALT + N
@Aslemammad
Aslemammad / mutableSource.tsx
Last active March 13, 2024 13:03
Consistent version of useMutableSource.
// Consistent version of `useMutableSource`, Inspired by https://github.com/pmndrs/valtio/blob/master/src/useMutableSource.ts
import { useEffect, useRef, useState } from 'react';
const TARGET = Symbol('target');
const GET_VERSION = Symbol('getVersion');
export type Source<TargetType extends any, VersionType extends any> = {
[TARGET]: TargetType;
[GET_VERSION]: (target: TargetType) => VersionType;
};