Skip to content

Instantly share code, notes, and snippets.

@mhl
mhl / birthdays.rb
Last active August 2, 2023 08:31
A very old Ruby script to email me reminders of when people's birthdays are coming up
#!/usr/bin/ruby -w
# encoding: US-ASCII
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.
@mhl
mhl / squash-all.bash
Created March 11, 2011 06:38
A script that squashes your entire branch down to a single commit
#!/bin/bash
# A script that squashes your entire current branch down to a single commit,
# if this repository has a single root commit. This will change the object
# name of the root commit. This is for an answer to the Stack Overflow
# question: http://stackoverflow.com/questions/5266340/
if [ -n "$(git status --porcelain)" ]
then
echo "git status wasn't clean - refusing to run..."
@mhl
mhl / git-show-all-objects.sh
Created September 12, 2011 16:05
A script to show all the objects in a git repository
#!/bin/sh
set -e
cd "$(git rev-parse --show-cdup)"
# Find all the objects that are in packs:
for p in .git/objects/pack/pack-*.idx
do
@mhl
mhl / git-fetch-and-fast-forward-all-branches.sh
Created April 22, 2011 11:35
An example script to show how to fetch from all default remotes and do any fast-forwards of local branches from upstream possible
#!/bin/sh
set -e
CURRENT_BRANCH="$(git symbolic-ref HEAD)"
CURRENT_BRANCH_UPSTREAM="$(git rev-parse --symbolic-full-name @{u} 2> /dev/null)"
# Update the remote-tracking branches for every remote for which
# remote.<name>.skipDefaultUpdate is not true:
git remote update default
@mhl
mhl / make_type_effectiveness_data.py
Last active March 18, 2019 12:55
A script for generating CSV files with type effectiveness data
#!/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 / extract-tree-from-git.py
Created July 29, 2010 15:37
A script to extract a tree from a git repository
#!/usr/bin/python3.1
from subprocess import call, Popen, PIPE, check_call
import re
import sys
import os
import errno
# !! n.b. You probably shouldn't be using this - it's vastly faster and safer to use
# one of the other methods mentioned here:
@mhl
mhl / update-all.py
Created September 28, 2018 14:48
A script for updating or cloning all repositories in a GitHub organization in the current directory
#!/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
@mhl
mhl / tips.org
Last active November 20, 2017 09:44

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
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
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