Skip to content

Instantly share code, notes, and snippets.

View morganney's full-sized avatar
🌳

Morgan Ney morganney

🌳
View GitHub Profile
@morganney
morganney / speechsynthesis-memory-leak.html
Created September 16, 2022 20:30
SpeechSynthesis memory leak (onEnd)?
<!doctype HTML>
<html>
<head>
<title>SpeechSynthesis onEnd Counter</title>
</head>
<body>
<h3>How long until the browser crashes?</h3>
<p>On macOS Monterey 12.5.1 (16GB RAM), Chrome, Firefox and Safari all crash at some point (under 200 secs).</p>
<button id="start">start</button>
<button id="stop">stop</button>
@morganney
morganney / speechsynthesis-browser-crash.html
Created September 16, 2022 19:43
SpeechSynthesis Memory Leak?
<!doctype HTML>
<html>
<head>
<title>SpeechSynthesis setInterval Counter</title>
</head>
<body>
<h3>How long until the browser crashes?</h3>
<p>On macOS Monterey 12.5.1 (16GB RAM), Chrome, Firefox and Safari all crash at some point (under 200 secs).</p>
<button id="start">start</button>
<button id="stop">stop</button>
@morganney
morganney / refreshTokenMiddleware.js
Created December 24, 2021 15:08
Express middleware for refreshing an access token with a refresh token
import { TokenSet } from 'openid-client'
import error from 'http-errors'
import debugFactory from 'debug'
const debug = debugFactory('ac:refresh')
/**
* Refreshes an expired token set.
* Requires middleware `oidc` to be called first.
*
* @param {Request} req The express request object
@morganney
morganney / flatten-integer-array.js
Created July 22, 2019 22:21
Flattens an array of integers with arbitrary nesting.
// These are just here for unit testing
const assert = require('assert').strict
const expectedError = {
name: /^TypeError$/,
message: /not an array|only be integers/
}
/**
* Flattens an array of arbitrarily nested integer arrays.
*
@morganney
morganney / example.js
Created December 7, 2018 22:16
Example
import React from 'react';
import PropTypes from 'prop-types';
import { Link } from 'react-router-dom';
import { Button } from '@hivekit/button';
import { Form } from '@hivekit/form';
import { FormattedMessage } from 'react-intl';
import { Field } from 'redux-form';
import coreMessages from 'tio-app/messages';
.cell-styles(@n, @i: 1) when (@i <= @n) {
.cell-@{i} {
width: (100% / @i);
height: (100% / @i);
}
.cell-styles(@n, (@i + 1));
}
.cell-styles(80);
section {
display: flex;
flex-direction: row;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;
box-sizing: border-box;
width: 94vw;
height: 94vw;
max-width: 620px;
<section>
<span class="alive cell-2"></span>
<span class="dead cell-2"></span>
<span class="dead cell-2"></span>
<span class="alive cell-2"></span>
</section>
import React from 'react'
import ReactDOM from 'react-dom'
import Title from './components/title'
import GridSizeSelector from './components/grid-size-selector'
import GameOfLife from './components/game-of-life'
class App extends React.Component {
constructor (props) {
super(props)
@morganney
morganney / spread-operator.js
Created August 2, 2015 23:00
Convert Object with Iterator to an Array with Spread Operator
console.log([...obj]); // ['b', 'symbol', 'bar']