Skip to content

Instantly share code, notes, and snippets.

@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;
}
@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 / 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:

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']);
var ItemView = require('marionette').ItemView;
import React from 'react';
import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import store from 'app/store';
class MarionetteContainer extends React.Component {
render () {
// in place array unique
function unique (arr) {
var i = 0;
var end = arr.length - 1;
while (i < end) {
var item = arr[i];
var index = arr.lastIndexOf(item, end);
if (index > i) {
@stutrek
stutrek / setup_whitespace
Created December 6, 2016 15:31
git whitespace config
#!/bin/bash
Smudge=$(git config --global filter.tabspace.smudge)
echo $Smudge;
if [ "$Smudge" == '' ]; then
git config --global filter.tabspace.smudge 'unexpand -t 4'
git config --global filter.tabspace.clean 'expand -t 4'
@stutrek
stutrek / stop_animations.html
Created November 29, 2017 16:06
A style tag that will stop all animations and transitions
<style>
* {
transition-duration: 0 !important;
animation-duration: 0 !important;
}
</style>
@stutrek
stutrek / machine.js
Created October 14, 2019 22:36
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
@stutrek
stutrek / machine.js
Last active October 26, 2019 16:03
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions