Skip to content

Instantly share code, notes, and snippets.

View etienne-martin's full-sized avatar

Etienne Martin etienne-martin

View GitHub Profile
type AnyFunction = (...args: any[]) => any
function useEvent<T extends AnyFunction>(callback?: T) {
const ref = useRef<AnyFunction | undefined>(() => {
throw new Error("Cannot call an event handler while rendering.")
})
// Or useInsertionEffect if it's React 18
useLayoutEffect(() => {
ref.current = callback
})
@JonnoFTW
JonnoFTW / boggle_solver.js
Last active December 27, 2019 16:01
Javascript boggle solver
/**
* Created by mack0242 on 6/04/17.
*/
var TrieNode = function (parent, value) {
this.parent = parent;
this.children = new Array(26);
this.isWord = false;
if (parent !== undefined) {
parent.children[value.charCodeAt(0) - 97] = this;
}
@JALsnipe
JALsnipe / crc32.swift
Created October 11, 2016 15:14 — forked from MaddTheSane/crc32.swift
crc32 implemented in Swift (Swift 3)
//
// crc32.swift
// SuperSFV
//
// Created by C.W. Betts on 8/23/15.
//
//
/* crc32.swift -- compute the CRC-32 of a data stream
Copyright (C) 1995-1998 Mark Adler
Copyright (C) 2015 C.W. "Madd the Sane" Betts
@PurpleBooth
PurpleBooth / README-Template.md
Last active July 25, 2024 06:10
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@ksafranski
ksafranski / Common-Currency.json
Last active July 24, 2024 16:40
Common Currency Codes in JSON
{
"USD": {
"symbol": "$",
"name": "US Dollar",
"symbol_native": "$",
"decimal_digits": 2,
"rounding": 0,
"code": "USD",
"name_plural": "US dollars"
},
//
// Regular Expression for URL validation
//
// Author: Diego Perini
// Created: 2010/12/05
// Updated: 2018/09/12
// License: MIT
//
// Copyright (c) 2010-2018 Diego Perini (http://www.iport.it)
//