Skip to content

Instantly share code, notes, and snippets.

@Stuk
Stuk / tools.md
Last active July 14, 2021 06:42
Things that I use on my Mac that you may also find useful

Things that I use on my Mac that you may also find useful

This list is in a rough order of most obscure/useful, so that the things at the top are tools that you haven't heard of before.

Witch

I find the default application switcher in OSX useless. I often have many Sublime Text windows open, a number of GitX windows, and maybe a couple of Chrome windows. Having to Cmd + Tab to the app, and then Cmd + ` through the app windows takes too long. Witch works like Alt + Tab on Windows.

It takes a bit of persuading to make it replace the default Cmd + Tab shortcut, but it's worth it.

@Stuk
Stuk / class.js
Last active March 7, 2024 01:06
ES5 classes, compatible with ES6 classes
function A() {}
A.prototype.thing = function () {
return "A";
};
function B() {}
Object.setPrototypeOf(B, A)
B.prototype = Object.create(A.prototype)
B.prototype.constructor = B;
@Stuk
Stuk / example.js
Created November 6, 2020 17:35
AbortController usage
// See https://dom.spec.whatwg.org/#abortcontroller-api-integration
function getData({signal}) {
// 1. Let p be a new promise.
// 4. Return p.
return new Promise((resolve, reject) => {
// 2. If options' signal member is present, then:
if (signal && signal.aborted) {
// 2. 1. If options' signal's aborted flag is set, then reject p with an "AbortError" DOMException and return p.
throw new DOMException("Aborted", "AbortError");
@Stuk
Stuk / Clock.tsx
Last active May 10, 2022 20:56
swc #3628 repro
import React from "react";
export function Clock({
hour,
minute,
second,
}: {
hour: number;
minute: number;
second: number;