Skip to content

Instantly share code, notes, and snippets.


Zander Martineau mrmartineau

View GitHub Profile

Pure ESM package

The package linked to from here is now pure ESM. It cannot be require()'d from CommonJS.

This means you have the following choices:

  1. Use ESM yourself. (preferred)
    Use import foo from 'foo' instead of const foo = require('foo') to import the package. Follow the below guide.
  2. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).
  3. Stay on the existing version of the package until you can move to ESM.

Storybook experimental Webpack 5 support

Storybook 6.2 includes experimental Webpack 5 support. Webpack 5 brings a variety of performance improvements, as well as exciting new features like module federation. Here's a quick guide to get you going.


Storybook uses webpack to bundle its UI ("manager") and also user code in an iframe ("preview"). In Storybook 6.2, the manager is bundled in Webpack 4, and the preview can either be bundled in Webpack 4 (default) or Webpack 5 (opt-in). In Storybook 6.3, the manager is also bundled in Webpack 5 when the preview is bundled with Webpack 5.

ityonemo /
Last active Jun 12, 2021
Zig in 30 minutes

A half-hour to learn Zig

This is inspired by


the command zig run my_code.zig will compile and immediately run your Zig program. Each of these cells contains a zig program that you can try to run (some of them contain compile-time errors that you can comment out to play with)

JamieCurnow / firestore.ts
Last active Jun 2, 2021
Using Firestore with Typescript
View firestore.ts
* This Gist is part of a medium article - read here:
// import firstore (obviously)
import { firestore } from "firebase-admin"
// Import or define your types
// import { YourType } from '~/@types'
Jack-Works / 2018.js
Last active Jun 1, 2021
cRAzY eSnEXt (*all* proposals mixed in)
View 2018.js
#! Aaaaaaaaaaa this is JS!!!
// This file is mixing all new syntaxes in the proposal in one file without considering syntax conflict or correct runtime semantics
// Enjoy!!!
// Created at Nov 23, 2018
for await(const x of (new A //
|> do { //
case(?) { //
when {val}: class {
sammillner / Forecast
Created Sep 30, 2020
Fivethirtyeight general election forecast
View Forecast
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
const url = ""
const req = new Request(url)
const res = await req.loadJSON()
const Biden = Math.round(res[0].candidates.find(x => x.candidate == "Biden").dates[0].winprob) + "%"
const Trump = Math.round(res[0].candidates.find(x => x.candidate == "Trump").dates[0].winprob) + "%"
mzeryck / mz_invisible_widget.js
Last active Jun 5, 2021
A Scriptable script that creates "invisible" widget backgrounds based on your iOS wallpaper, and then either uses them as a Scriptable widget background or exports to your camera roll.
View mz_invisible_widget.js
// This widget was created by Max Zeryck @mzeryck
You can't add commit messages to gists, so I just want to say thanks to everyone who has used, modified,
and enjoyed this script. This version adds support for the iPhone 12 mini, thanks to arealhen for providing
a screenshot, and mintakka for a temporary solution.
// Widgets are unique based on the name of the script.
const filename = + ".jpg"
marco79cgn / sonos-nowPlaying.js
Last active Jun 8, 2021
A scriptable widget that shows what's playing on SONOS
View sonos-nowPlaying.js
// Variables used by Scriptable.
// These must be at the very top of the file. Do not edit.
// icon-color: cyan; icon-glyph: magic;
// the node sonos http api base url (running on your Pi for example)
let sonosBaseUrl = ""
// optional for cover art: the ip address of one of your Sonos speakers
let sonosPlayerUrl = ""
let param = args.widgetParameter
View scriptable-xkcd-widget.js
const url = ""
const req = new Request(url)
const { img: imgUrl } = await req.loadJSON()
const imgReq = await new Request(imgUrl)
const img = await imgReq.loadImage()
// for development, displays the widget if run
const debug = false;