Skip to content

Instantly share code, notes, and snippets.

View felixeichler's full-sized avatar

Felix Eichler felixeichler

View GitHub Profile
import { useMouse } from '@uidotdev/usehooks';
import * as React from 'react';
interface Positions {
/* Sub-menu height */
h: number;
/* Mouse x */
mouseX: number;
/* Mouse y */
mouseY: number;
@felixeichler
felixeichler / levenshtein.ts
Last active October 9, 2024 10:38 — forked from andrei-m/levenshtein.js
Levenshtein distance between two given strings implemented in JavaScript and usable as a Node.js module
/**
* Computes the Levenshtein distance between two strings (a number that tells you how different two strings are).
* The higher the number, the more different the two strings are.
* Original source: https://gist.github.com/andrei-m/982927/0efdf215b00e5d34c90fdc354639f87ddc3bd0a5
*/
const getLevenshteinDistance = (a: string, b: string): number => {
if (a.length == 0) return b.length;
if (b.length == 0) return a.length;
const matrix = [];