Skip to content

Instantly share code, notes, and snippets.

Avatar

John Duncan JohnDDuncanIII

View GitHub Profile
View update_golang.sh
update_go() {
ARCH="$(uname -m | sed 's/^..86$$/386/; s/^.86$$/386/; s/x86_64/amd64/; s/arm.*/arm/; s/aarch64/arm64/')"
OS="$(uname | tr "[:upper:]" "[:lower:]" | sed 's/mingw/windows/; s/.*windows.*/windows/')"
# if the $GOROOT environment variable does not exist...
if [ -z "$GOROOT" ]
then
# if go is installed
if [ -x "$(command -v go)" ]
then
View news.html
<!DOCTYPE html>
<iframe src="data:text/html,
<!DOCTYPE html>
<script>
const d = new Date();
const year = d.getFullYear();
const month = `${d.getMonth() + 1}`.padStart(2, '0');
const day = `${d.getDate()}`.padStart(2, '0');
View preact-xul.js
document.createElementHTML = element => document.createElementNS("http://www.w3.org/1999/xhtml", element)
document.createElementXUL = element => document.createElementNS("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul", element)
htmlNS = () => document.createElement = document.createElementHTML
// https://bugzilla.mozilla.org/show_bug.cgi?id=1479050
// https://bugzilla.mozilla.org/show_bug.cgi?id=1479538
// https://bugzilla.mozilla.org/show_bug.cgi?id=1631439
// https://developer.thunderbird.net/add-ons/updating/tb78/changes#changed-xul-elements
xulNS = () => document.createElement = (
// Mozilla 63+
View darkmode.js
// js
const isDarkMode = (
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
)
window
.matchMedia("(prefers-color-scheme: dark)")
.addEventListener("change", e => {
const colorScheme = e.matches ? "dark" : "light"
View reactify.jsx
/**
* recursively converts DOM nodes into React elements
* @param {(DOM) Node} element the DOM Node
* @param {number} index the unique key
* @param {number} id the ID of the parent Component
*
* @returns {JSX} the new JSX element
*/
const reactify = (element, index, id, disableAnchors) => {
// get attributes of DOM nodes and add them to a map to pass to the React element