## Auto-updating userscripts hosted on Github Gist

In the process of crafting this small set of improvements to Advance Wars By Web, I found out about the proper URL for auto-updating userscripts which are hosted on Microsoft's "Gist" service: // @updateURL https://gist.githubusercontent.com/������/����������������/raw/�����.user.js This will always redirect to the latest version of the file.

## Javascript: getElementByXPath

function getElementByXPath(path, context=null, _document=undefined) {
if( _document === undefined ) _document = document;
let res = document.evaluate(path, _document, context, XPathResult.FIRST_ORDERED_NODE_TYPE);
if( !res ) return null;
return res.singleNodeValue;
}

## Python: Using XOFs for general-purpose Random

As always, one's own stack overflow answers make the best blog posts. In this case, we craft a version of random.Random with a few modifications: Pulls its data from an arbitrary stream (in our case, a DRBG such as a hash function or deterministic CSPRNG) Wastes noticeably fewer bits when generating random integers Has fixed code for .shuffle, on the offchance CPython ever changes theirs, and to make it …

## Python: Rounding fractions half-up

By default, Python's fractions rounds halves to the nearest even number. If you, instead, want to round a fraction but send halves up, here's how that's done:

def roundhalfup(x: Fraction) -> int:
"""
Rounds x to the nearest integer, with ties being rounded towards positive infinity
"""
return floor(x + Fraction(1, 2))

## Javascript: Parsing query parameters

There are at least 2×5×7×3×3×1=630 different things you might unambiguously mean by "parsing" a query string in Javascript: …

## Python: Nested in-line "for" statements

You must leave the fors in the same order as in the code-block form, only popping the inner expression itself to the front:…

## WordPress: Restrict MathJax to a class

I write on a variety of topics, only some of which it's appropriate to have mathematical typesetting for. To avoid triggering a math rendering engine on unrelated use of $purious dollar sign$, while activating it when $\text{necessary}\wedge\text{appropriate}$, I decided to restrict them to only elements with .language-mathjax. Here's how that's done (for v3): MathJax = { tex: { inlineMath: [ ['$', '$'] ] }, startup: { elements: ['.language-mathjax'] } …

## ESXi: auto-reboot after Purple Screen of Death

Shamelessly stolen / archived from / hat-tip to this other website, vSkilled, for their post on this. I'm just copying the important details here for when they go under or get consumed by advertisements. esxcfg-advcfg -s 120 /Misc/BlueScreenTimeout # (That's for a two-minute wait; adjust to taste)

## Converting SVG to .ico with Python

Just a super rudimentary script that I made which hooks CairoSVG up to Pillow because apparently Firefox doesn't support SVG-formatted browserAction images

## Getting OpenNIC to work with pfSense

If you're using an alternate DNS root server such as OpenNIC, and your network uses a pfSense-based router, you may find that clients are, strangely, unable to resolve unofficial TLDs, getting SERVFAIL or NXDOMAIN. There are 3 ways I can think of to quickly solve this problem for the whole network, listed here in increasing order of complication: 1. Disable the DNS resolver Go to Services > DNS Resolver …