Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Streaming json writer. Call generator to set up,
* file isn't opened until you call send().
*
* Pass objects with send until you're done. You can call send(null) to close
* or let the finally finish up and close out the file at end of execution.
*
* @param string $file - File path to write to
@edhaase
edhaase / CacheStampedeAvoider.js
Created August 7, 2019 18:28
Prevent cache stampedes by tracking pending requests
/**
* Example cache class that uses promises to resolve.
*/
class Cache {
constructor() {
this.store = {};
}
async get(key) {
return this.store[key];
}
/**
* MiniMap.js - MiniMap for the game Adventure.Land
*
* Features:
* Event emitter
* Drag to reposition
* Numpad plus/minus to zoom
* Toggle visibility to show or hide
* Left click to interact with markers, right click to smart move
* Easily extensible