This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/tls" | |
"flag" | |
"fmt" | |
"log" | |
"net/http" | |
"os" | |
"os/user" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// UPDATE: In 2023, you should probably stop using this! The narrow version of Safari that | |
// does not support `nomodule` is probably not being used anywhere. The code below is left | |
// for posterity. | |
/** | |
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will | |
* load <script nomodule> anyway. This snippet solve this problem, but only for script | |
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script> | |
* | |
* Again: this will **not** prevent inline script, e.g.: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// usage: | |
// importScript('./path/to/script.js').then((allExports) => { .... })); | |
function importScript(path) { | |
let entry = window.importScript.__db[path]; | |
if (entry === undefined) { | |
const escape = path.replace(`'`, `\\'`); | |
const script = Object.assign(document.createElement('script'), { | |
type: 'module', | |
textContent: `import * as x from '${escape}'; importScript.__db['${escape}'].resolve(x);`, | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Updates the passed dialog to retain focus and restore it when the dialog is closed. Won't | |
* upgrade a dialog more than once. Supports IE11+ and is a no-op otherwise. | |
* @param {!HTMLDialogElement} dialog to upgrade | |
*/ | |
var registerFocusRestoreDialog = (function() { | |
if (!window.WeakMap || !window.MutationObserver) { | |
return function() {}; | |
} | |
var registered = new WeakMap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import json | |
import sys | |
try: # Py3 | |
from urllib.parse import urlencode | |
from urllib.request import urlopen | |
from urllib.request import Request | |
except ImportError: # Py2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is part of the blog post here: https://whistlr.info/2022/abortcontroller-is-your-friend/ | |
// ...and can be used to detect/polyfill the `signal` argument to addEventListener. | |
// | |
// Note that at writing, 86%+ of active browsers already support it: | |
// https://caniuse.com/mdn-api_eventtarget_addeventlistener_options_parameter_options_signal_parameter | |
// ...but that 92% of browsers support `AbortController` and signal. | |
// | |
// So there's 6% of total browsers which will fail silently when adding the `signal` argument. | |
// Eyeballing it, this is mostly Safari 11-15 and Chrome 66-90. These snippets can help with those targets. | |
// |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Useful bash functions. This is sourced by the environment file. | |
# These are available to scripts, but you shouldn't use them in scripts if you | |
# want them to be portable. | |
# Usage: pathremove /path/to/bin [PATH] | |
# Eg, to remove ~/bin from $PATH | |
# pathremove ~/bin PATH | |
function pathremove { | |
local IFS=':' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// If the device is already on a network and you need to change it, you can load: | |
// http://<device_ip>/common/get_wifi_setting | |
// It'll give you a result like... ret=OK,ssid=OldSSIDHere,security=mixed,key=%6e%65%76%65%72%67%6f%6e%6e%61%67%69%76%65%79%6f%75%75%70 | |
// To update the same data, open that page and in the console, run this (modify as needed): | |
const ssid = 'NewSSIDHere'; | |
const key = 'nevergonnagiveyouup'; | |
const encoded = Array.from(key).map((c) => '%' + c.charCodeAt(0).toString(16).padStart(2, '0')).join(''); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
0eNrNVV1uozAQvko1z1AJ8gPhBH3fvlWVZfA0sUpsZA/RRhEH2Fv0bD3J2iZByTZpXakPKyHAzMw3M998xgeo2x47IxVBdQDZaGWhejqAlWvFW/+N9h1CBZJwCwkovvUrw2ULQwJSCfwNVTY8J4CKJEkc48Niz1S/rdE4hynSkotdbygNEAl02roorXwqh5RnRQJ7qOaFQxfSYDMa8yH5AJrHg66iQWfRoHkWDTqPB51Fgy7iQRfRoMuLEadHGVwb0/0RtLxfXMI6CCcjMrplNW74Tmrjoxppml4Sa1ptkZ309cJbi8lkNMjFZCPTO5NBwXRPXU/sgyh30lAf6jsxgangau06cTVp419vBgdFO7e1QVRfeA2hJzW2aL0587cQeq53KaAqhudhuEJtMVXpx6VSS7r7RKurf4b1BataiQnmRRr7bbb81ifu/wMh1bbjhpNPAu9/3oLDMRUqXrfIhLT+eRqTRSUYaRZ6m+YaVsx32qGIqSh4pI/fY3x5xrZfl34CriTiIyMAV8ZRRio9z/4HpZ/E+iOa/kwIP6H01SW1zSbI/SbBs9sE+3Ml9FSdHVQJtLxG1xD8It68orl7wLZziRPYobHjdimzebHKi8XSXfNyGP4Cjmpeag== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fs from 'fs'; | |
// as per https://github.com/MicrosoftEdge/MSEdgeExplainers/blob/master/CSSModules/v1Explainer.md | |
export default function cssModules() { | |
return { | |
name: 'css-modules', | |
async load(id) { | |
if (!id.endsWith('.css')) { | |
return; |
NewerOlder