Skip to content

Instantly share code, notes, and snippets.

@mhl
mhl / birthdays.rb
Last active May 14, 2021
A very old Ruby script to email me reminders of when people's birthdays are coming up
View birthdays.rb
#!/usr/bin/ruby -w
require 'date'
def usage
STDERR.print <<EOUSAGE
It is intended that this script should be run from cron.daily, or
once every few days by some other means.
Usage:
@mhl
mhl / make_type_effectiveness_data.py
Last active Mar 18, 2019
A script for generating CSV files with type effectiveness data
View make_type_effectiveness_data.py
#!/usr/bin/env python
# For this script to run, you'll need the GAME_MASTER.json file from:
#
# https://raw.githubusercontent.com/pokemongo-dev-contrib/pokemongo-game-master/master/versions/latest/GAME_MASTER.json
#
# ... in the current directory.
import csv
from collections import defaultdict
@mhl
mhl / update-all.py
Created Sep 28, 2018
A script for updating or cloning all repositories in a GitHub organization in the current directory
View update-all.py
#!/usr/bin/env python
from __future__ import print_function, unicode_literals
import argparse
import json
from os.path import exists, expanduser, join
from os import getcwd
import requests
from subprocess import check_call, call
View tips.org

In https://www.wikidata.org/wiki/Special:Preferences#mw-prefsection-gadgets

Turn on KeyShortcuts

Turn on checkConstraints

This is very helpful, but will produce lots of warnings that you can ignore, in particular:

  • the inception date of positions

Make sure every item items won’t just get deleted

To do this, you should make sure that the item has at least one of the following:

  • An associated Wikipedia page
View administrative-areas-with-multiple-enclosing-countries-in-osm.txt
Multiple enclosing country codes (u'AU', u'HM') found for area Heard Island and McDonald Islands with ID 14196
Multiple enclosing country codes (u'AU', u'HM', u'NF') found for area Australia with ID 958878
Multiple enclosing country codes (u'AU', u'NF') found for area Norfolk Island with ID 363603
Multiple enclosing country codes (u'AU', u'NF') found for area Unknown name for way with ID 184710937 with ID 237996
Multiple enclosing country codes (u'BV', u'NO') found for area Bouvetøya with ID 363287
Multiple enclosing country codes (u'BV', u'NO') found for area Norge with ID 958819
Multiple enclosing country codes (u'CA', u'US') found for area Maine with ID 961284
Multiple enclosing country codes (u'CA', u'US') found for area Washington County with ID 969065
Multiple enclosing country codes (u'CD', u'RW') found for area Rubenga (chefferie) with ID 991957
Multiple enclosing country codes (u'CN', u'PH') found for area Central Luzon with ID 958975
View statements-new-senate-people
CREATE
LAST Les "Alfredo Héctor Luenzo"
LAST Len "Alfredo Héctor Luenzo"
LAST P31 Q5
LAST P106 Q82955
LAST P39 Q18229570 P580 +2015-12-10T00:00:00Z/11 P768 Q45007 S854 http://www.senado.gov.ar/senadores/senador/457
CREATE
LAST Les "Ana Claudia Almirón"
LAST Len "Ana Claudia Almirón"
LAST P31 Q5
View no-wikidata-person.csv
We can make this file beautiful and searchable if this error is corrected: It looks like row 3 should actually have 31 columns, instead of 30. in line 2.
id,name,sort_name,district,start_date,end_date,party,source,image,phone,email,term,id,uuid,id,name,sort_name,email,twitter,facebook,group,group_id,area_id,area,term,start_date,image,gender,wikidata,wikidata_group,wikidata_area
rdominguez,Ramon Alfredo Dominguez,"Dominguez, Ramon Alfredo",San Luis,2013-12-10,2017-12-09,COMPROMISO FEDERAL,http://www.hcdn.gob.ar/diputados/rdominguez/,,,,135,rdominguez,8c699082-2995-407b-b100-cf40660a3d22,8c699082-2995-407b-b100-cf40660a3d22,Ramon Alfredo Dominguez,"Dominguez, Ramon Alfredo",,,,COMPROMISO FEDERAL,compromiso_federal,area/san_luis,San Luis,135,2017-01-01,,,,Q5668474,Q44818
dgiustozzi,Ruben Dario Giustozzi,"Giustozzi, Ruben Dario",Buenos Aires,2013-12-10,2017-12-09,JUNTOS POR ARGENTINA,http://www.hcdn.gob.ar/diputados/dgiustozzi/,,,,135,dgiustozzi,6b95e796-00d1-4332-8dfa-f53b1817e2a2,6b95e796-00d1-4332-8dfa-f53b1817e2a2,Ruben Dario Giustozzi,"Giustozzi, Ruben Dario",,,,JUNTOS POR ARGENTINA,juntos_por_argentina,area/buenos_aires,BUENOS AIRES,135,2017-01-01,,male,,Q41
@mhl
mhl / make_parlparse_wikidata_mapping.py
Last active Aug 22, 2017
mapping between Historic Hansard slugs, Wikidata items and parlparse IDs
View make_parlparse_wikidata_mapping.py
#!/usr/bin/env python
from __future__ import unicode_literals, print_function
import csv
import json
from os.path import dirname, join
import re
import sys
View print-twitter-usernames.py
#!/usr/bin/env python
# This script should print out all the Twitter username for the
# current representatives for a particular country's lower house
# (Ecuador in this example, but it's easy to change). This should
# work on Python 2.7 and Python 3.
from __future__ import print_function, unicode_literals
from everypolitician import EveryPolitician
View graph-youngest-parliament.py
#!/usr/bin/env python
from __future__ import unicode_literals
from datetime import date
from itertools import islice
from everypolitician import EveryPolitician
import matplotlib.pyplot as plt