Skip to content

Instantly share code, notes, and snippets.

Avatar
🤦‍♂️
Coding

Zander Martineau mrmartineau

🤦‍♂️
Coding
View GitHub Profile
View esm-package.md

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.
View storybook-webpack5-experimental.md

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.

Intro

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.

View LearnGoIn5mins.md
@ityonemo
ityonemo / test.md
Last active Jun 12, 2021
Zig in 30 minutes
View test.md

A half-hour to learn Zig

This is inspired by https://fasterthanli.me/blog/2020/a-half-hour-to-learn-rust/

Basics

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
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:
* https://jamiecurnow.medium.com/using-firestore-with-typescript-65bd2a602945
*/
// import firstore (obviously)
import { firestore } from "firebase-admin"
// Import or define your types
// import { YourType } from '~/@types'
@Jack-Works
Jack-Works / 2018.js
Last active Jun 1, 2021
cRAzY eSnEXt (*all* proposals mixed in)
View 2018.js
#! Aaaaaaaaaaa this is JS!!!
// https://github.com/tc39/proposal-hashbang
// 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 // https://github.com/tc39/proposal-pipeline-operator
|> do { // https://github.com/tc39/proposal-do-expressions
case(?) { // https://github.com/tc39/proposal-pattern-matching
when {val}: class {
@sammillner
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 = "https://projects.fivethirtyeight.com/2020-election-forecast/us_timeseries.json"
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
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 = Script.name() + ".jpg"
@marco79cgn
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 = "http://192.168.178.10:5005"
// optional for cover art: the ip address of one of your Sonos speakers
let sonosPlayerUrl = "http://192.168.178.38:1400"
let param = args.widgetParameter
View scriptable-xkcd-widget.js
const url = "https://xkcd.com/info.0.json"
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;