Skip to content

Instantly share code, notes, and snippets.

Ordered State Handler

Ordered state handlers keep track of state through a known procedure. You can provide callbacks for when an ordered state handler enters a state, exits a state, or when the state advances.

Basic Usage

var osh = orderedStateHandler(['1', '2', '3', '3.abc', '3.xyz','4']);
@stutrek
stutrek / README.md
Last active October 18, 2020 22:31
iframe memory test

iframe memory test

This is a simple test of memory reclamation in nested iframes. It demonstrates that setting the top level iframe's src to about:blank and removing it from the DOM is sufficient to allow the browser to reclaim all memory used in child iframes, even with different domains.

Scripts (both inline and remote), DOM elements, event listeners, timeouts, and intervals are all cleared from memory.

Usage

Add this to your hosts file:

@stutrek
stutrek / pollerapi.js
Created February 3, 2013 19:27
A simple API for a poller.
var poller = new Poller('linescore.json', 15000);
// called when new data is received.
// not called when the same data is returned twice in a row
poller.on('update', function( data ) {
console.log( data );
});
// called on an AJAX error. Polling automatically stops.
poller.on('error', function( error ) {
@stutrek
stutrek / theelementsoftypographicstylesheet.css
Created July 4, 2012 19:04
Elements of Typographic Stylesheet
html.eotss_enabled body {
-webkit-font-feature-settings: 'clig', 'onum';
font-feature-settings: 'clig', 'onum';
}
/* This is slow. Best to put it in a timeout to give the UI time to update. */
html.eotss_enabled.eotss_slow body {
text-rendering: optimizeLegibility;
}