Skip to content

Instantly share code, notes, and snippets.

View mrienstra's full-sized avatar

Michael Rienstra mrienstra

  • Olympic Peninsula, WA
View GitHub Profile
await new Promise(function (resolve) {
setTimeout(function () {
resolve();
}, 1000);
});
// ... Can be shortened to:
await new Promise(function (resolve) {
setTimeout(resolve, 1000);
@mrienstra
mrienstra / unregisterServiceWorkers.js
Created February 4, 2018 22:10
Unregister service workers, verbose
navigator.serviceWorker.getRegistrations().then(function (registrations) {
if (!registrations.length) {
console.log('No serviceWorker registrations found.')
return
}
for(let registration of registrations) {
registration.unregister().then(function (boolean) {
console.log(
(boolean ? 'Successfully unregistered' : 'Failed to unregister'), 'ServiceWorkerRegistration\n' +
(registration.installing ? ' .installing.scriptURL = ' + registration.installing.scriptURL + '\n' : '') +
@mrienstra
mrienstra / Rearrange Desktop Icons.scpt
Last active January 11, 2024 15:51
Rearranges Desktop icons to flow from left to right, top to bottom.
-- https://gist.github.com/mrienstra/8330528
-- Based on http://www.tuaw.com/2012/12/24/applescript-desktop-icon-race/
-- Inspired by http://namesakecomic.com/comic/happy-new-year-from-namesake/#comment-1182035013
-- Rearranges Desktop icons to flow from left to right, top to bottom.
-- To have this run automatically every time files are added or removed from the Desktop, set this script to run as a Desktop "Folder Action". (See https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/reference/ASLR_folder_actions.html )
-- This is currently a rough proof-of-concept. It has only been tested with OS X 10.8.5 (Mountain Lion).
@mrienstra
mrienstra / dist > Counter.232eec27.js
Created November 10, 2022 06:58
Astro Svelte duplication test
/* empty css */ function L() {}
function nt(t, e) {
for (const n in e) t[n] = e[n];
return t;
}
function Q(t) {
return t();
}
function z() {
return Object.create(null);
const colors = {
grey: 90,
red: 31,
yellow: 33,
blue: 34,
purple: 35,
cyan: 36,
white: 37,
};
// preview controller
(() => {
interface MarkdownConfig {
scrollSync?: boolean;
}
class PreviewController {
/**
* Scroll map that maps buffer line to scrollTops of html elements
*/
@mrienstra
mrienstra / astro_markdown_files.md
Last active September 19, 2022 19:30
Astro .md files
@mrienstra
mrienstra / README
Created October 3, 2012 23:48
Demo of hacks to prevent scroll-triggered navigation
The first approach use several layers. It takes advantage of the fact that you cannot trigger a "back" unless BODY's "scrollLeft" is 0. The disadvantage to this approach is the appearance of an additional horizontal scrollbar. There may also be some subtle side-effects to using "position: fixed".
1. The HTML element acts as a container for the BODY element, and uses "overflow: scroll".
2. The BODY element is 2 pixels wider than the page, so it can scroll 1px in either direction when its "scrollLeft" is 1 (neutral position).
3. We bind to the "onscroll" event of the window, and reset BODY's "scrollLeft" to 1.
4. The content is inside a DIV, which uses "position: fixed" so it doesn't jump around when the BODY is scrolling.
The second approach uses the hash / history stack. Rather than trying to stop a "back" or "forward", we simply "buffer" the history stack so that we can detect any changes and return to our neutral position.
1. When we load the page, we change the hash to "#previous", then "#neutral", then
@mrienstra
mrienstra / asdf_list_all_flutter.txt
Created April 23, 2020 21:41
Output from `asdf list all flutter`
.17.0-3.2.pre-beta
.17.0-dev.0.0-dev
.17.0-dev.1.0-dev
.17.0-dev.2.0-dev
.17.0-dev.3.0-dev
.17.0-dev.3.1-beta
.17.0-dev.4.0-dev
.17.0-dev.5.0-dev
.18.0-6.0.pre-dev
.18.0-dev.0.0-dev