Skip to content

Instantly share code, notes, and snippets.

@jgraham
jgraham / htmlparser.py
Created February 12, 2012 12:58
HTMLParser backed by html5lib
import tokenizer
from constants import tokenTypes, tagTokenTypes
class HTMLParser(object):
def __init__(self):
self.reset()
def reset(self):
self._tokenizer = None
pass
@jgraham
jgraham / timeout.diff
Created May 8, 2012 15:20
Add possibility to disable / explicitly control timeouts
diff -r 639d5836906a apisample3.htm
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/apisample3.htm Tue May 08 17:17:26 2012 +0200
@@ -0,0 +1,17 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<title>Sample HTML5 API Tests</title>
+</head>
+<script src="testharness.js"></script>
@jgraham
jgraham / gist:6356797
Created August 27, 2013 17:54
Structured logging logger.
class StructuredLogger(object):
def __init__(self):
self._log = logger
def _test_log_func(level_name):
def log(self, params):
all_params = {"_thread":threading.current_thread().name,
"_process":multiprocessing.current_process().name}
all_params.update(params)
self._log.log_structured(level_name, all_params)
This file has been truncated, but you can view the full file.
{
"items": {
"reftest": [
{
"url": "/html/dom/elements/global-attributes/dir_auto-EN-L.html",
"path": "html/dom/elements/global-attributes/dir_auto-EN-L.html",
"ref_type": "==",
"ref_url": "/html/dom/elements/global-attributes/dir_auto-EN-L-ref.html"
},
{
set -e
echo "Ensure server and celery are running and press Enter"
read
sed -i 's|BUILDAPI_BUILDS4H_URL = ".*"|BUILDAPI_BUILDS4H_URL = "https://secure.pub.build.mozilla.org/builddata/buildjson/builds-2015-11-03.js.gz"|' treeherder/config/settings.py
python manage.py ingest_push mozilla-inbound 2530cf72c8e7
echo "Wait for log parsing mark push, then press Enter"
read
python manage.py ingest_push mozilla-inbound c615bf9eae4f
import cPickle
import re
import os
from collections import defaultdict
import numpy
from sklearn.feature_extraction import DictVectorizer
from sklearn.linear_model import SGDClassifier
from treeherder.model.models import Job