Skip to content

Instantly share code, notes, and snippets.

View jonathontoon's full-sized avatar
🏴

Jonathon Toon jonathontoon

🏴
View GitHub Profile
@KristofferEriksson
KristofferEriksson / useLocation.ts
Created February 11, 2024 16:44
A React Typescript hook that provides real-time geolocation data, complete with heading and speed metrics
import { useEffect, useState } from "react";
interface LocationOptions {
enableHighAccuracy?: boolean;
timeout?: number;
maximumAge?: number;
}
interface LocationState {
coords: {
@iam4722202468
iam4722202468 / python
Created August 28, 2021 04:22
Free Flow Puzzle Generator
import random
paths = {}
SIZE = 7
def printPuzzle():
puzzle = []
for x in range(0, SIZE):

Saved for my personal reference, all content belongs to codetheory.in

Controlling the Frame Rate with requestAnimationFrame

Limiting the frame rate while using requestAnimationFrame can be a common want especially when coding Games where you want your animations and mechanics to not exceed a particular mark of frames per second. Let’s go through 2 ways of doing it.

Quick and Easy Way

Using setTimeout inside the rAF method is an easy way.