Adapted from the original specification
[DRAFT] WHOIS: look up ASN from the command-line
Since Marco d'Itri's whois(1) v5.5.0 released in July 2019, most sysadmins no longer need to do trial-and-error or detectivework to guess which of the 5 RIRs controls the IP attacking you and then hunt down the appropriate WHOIS server—the -I
flag will now do that annoying accounting on your behalf
[DRAFT] U.S. Obscenity Ban: Name & Blame
An 1873 federal bill to ban smut, abortion pamphlets, and sex toys was never found unconstitutional; instead, only the clauses that meaningfully impacted the ability of the American public to be sexually promiscuous were overturned, piecemeal, under the banner of "civil rights". I will attempt to give a breakdown (including partisan affiliation) of the people behind this bill's tortured history.
Transcript: Dr. Ryan Cole on Vitamin D and COVID
Transcribed from 0:52–24:13 of the Week 8 recording at lgo.idaho.gov/capitol-clarity/
Javascript: getElementByXPath
function getElementByXPath(path, context=null, document=null, namespaceResolver=null, first_ordered=true) {
if (context === null) context = window.document.documentElement;
if (document === null) document = context.ownerDocument;
if (namespaceResolver === null) namespaceResolver = document.createNSResolver(context);
const result = document.evaluate(path, context, namespaceResolver, first_ordered ? XPathResult.FIRST_ORDERED_NODE_TYPE : XPathResult.ANY_UNORDERED_NODE_TYPE, null);
return result.singleNodeValue || null;
}
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 …
Applying highlight.js to inline code on WordPress
If you're using the plugin Prismatic to apply highlight.js to your code excerpts, but you want it to also affect inline <code> tags (i.e. not only those wrapped in <pre> blocks), simply go Settings > Prismatic > Highlight.js and paste this into the “Init Script” field: hljs.configure({ cssSelector: 'code' }); hljs.highlightAll(); — then be sure to remember to add the language-* classes to your inline <code> tags! You may …
Python: Using "with" with sqlite3 cursor
If you like the assurance that Python's with statement provides, but can't figure out how to properly apply it to individual cursor objects, here's how to do that: import sqlite3 from contextlib import closing con = sqlite3.connect('example.db') with con, closing(con.cursor()) as cur: cur.execute(…)
Mandates ARE laws…
I've seen some people online saying variations on “[COVID-19 quarantine] mandates aren't laws! know your rights! [state] legislature didn't sign off on this!” However, these people are usually incorrect. I'll be compiling examples in this post, more to come if I feel like it, starting out with representative examples from each quadrant of the U.S.: AL Code § 22-2-2 (6) [archived] CA HSC § 120130 (c) and (d), and …
Basic JS Async Cookbook
function asleep(delay) { return new Promise(resolve => setTimeout(resolve, delay)); } // Usage: await asleep(1000); function aalert(message) { return new Promise( resolve => resolve(alert(message)) ); } function aconfirm(message) { return new Promise( resolve => resolve(confirm(message)) ); } function aprompt(message, deflt) { return new Promise( resolve => resolve(prompt(message, deflt)) ); } // Usage: await aalert("The task will begin as soon as you press OK.") ; do_task(); aalert("The task will begin as …