Skip to content

Instantly share code, notes, and snippets.

View jwhitlock's full-sized avatar

John Whitlock jwhitlock

View GitHub Profile
@jwhitlock
jwhitlock / 2022-06-mypy-demo.md
Last active December 12, 2023 13:44
Converting fx-private-relay to use mypy

Converting fx-private-relay to use mypy

Notes for an interactive class or video

Overview

  • Intro to private relay if video
  • Starting with tag v3.5.14
    • Python 3.9 - I'm using 3.9.11
  • Django 3.2.13 - LTS version, extended support until April 2024.
@jwhitlock
jwhitlock / find_staticfiles.cmd
Created March 10, 2022 17:23
Staticfiles in mozilla/fxprivaterelay:v3.2.6 image
docker run --rm -it --entrypoint /bin/sh mozilla/fxprivaterelay:v3.2.6 -c "find staticfiles"
FROM python:3.10.1-slim
RUN apt-get update && \
apt-get -y install git libgeos-dev build-essential
RUN pip install \
numpy==1.21.4 \
cython==0.29.26
RUN pip install --verbose --no-binary=shapely \
"git+https://github.com/shapely/shapely@maint-1.8#egg=shapely"
RUN python -c "import sys; from shapely import speedups; sys.exit(not speedups.available)"
@jwhitlock
jwhitlock / Dockerfile
Last active December 17, 2021 15:49
shapely issue #1263, but fixed
FROM python:3.10.1-slim
RUN apt-get update && \
apt-get -y install git libgeos-dev build-essential
RUN pip install \
numpy==1.21.4 \
cython==0.29.26
RUN pip install --verbose --no-binary=shapely \
"git+https://github.com/shapely/shapely@907c7ee19219b74c45e032f085d3dd3020e0544d#egg=shapely"
RUN python -c "import sys; from shapely import speedups; sys.exit(not speedups.available)"
@jwhitlock
jwhitlock / Dockerfile
Created December 16, 2021 23:21
shapely issue #1263, full build
FROM python:3.10.1-slim
RUN apt-get update && \
apt-get -y install libgeos-dev
RUN pip install numpy cython
RUN pip install --no-binary=shapely shapely==1.8.0
RUN python -c "import sys; from shapely import speedups; sys.exit(not speedups.available)"
@jwhitlock
jwhitlock / shell.txt
Last active December 16, 2021 16:29
Demo of using pmac to update Ichnaea dependencies
Last login: Tue Dec 14 10:43:03 on ttys003
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
[I] john@johnwhitlock-4zq05n ~/s/ichnaea (main)> vf activate ichnaea
[I] john@johnwhitlock-4zq05n ~/s/ichnaea (main)> git co main
Already on 'main'
Your branch is up to date with 'origin/main'.
[I] john@johnwhitlock-4zq05n ~/s/ichnaea (main)> git pull
Already up to date.
[I] john@johnwhitlock-4zq05n ~/s/ichnaea (main)> git co -b dep-updates-dec-2021-part1
@jwhitlock
jwhitlock / get_fs_data.py
Created October 28, 2021 19:21
Get data from FxA firestore
#! /usr/bin/env python3
"""
Get data from FxA firestore.
Runs from within the Google Application environment using baked in credentials.
"""
from __future__ import annotations
import argparse
import json
@jwhitlock
jwhitlock / task.yml
Last active August 20, 2021 16:13
Taskcluster task for Poucave issue #851
taskQueueId: proj-taskcluster/gw-ci-ubuntu-18-04
schedulerId: taskcluster-ui
created: '2021-08-20T16:06:31.635Z'
deadline: '2021-08-20T19:06:31.635Z'
payload:
command:
- - /bin/bash
- -c
- which python3 && python -V && which curl && curl --version
- - /bin/bash
@jwhitlock
jwhitlock / output.txt
Created April 27, 2021 20:05
Python3 sets vs lists
Timing set_in_loop... 1.063s
Timing list_in_loop... 1.835s
Timing set_out_loop... 1.093s
Timing list_out_loop... 1.998s
function time factor
set_in_loop 1.063s (1.0x)
set_out_loop 1.093s (1.0x)
list_in_loop 1.835s (1.7x)
@jwhitlock
jwhitlock / utctest.py
Created December 11, 2020 16:24
Compare pytz's UTC to Python 3.9's UTC
from datetime import datetime
from zoneinfo import ZoneInfo
from pytz import UTC
ziUTC = ZoneInfo("UTC")
assert UTC != ziUTC
now = datetime.utcnow()
pytz_now = now.replace(tzinfo=UTC)
zoneinfo_now = now.replace(tzinfo=ziUTC)