Skip to content

Instantly share code, notes, and snippets.

View roderick-martina's full-sized avatar

roderick martina roderick-martina

  • Zoetermeer, The Netherlands
View GitHub Profile
@roderick-martina
roderick-martina / useUndo.ts
Created February 18, 2024 11:27 — forked from KristofferEriksson/useUndo.ts
A React hook that enhances your components with powerful undo/redo functionality
import { useCallback, useEffect, useRef, useState } from "react";
interface UseUndoHook<T> {
value: T;
onChange: (newValue: T) => void;
undo: () => void;
redo: () => void;
clear: () => void;
canUndo: boolean;
canRedo: boolean;
@roderick-martina
roderick-martina / simple-pagination.js
Created April 1, 2020 08:47 — forked from kottenator/simple-pagination.js
Simple pagination algorithm
// Implementation in ES6
function pagination(c, m) {
var current = c,
last = m,
delta = 2,
left = current - delta,
right = current + delta + 1,
range = [],
rangeWithDots = [],
l;
@roderick-martina
roderick-martina / 0_reuse_code.js
Created May 21, 2017 10:48
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console