Skip to content

Instantly share code, notes, and snippets.

View willkg's full-sized avatar

Will Kahn-Greene willkg

View GitHub Profile
@willkg
willkg / git-wtfamipushing
Created February 27, 2013 22:23
shows a log --oneline of the sha in production and head
#!/bin/bash
set -o errexit
USAGE=""
. git-sh-setup
INPROD=`curl -s "https://support.mozilla.org/media/revision.txt"`
echo "You are about to push:"
@willkg
willkg / commit-msg
Created July 10, 2013 02:16
commit-msg hook for translating all commit messages into Pirate using dennis.
#!/bin/bash
(cat < $1 | dennis-cmd translate - | tail -n "+2" > $1.tmp) && mv $1.tmp $1
# We always exit 0 in case dennis-cmd fails. Then you get your
# original commit message. No one likes it when goofy shenanigans
# break your stuff.
exit 0;
@willkg
willkg / james.py
Last active December 20, 2015 23:59 — forked from mythmon/james.py
chief cli
#!/usr/bin/env python
"""
james.py - Chief CLI.
USAGE: james.py ENV REF
ENV - Environment defined in the config file to deploy to.
REF - A git reference (like a SHA) to deploy.
Config: james.ini in the current directory should be an ini file with
one section per environment. Each environment should have a
@willkg
willkg / search_test.py
Created March 7, 2016 16:25
Run a search and compare against previous search
import json
import os
try:
import requests
from tabulate import tabulate
except ImportError:
print 'Please install "requests" and "tabulate" packages.'

Keybase proof

I hereby claim:

  • I am willkg on github.
  • I am willkg (https://keybase.io/willkg) on keybase.
  • I have a public key ASCv61L2W1k6pml_QwoWmDZl8fbJnc_1C9-wMPmpg5SvPAo

To claim this, I am signing this object:

# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""To run:
1. ``mkvirtualenv --python=/usr/bin/python3 crashids``
2. ``pip install -r requirements.txt``
3. ``python get_ids_1337688.py <ACCESS_KEY> <SECRET_ACCESS_KEY>``
--
-- Bug 1461321: signatures data migration
--
-- Used for a single data migration October 2018. We can delete it after
-- using it in stage and prod.
BEGIN WORK;
-- Crontabber has a job that updates these tables. We lock the tables here
-- to prevent it from updating the data while we're migrating.
--
-- Bug 1503383: drop everything
--
-- Drops all the stored procedures and things that we don't need anymore.
BEGIN WORK;
-- Drop functions
DROP FUNCTION IF EXISTS version_sort_digit(text) CASCADE;
DROP FUNCTION IF EXISTS major_version_sort(text) CASCADE;
@willkg
willkg / demozlog.py
Created April 19, 2019 13:57
make mozlog human readable
!/usr/bin/env python
"""
This de-mozlogifies a log line by line to make it readable by humans. To use:
tail -f /path/to/mozlog.log | python demozlog.py
"""
import datetime
@willkg
willkg / shell.py
Created April 30, 2019 15:48
Django interactive shell with preloaded models
!/usr/bin/env python
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
"""
Creates a shell that loads all the Django ORM models and puts them
in locals.
"""