Skip to content

Instantly share code, notes, and snippets.

@jgmize
jgmize / contentlengths.py
Created February 26, 2013 21:35
get URL content lengths using requests, a gevent process pool, and redis
#!/usr/bin/env python
import logging
import re
from gevent import monkey, spawn
from gevent.pool import Pool
monkey.patch_all()
from redis import Redis
import requests
@jgmize
jgmize / gist:6529655
Created September 11, 2013 20:54
Proposal of how to deal with legacy PHP lang param usage conflict with funfactory.middleware.LocaleURLMiddleware
from funfactory.middleware import LocaleURLMiddleware
from django.conf import settings
class ExceptionalLocaleURLMiddleware(LocalURLMiddleware):
"""
Replacement for funfactory.middleware.LocaleURLMiddleware that supports excluding
specific paths from getting redirected if a lang param is present in the request.
"""
def process_request(self, request):
if 'lang' in request.GET and request.path in getattr(
@jgmize
jgmize / legacy_release_note_map.py
Created January 23, 2014 00:31
Extract relations of releases to notes from legacy db to new schema in RNA
import json
from django.db.models import Q
from rna.models import Release, Note
def dump_release_notes_map(filename='release-notes-map.json'):
"used on the legacy side with the legacy models"
with open(filename, 'w') as f:
json.dump(
[(release.id, list(
@jgmize
jgmize / merge_conflict
Created February 12, 2014 21:38
merge conflict
{% if show_mobile %}
<small class="download-other os_android">
<a href="https://support.mozilla.org/kb/will-firefox-work-my-mobile-device">{{ _('Supported Devices') }}</a> |
<<<<<<< HEAD
<a href="{{ product_url('mobile', 'notes', build) }}">{{ _('What’s New') }}</a> |
<a href="/en-US/legal/privacy/firefox.html">{{ _('Privacy') }}</a>
=======
{% if build %}
<a href="/en-US/mobile/{{ build }}/notes">{{ _('What’s New') }}</a> |
{% else %}
@jgmize
jgmize / index.html
Last active August 29, 2015 14:02 — forked from enjalot/index.html
<!DOCTYPE html>
<meta charset="utf-8">
<style>
</style>
<body>
<script src="http://d3js.org/d3.v3.min.js"></script>
<svg width=960px height=500px>
<g transform='translate(166, 108)'>
<circle cx=142 cy=10 r=30 fill='#25B0B0'>
We couldn’t find that file to show.
@jgmize
jgmize / keybase.md
Created September 23, 2014 06:49
Keybase

Keybase proof

I hereby claim:

  • I am jgmize on github.
  • I am jgmize (https://keybase.io/jgmize) on keybase.
  • I have a public key whose fingerprint is 879B F8F5 CE76 1CD2 BFD6 F2E9 DBB1 76AA 9894 5BFE

To claim this, I am signing this object:

#!/usr/bin/env python
import mrjob.job
import mrjob.protocol
IP = 1
DOMAIN = 2
DATETIME = 4
METHOD = 5
URL = 6
@jgmize
jgmize / correlated_locale_redirects.py
Created September 29, 2014 05:39
correlated locale redirects
#!/usr/bin/env python
import re
import mrjob.job
import mrjob.protocol
IP = 1
DOMAIN = 2
DATETIME = 4