Skip to content

Instantly share code, notes, and snippets.

View jwhitlock's full-sized avatar

John Whitlock jwhitlock

View GitHub Profile
@jwhitlock
jwhitlock / bpz2.out
Last active August 29, 2015 14:06
BPZAround.me - heroku web worker, RDS database
jmbp:~ john$ git clone git@github.com:jwhitlock/BPZAround.me.git
Cloning into 'BPZAround.me'...
remote: Counting objects: 669, done.
remote: Compressing objects: 100% (299/299), done.
remote: Total 669 (delta 330), reused 647 (delta 318)
Receiving objects: 100% (669/669), 2.03 MiB | 989.00 KiB/s, done.
Resolving deltas: 100% (330/330), done.
Checking connectivity... done.
jmbp:~ john$ git st
fatal: Not a git repository (or any of the parent directories): .git
@jwhitlock
jwhitlock / unknown_versions.py
Created May 22, 2015 19:37
Gather unknown versions from web-platform-compat MDN import
#!/usr/bin/env python
"""Gather the unknown versions from a web-platform-compat MDN import
This assumes that data/import_issues_by_url.csv has been generated by
running tools/gather_import_issues.py.
The output is csv data that could be redirected to a file.
"""
import csv
@jwhitlock
jwhitlock / inline_texts.py
Last active August 29, 2015 14:23
Find the most common inline_text issues for browsercompat.com
#!/usr/bin/env python
from __future__ import print_function
import csv
import json
import sys
if len(sys.argv) != 2:
print("Usage: {} import_issues_by_url.csv".format(sys.argv[0]))
sys.exit(0)
@jwhitlock
jwhitlock / diff_issues.py
Last active August 29, 2015 14:23
Calculate differences between two browsercompat issues counts, and format as MarkDown
#!/usr/bin/env python
from __future__ import print_function
import csv
import sys
if len(sys.argv) != 3:
print("Usage: {} older_count.csv newer_count.csv".format(sys.argv[0]))
sys.exit(0)
@jwhitlock
jwhitlock / graph_temps.py
Last active August 29, 2015 14:25
Plot home temperatures
#!/usr/bin/env python
"""Print temperature data from dm0-dev
Based on code from:
http://stackoverflow.com/questions/19079143/how-to-plot-time-series-in-python
Besides standard library, requires matplotlib and numpy.
See http://www.scipy.org/install.html for install packages
"""
from __future__ import print_function
@jwhitlock
jwhitlock / suggest_slugs.py
Created November 17, 2015 21:00
Generate a CSV of proposed new slugs
#!/usr/bin/env python
"""Generate a CSV of new slugs."""
from collections import namedtuple, OrderedDict
from csv import writer as csv_writer
from hashlib import md5 as hashlib_md5
from json import load as json_load
from string import ascii_lowercase, digits
from urllib import unquote_plus
from urlparse import urlparse
#!/usr/bin/python
import logging
import socket
import time
from urllib2 import urlopen, URLError, HTTPError
from AppKit import CWInterface
starttime=time.time()
@jwhitlock
jwhitlock / reset_scrape.py
Last active March 25, 2016 16:09
BC: Manually reset scrape
# heroku run --app browsercompat ./manage.py shell_plus
from mdn.models import FeaturePage
from mdn.tasks import start_crawl
other = [
FeaturePage.STATUS_STARTING, # 0
FeaturePage.STATUS_META, # 1
FeaturePage.STATUS_PAGES, # 2
FeaturePage.STATUS_PARSING, # 3
FeaturePage.STATUS_ERROR, # 5
@jwhitlock
jwhitlock / modify_mdn_locale_headers.sh
Created May 11, 2016 03:19
Modify the locale file headings for the MDN project
#!/bin/bash
# Replaces headers in locale files
# Run from the locale folder
for LANG in `ls`
do
# Derived from product details' language.json
# search-and-replace to get into bash case syntax
# dashes replaced with underscores
case $LANG in
@jwhitlock
jwhitlock / spam_edits_90.py
Last active May 26, 2016 12:41
Report on spam edits for last 90 days, and how long they were published
#!/usr/bin/env python
from csv import writer
from datetime import datetime, timedelta
from os.path import expanduser
from pyquery import PyQuery as pq
from six.moves.urllib.parse import urlparse
from kuma.wiki.models import Document, Revision, RevisionAkismetSubmission