Skip to content

Instantly share code, notes, and snippets.

@yandzee
yandzee / useMouseDrag.ts
Created January 30, 2026 11:53
useMouseDrag
import React, { useCallback, useLayoutEffect, useRef } from 'react';
import _ from 'lodash';
import { toPageCoords } from '~/ui/utils';
import { XY } from '~/domain/geometry';
export interface DragCoords {
diff: {
x: number;
@yandzee
yandzee / index.js
Last active September 3, 2020 02:35
Code retry with promises
// Author: Renat Tuktarov ([email protected])
const retry = function(fn, prev) {
return new Promise((current, reject) => {
const resolve = _ => (prev && prev()) || current();
fn(resolve, delay => {
setTimeout(_ => {
retry(fn, resolve);
}, delay);