Skip to content

Instantly share code, notes, and snippets.

View willkg's full-sized avatar

Will Kahn-Greene willkg

View GitHub Profile
#!/bin/bash
# This is built to test a problem where if a try symbol is uploaded, it doesn't
# invalidate the cache and then future download attempts suggest the symbol
# doesn't exist (404).
# using a upload try token:
#
# head (404), upload (should invalidate cache), head (should be 200)
#
@willkg
willkg / crashdata_fetch.sh
Created May 20, 2021 19:43
Script to fetch crash annotations and minidumps from Crash Stats and put it in a directory tree.
!/bin/bash
# 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/.
#
# Run on the host with crashstats-tools installed.
#
# https://pypi.org/project/crashstats-tools/
#
@willkg
willkg / comp_and_upload.py
Created October 9, 2020 00:54
Script to compress files with makecab and upload
#!/usr/bin/env python
"""
October 8th, 2020. I wrote this to fix a problem where .dll and .exe files were getting
uploaded to symbols.mozilla.org, but hadn't been run through makecab. That prevented
them from getting served by symbols.mozilla.org and that broke debugging efforts.
I ran this script in WSL2 on Windows. It downloads files from the symbols bucket, runs
makecab on them, batches them up, and periodically uploads a symbols.zip file.
import logging
import os
import markus
from markus.main import MetricsFilter
logging.basicConfig(level=logging.DEBUG)
LOGGER = logging.getLogger(__name__)
@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.
"""
@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
--
-- 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;
--
-- 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.
# 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>``

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: