Skip to content

Instantly share code, notes, and snippets.

Peter Bengtsson peterbe

View GitHub Profile
View crawl-cdn-hit-rate-most-common-pages-GET.py
import concurrent.futures
import random
import time
import statistics
from collections import defaultdict
from urllib.parse import urlparse
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
View gist:4139c960aa78067b7cbe571da7772b94
web_1 | /usr/local/lib/python2.7/site-packages/django/template/backends/jinja2.py:6: ImportWarning: Not importing directory '/app/jinja2': missing __init__.py
web_1 | import jinja2
web_1 | /usr/local/lib/python2.7/site-packages/django/template/backends/jinja2.py:6: ImportWarning: Not importing directory '/app/jinja2': missing __init__.py
web_1 | import jinja2
web_1 | /usr/local/lib/python2.7/site-packages/django/template/backends/jinja2.py:6: ImportWarning: Not importing directory '/app/jinja2': missing __init__.py
web_1 | import jinja2
web_1 | /usr/local/lib/python2.7/site-packages/django/template/backends/jinja2.py:6: ImportWarning: Not importing directory '/app/jinja2': missing __init__.py
web_1 | import jinja2
web_1 | /app/kuma/core/i18n.py:18: ImportWarning: Not importing directory '/app/kuma/core/jinja2': missing __init__.py
web_1 | from jinja2 import nodes
View builtin_banners.py
from django.utils.translation import ugettext_lazy as _
FILTER_NAMES = {
'developer_needs': {
'title': _('MDN Developer Survey'),
'body': _('...'),
},
'maintenance_mode': {
'title': _('In Maintenance Mode'),
'body': _('Check back in again at %(date)s.'),
View banners-content.jinja
{% macro banner_developer_needs(url) %}
<h2 class="mdn-cta-title">
{{ _('MDN Developer Survey') }}
</h2>
<p class="mdn-cta-copy">
{{ _('We want to learn more about the needs of developers') }}
</p>
<p class="mdn-cta-button-container">
<a
View gist:1d64492d37aea10fa054030b116f78e1
▶ python crawl-cdn-hit-rate-most-common-pages-GET.py
/en-US/docs/Web/API/Element/getAttribute Hit from cloudfront
/en-US/docs/Web/API/Event/preventDefault Miss from cloudfront
/en-US/docs/Web/API/Fetch_API/Using_Fetch Miss from cloudfront
/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace Miss from cloudfront
/en-US/docs/Learn/Getting_started_with_the_web/HTML_basics Miss from cloudfront
/en-US/docs/Web/JavaScript/Reference/Functions/arguments Miss from cloudfront
/en-US/docs/Web/API/Element/innerHTML Miss from cloudfront
/en-US/docs/Web/API/HTMLImageElement/Image Miss from cloudfr
View crawl-cdn-hit-rate.py
import concurrent.futures
import random
from urllib.parse import urlparse
import pyquery
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
import requests_cache
View download-svgs.py
import hashlib
import os
import shutil
from collections import defaultdict
from glob import glob
from subprocess import check_call
import pyquery
View gist:aedaccba8f98df77897a10bdbade19d7
MOZILLA/MDN/kuma master ✔
▶ docker-compose up
Starting kuma_mysql_1 ... done
Starting kuma_redis_1 ... done
Starting kuma_elasticsearch_1 ... done
Recreating kuma_api_1 ... done
Recreating kuma_kumascript_1 ... done
Recreating kuma_web_1 ... done
Recreating kuma_worker_1 ... done
Attaching to kuma_redis_1, kuma_mysql_1, kuma_elasticsearch_1, kuma_api_1, kuma_kumascript_1, kuma_web_1, kuma_worker_1
View prodscrape.py
import datetime
import os
from urllib.parse import urljoin, urlparse
from collections import namedtuple
import pyquery
import click
import requests
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
View gist:b73bdf345f33b9caef2e534311e0582d
~/dev
▶ time rg -t txt therapist
MOZILLA/whatsdeployed/dev-requirements.txt
4:therapist==1.6.0 \
PYTHON/hashin/lint-requirements.txt
3:therapist==1.6.0
KINTO/kinto/lint-requirements.txt
1:therapist==1.6.0 \
You can’t perform that action at this time.