Skip to content

Instantly share code, notes, and snippets.

@robla
robla / tennessee-example-scores.abif
Last active October 23, 2023 00:34
tennessee-example-scores.abif (see also: https://electowiki.org/wiki/Tennessee_example)
{"title": "Tennessee capitol example"}
{"description": "Hypothetical example of selecting capitol of Tennessee, frequently used on Wikipedia and electowiki. The proportion of voters is loosely based on the people who live in the metropolitan areas of the four largest cities in Tennessee, and the numeric ratings are based on crow-flying mileage to the city from the other metro areas."}
# See https://electowiki.org/wiki/Tennessee_example for illustrations
=Memph:[Memphis, TN]
=Nash:[Nashville, TN]
=Chat:[Chattanooga, TN]
=Knox:[Knoxville, TN]
# -------------------------
# Ratings are 400 miles minus crow-flying mileage to city
42:Memph/400>Nash/200>Chat/133>Knox/45
@robla
robla / RobLa-IETF-W3C.md
Last active April 8, 2024 06:00
robla's history with the IETF and W3C

I was heavily involved in the IETF and the W3C back in the late 1990s, when "the web" was new (and when the "W3C" was new). Back then, there was a big debate about the wisdom of "Postel's law", which I strongly suspect was a big part of the rationale for the W3C forking from the IETF. After the failure of HTML 2.0 (published by the IETF) to be published quickly enough to stop the creation of de facto standards by Netscape and Microsoft, since HTML 2.0 doesn't have very many features in it, but Netscape's and Microsoft's browsers had many more features. The W3C went down the path of insisting that compliant implementations should "halt and catch fire" (so to speak) when they published the XML specification in 1997. The "XHTML" experiment proved that organizations don't have that much authority, and that anyone who purports to be a "compliance cop" from one of those or

#!/bin/bash
function print_24hr_string () {
# Wrapper around "date" command for printing 24hr datetime
# 1: "tzolson": timezone id from the Olson DB
tzolson="$1"
# 2: "placename": more relevant timezone label than Olson's choices
placename="$2"
# 3: "fdate" is "function date" for date passed to this func
fdate="$3"
@robla
robla / reverse_cumulative_table.py
Created February 16, 2019 00:54
Reverse-engineering a ballot set from a specific table of pairwise voting results listed in a 2019 reddit post
#!/usr/bin/python3
# Script for generating an answer to this:
# <https://www.reddit.com/r/Voting/comments/aqsxft/condorcet_winner_from_counts_of_ranks_possible/>
import json
import itertools
from collections import Counter
innerperm = [x for x in itertools.permutations(['P1', 'P2', 'P3'], 3)]
@robla
robla / grepcount-cand-files.sh
Last active June 18, 2018 05:32
Very crude tool to tally the output of sfballotparse.py for 2018 in particular (with hardcoded last names for the top 3 candidates this past election)
#!/bin/bash
# Very crude tool to tally the output of sfballotparse.py for 2018 in particular
# (with hardcoded last names for the top 3 candidates this past election)
votefile=${1}
if [ ! -f "${votefile}" ]; then
echo "${votefile} not found"
exit
fi
@robla
robla / sf2018mayorballots-urlencoded-tallysorted.txt
Last active June 17, 2018 21:21
Ballots for sf2018mayoral race (report 14), urlencoded with robla/sfballotparse.py and piped through sort + uniq -c
47 AMY+FARAH+WEISS=1
4 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2
38 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2&ELLEN+LEE+ZHOU=3
31 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2&JANE+KIM=3
29 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2&LONDON+BREED=3
27 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2&MARK+LENO=3
20 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2&MICHELLE+BRAVO=3
8 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2&None=3
15 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=2&RICHIE+GREENBERG=3
1 AMY+FARAH+WEISS=1&ANGELA+ALIOTO=3
@robla
robla / sfballotparse.py
Created June 17, 2018 21:00
sfballotparse.py - parse sfelections.sfgov.org/results ballot image files
#!/usr/bin/env python3
# MIT License
#
# Copyright (c) 2018 Rob Lanphier
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
@robla
robla / sqlite3-csv.sh
Created November 25, 2017 01:27
sqlite3-csv.sh: dump an table from sqlite db as csv
#!/bin/bash
# sqlite3-csv: dump an table from sqlite db as csv
summary="$0: dump an sqlite db as csv"
usageline=" usage: $0 thisdb [thistable]"
usage="${summary}\n\n${usageline}\n\n"
if [ -z "$1" ]; then
printf "$usage"
exit;
@robla
robla / keybase.md
Created November 21, 2017 02:31
keybase.md

Keybase proof

I hereby claim:

  • I am robla on github.
  • I am robla (https://keybase.io/robla) on keybase.
  • I have a public key ASCNQx8NKhpIwCSsDw5BeXa9ojdNLNBkYrdpMcZKOa9ZLAo

To claim this, I am signing this object:

@robla
robla / gist:371ea556af34d20341808610068fb0e1
Created February 21, 2017 04:22
Blockstack ID: roblan.id
Verifying that "roblan.id" is my Blockstack ID. https://onename.com/roblan