Skip to content

Instantly share code, notes, and snippets.

View spencerwi's full-sized avatar

Spencer Williams spencerwi

View GitHub Profile
@spencerwi
spencerwi / dump-playlist.js
Last active May 14, 2020 21:05
Dump GMusic playlist to JSON file
function readRow(songRowTr) {
let title = songRowTr.querySelector("td[data-col='title']").innerText;
let artist = songRowTr.querySelector("td[data-col='artist']").innerText;
let album = songRowTr.querySelector("td[data-col='album']").innerText;
return {title, artist, album}
}
function dumpPlaylist() {
let playlistName = document.querySelector('gpm-detail-page-header').querySelector('h2[slot=title]').innerText;
let tracks = Array.from(document.querySelectorAll('tr.song-row')).map(songRowTr => readRow(songRowTr));
@spencerwi
spencerwi / up.sh
Created September 10, 2019 15:52
Bash function to go up 1 or more directories without manually cd-ing
function up {
if [ -z "$1" -o ! "$1" -gt 0 ]; then
cd ..
else
CDSTR=""
for i in $(seq 1 $1) ; do
CDSTR="../$CDSTR"
done
cd $CDSTR
fi
@spencerwi
spencerwi / keybase.md
Created July 1, 2019 11:25
keybase.md

Keybase proof

I hereby claim: * I am spencerwi on github. * I am spencerwi (https://keybase.io/spencerwi) on keybase. * I have a public key ASDH0-05zgpKQvvw9CMrPNc8VSvwzUjFSjGZgUy2Iw9Nlgo To claim this, I am signing this object:

{   "body": {     "key": {       "eldest_kid": "0120c7d3ed39ce0a4a42fbf0f4232b3cd73c552bf0cd48c54a3199814cb6230f4d960a",       "host": "keybase.io",       "kid": "0120c7d3ed39ce0a4a42fbf0f4232b3cd73c552bf0cd48c54a3199814cb6230f4d960a",       "uid": "2891c166bc8338e49bc795c0c4e36b19",       "username": "spencerwi"     },     "merkle_root": {       "ctime": 1561980248,       "hash": "dbcdfcb5dd7c54574d8754f0bb5d5f0557b49c1e568358f5ebbed8e2195a0b380286b05e5e4c73d8517a26107a5933c3fd2336bcaf814c9b4bce60d1da9bab8b",       "hash_meta": "e216177a1f552fb4e5fcbcfc41cc78567de60953b26a6cddbe73d5e205fa2acc",       "seqno": 5671655     },     "service": {       "entropy": "bQvCp9/Vxl/o2tBjuphc+LNC",       "name": "github",       "username": "spencerwi"     },     "type": "web_
@spencerwi
spencerwi / .editorconfig
Created March 29, 2018 20:08
My editorconfig
# This is the "system-level" editorconfig
root = true
# Unix-style newlines with a newline ending every file
[*]
end_of_line = lf
insert_final_newline = true
# 4-space indent for JSON
[*.json]
@spencerwi
spencerwi / ips.fsx
Created January 9, 2017 12:11
Get IP addresses on local machine (using only F# stdlib)
open System
open System.Net
open System.Linq
let applyFilters showIPv4Only showIPv6Only addrs =
match (showIPv4Only, showIPv6Only) with
| (true, false) -> Seq.filter (fun (addr: IPAddress) -> addr.AddressFamily = Sockets.AddressFamily.InterNetwork) addrs
| (false, true) -> Seq.filter (fun (addr: IPAddress) -> addr.AddressFamily = Sockets.AddressFamily.InterNetworkV6) addrs
| (_, _) -> addrs
@spencerwi
spencerwi / whenwas.fsx
Created January 8, 2017 23:11
whenwas.fsx
#!/usr/bin/env fsharpi --exec
open System
type DateScale = Hour | Hours | Day | Days | Week | Weeks
type DateDirection = Ago | Forward
let parseDirection strInput =
match strInput with
| "forward" | "from now" -> Forward
@spencerwi
spencerwi / ping-until-up.sh
Created January 8, 2017 23:10
ping-until-up.sh
#!/bin/bash
###
# Pings a host until the host responds.
###
if [ "$#" -gt 0 ] ; then
IS_LIVE=false;
while ! $IS_LIVE ; do
@spencerwi
spencerwi / CodeWarsTestRunner.scala
Last active September 17, 2016 18:48
Codewars test harness for scala (using scalatest)
import org.scalatest._;
import org.scalatest.events._;
class CodeWarsReporter extends Reporter {
def apply(event: Event) : Unit = event match {
case e: SuiteStarting => println(s"<DESCRIBE::> ${e.suiteName}")
case e: ScopeOpened => println(s"<DESCRIBE::> ${e.message}")
case e: TestStarting => println(s"<IT::>${e.testName}")
case e: TestSucceeded => {
println(s"<PASSED::>${e.testName}")
declare abstract class TemporalAccessor {
get(field: TemporalField): number
query(query: TemporalQuery): any
range(field: TemporalField): ValueRange
}
declare abstract class Temporal extends TemporalAccessor {}
declare abstract class Clock {
static fixed(fixedInstant: Instant, zoneOffset: ZoneOffset): Clock
static system(zone: ZoneId): Clock
@spencerwi
spencerwi / Response.md
Last active July 29, 2016 22:33
In response to Wayne Grudem, regarding his endorsement of voting for Donald Trump as "morally good"

I also have found Grudem to be respectable in his Systematic Theology, but I'm disappointed in this article.

In summary, Grudem's points are:

  • Trump's not really that bad, is he? His sins, even though he wears them proudly, shouldn't be offensive to Christians.
  • Trump is the lesser of two evils. You don't want Hillary to win, do you? (Put another, even-more-cliched way, "not voting is the same as voting for Hillary" -- which is false, if I was never going to vote for Trump in the first place).
  • Christianity means doing what's best for America (and Trump is what's best for America).

I disagree with these premises; I do think the sins that Trump wears not just unrepentantly, but proudly, should be offensive to Christians, and should be more offensive to Grudem than they are; he minimizes outright insults that Trump has doubled-down on as "careless remarks" rather than the more Biblical "out of overflow of the heart, the mouth speaks" (as Jesus said in Luke 6).

Yes, Trump is egotistical. That fault can