Skip to content

Instantly share code, notes, and snippets.

View groovecoder's full-sized avatar

luke crouch groovecoder

View GitHub Profile
KUMA_WIKI_IFRAME_ALLOWED_HOSTS regex:
^https?\:\/\/(developer-local.allizom.org|developer-dev.allizom.org|apps.playcanvas.com|developer.allizom.org|mdn.mozillademos.org|testserver|localhost\:8000|developer.cdn.mozilla.net|developer-local\:81|(www.)?youtube.com\/embed\/(\.*))
needs to match:
<iframe width="100%" height="300" src="//jsfiddle.net/sr88b8h2/1/embedded/" allowfullscreen="allowfullscreen" frameborder="0"></iframe>
+wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.7.deb
--2015-03-17 15:20:49-- https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.3.7.deb
Resolving download.elasticsearch.org (download.elasticsearch.org)... 2406:da00:ff00::36f3:4d9e, 2406:da00:ff00::36e1:85c3, 2406:da00:ff00::36e1:40a1, ...
Connecting to download.elasticsearch.org (download.elasticsearch.org)|2406:da00:ff00::36f3:4d9e|:443... connected.
ERROR: no certificate subject alternative name matches
requested host name `download.elasticsearch.org'.
To connect to download.elasticsearch.org insecurely, use `--no-check-certificate'.
import random
from locust import HttpLocust, TaskSet, task
class YahooSearchBehavior(TaskSet):
query_file = 'search_terms.txt'
def __init__(self, parent):
self.query_lines = open(self.query_file, 'r').read().splitlines()
(kuma)lcrouch-14912:kuma lcrouch$ curl -s -D - "https://developer.mozilla.org:443/en-US/search.json?q=html&amp;highlight=false" -o /dev/null
HTTP/1.1 200 OK
Server: Apache
Vary: Accept,Cookie
X-Backend-Server: developer3.webapp.scl3.mozilla.com
Content-Type: application/json
Access-Control-Allow-Credentials: false
Date: Mon, 23 Feb 2015 18:15:13 GMT
Transfer-Encoding: chunked
Access-Control-Allow-Origin: *
#!/usr/bin/env python
from datetime import datetime
import urllib
import requests
def _parse_github_datetime(datetime_string):
return datetime.strptime(datetime_string, '%Y-%m-%dT%H:%M:%SZ')
class KeyAction(models.Model):
"""Record of an action taken while using a key"""
key = models.ForeignKey(Key, related_name='history', db_index=True)
action = models.CharField(max_length=128, blank=False)
notes = models.TextField(null=True)
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey('content_type', 'object_id')
created = models.DateTimeField(auto_now_add=True)
class Key(models.Model):
"""Authentication key"""
user = models.ForeignKey(User, editable=False, db_index=True, blank=False,
null=False)
key = models.CharField(_("Lookup key"), max_length=64,
editable=False, db_index=True)
hashed_secret = models.CharField(_("Hashed secret"), max_length=128,
editable=False, db_index=False)
description = models.TextField(_("Description of intended use"),
blank=False)
models.py:
class Key(models.Model):
"""Authentication key"""
user = models.ForeignKey(User, editable=False, db_index=True, blank=False,
null=False)
key = models.CharField(_("Lookup key"), max_length=64,
editable=False, db_index=True)
hashed_secret = models.CharField(_("Hashed secret"), max_length=128,
editable=False, db_index=False)
from nose.tools import eq_, ok_
from pyquery import PyQuery as pq
from django.contrib.auth.models import Permission, User
from django.test import TestCase
from kuma.core.urlresolvers import reverse
from kuma.users.tests import user
from ..models import Key
diff --git a/kuma/actioncounters/migrations/0003_update_unique_hashes.py b/kuma/actioncounters/migrations/0003_update_unique_hashes.py
index 74e0ca5..5e15283 100644
--- a/kuma/actioncounters/migrations/0003_update_unique_hashes.py
+++ b/kuma/actioncounters/migrations/0003_update_unique_hashes.py
@@ -20,7 +20,7 @@ class Migration(DataMigration):
.delete())
# Update all remaining counters with a unique hash.
- from actioncounters.utils import get_unique
+ from kuma.actioncounters.utils import get_unique