Skip to content

Instantly share code, notes, and snippets.

View thcipriani's full-sized avatar

Tyler Cipriani thcipriani

View GitHub Profile
@thcipriani
thcipriani / versionsfordblist.py
Last active July 24, 2018 17:36
A short script to see which MediaWiki versions are active for all the wikis in a particular list of wikis.
#!/usr/bin/env python3
"""
versionsfordblist
~~~~~~~~~~~~~~~~~
Dumps out versions in use for any dblist on noc.wikimedia.org
Usage:
versionsfordblist <dblist>
@thcipriani
thcipriani / diasticus-strains.py
Last active June 28, 2018 03:49
White Labs started putting a disclaimer about strains that have a potential indicator of Saccharomyces cerevisiae var. diastaticus. This is a script to find all the strains that have it.
#!/usr/bin/env python3
import os
import requests
from bs4 import BeautifulSoup
base_url = 'https://www.whitelabs.com'
page = ('yeast-bank?keywords='
#!/usr/bin/env python
"""
train.py
~~~~~~~~
Find deployments of a given type in a given time period.
"""
from __future__ import division
@thcipriani
thcipriani / 1-rsync-refuses.sh
Last active February 21, 2018 16:18
It seems that if we explicitly ignore a file, when that file exists on an rsync target in a deleted directory, rsync --delete will refuse to delete that directory
#!/usr/bin/env bash
set -x
mkdir -p rsync1/versions/version1/cache/l10n
touch rsync1/versions/version1/cache/l10n/en.cdb
touch rsync1/versions/version1/cache/l10n/en.json
rsync -avz --delete --exclude='**/cache/l10n/*.cdb' rsync1/ rsync2/
touch rsync2/versions/version1/cache/l10n/en.cdb
rm -rf rsync1/versions/version1
@thcipriani
thcipriani / ksphelper
Created July 28, 2017 15:05
A gpgparticipants(1) helper script. The idea is to not import the keys you have initially, but only after the ksp-file.txt has been verified as correct.
#!/usr/bin/env bash
set -euo pipefail
help() {
cat<<HELP 2>&1
USAGE:
ksphelper <party name> <keymaster> <keysfile>
ksphelper helps create a gpgparticipants file from a list of keys.
@thcipriani
thcipriani / update-wikimedia-repos.py
Last active February 6, 2019 16:27
Update all the github descriptions for WMF repos
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
update-wikimedia-repos.py
~~~~~~~~~
Update all Wikimedia repositories to point to the code mirror on gerrit.
Prompts for username and password as well as 2fa code. You will be prompted twice
for a 2fa code -- once for listing orgs, once for listing repos.
" SetSpaces ------------------------------------------------------------ {{{
function! SetSpaces(arg)
echo "settings spaces to: " . a:arg
execute 'set tabstop=' . a:arg
execute 'set shiftwidth=' . a:arg
execute 'set softtabstop=' . a:arg
endfunction
command! -nargs=1 SetSpaces :call SetSpaces(<f-args>)
" }}}
@thcipriani
thcipriani / spell.sh
Created February 23, 2017 17:00
I keep this function sourced from my .bashrc—it is incredibly useful.
spell() {
# /me futilely avoids googling words to find their correct spelling
local candidates oldifs word array_pos
oldifs="$IFS"
IFS=':'
# Parse the apsell format and return a list of ":" separated words
read -a candidates <<< "$(printf "%s\n" "$1" \
| aspell -a \
| awk -F':' '/^&/ {
#!/usr/bin/env bash
# Embed exif info inside of a photo
DEBUG=0
DRY_RUN=0
OUTPUT_DIR=
FILES=
TAGS=(
'FocalLength'
'ExposureTime'
'Make'
@thcipriani
thcipriani / vigenère_cipher.py
Created February 17, 2017 15:55
Simple python implementation of the Vigenère Cipher as described by https://en.wikipedia.org/wiki/Vigen%C3%A8re_cipher#Description
#!/usr/bin/env python3
"""
Vigenère Cipher
===============
This is a slightly more complicated version of the classic Ceaser cipher (A.K.A
Rot13). Rather than rotate each letter of the alphabet 13 characters, we rotate
each letter of a message by the offset of the cooresponding letter of a
variable length key.