Skip to content

Instantly share code, notes, and snippets.

### Keybase proof
I hereby claim:
* I am frogglet on github.
* I am frogglet (https://keybase.io/frogglet) on keybase.
* I have a public key ASBuYBAtUDzULSt5n2B_X7ynA9jcJIPVIe7qZVCThWJqwAo
To claim this, I am signing this object:
@Frogglet
Frogglet / index.js
Created November 28, 2018 22:18
Synchronously executing async api requests while avoiding rate-limiting
// utility function to wait for x milliseconds using async/await
const wait = ms => new Promise(res => setTimeout(res, ms));
let API_REMAINING = 60; // number of remaining API hits allowed
let API_RESET = 0; // unix epoch timestamp for when API_REMAINING will be reset
const queue = []; // queue of jobs to manage
// this is the main function that infinitely loops to process the queue
async function process_queue(){
@Frogglet
Frogglet / example.js
Created August 9, 2016 03:04 — forked from kirbysayshi/LICENSE
Hierarchical Spatial Hash Grid: extremely efficient spatial hashing for collision detection between objects of any size! This is an implementation in JS as described in http://www10.informatik.uni-erlangen.de/~schornbaum/hierarchical_hash_grids.pdf
// The only thing HSHG expects a collidable object to have is a getAABB() method that
// returns an object with two properties, min and max, that should both have a single
// array with two numbers as coordinates. For example, an object at 10, 10 and
// height/width of 100 would return { min: [10, 10], max: [110, 110] }
function Vertex(args /*x, y, radius*/){
var argProp;
for(argProp in args){
if(args.hasOwnProperty(argProp)){