Skip to content

Instantly share code, notes, and snippets.

View nottrobin's full-sized avatar

Robin Winslow nottrobin

View GitHub Profile
diff --git a/docs/.env b/docs/.env
index b24647eb..9f09d4cb 100644
--- a/docs/.env
+++ b/docs/.env
@@ -1 +1,2 @@
-PORT=8104
\ No newline at end of file
+PORT=8104
+FLASK_DEBUG=true
\ No newline at end of file
@nottrobin
nottrobin / yarn-npm-speed-test.md
Last active April 17, 2019 19:52
Benchmark tests for Yarn vs NPM speed

Yarn vs NPM speed test

Work in progress

I recently made a claim on Twitter that yarn is still significantly faster than npm for installing NodeJS dependencies.

My belief here was based on some light research I did near the end of 2017, not too long after NPM 5 was released claiming huge speed improvements. I found a blog post at the time claiming Yarn was still faster, and then did some light testing which confirmed this for me, by a large margin.

However, my assertion was challenged:

# HELP wsgi_latency Multiprocess metric
# TYPE wsgi_latency histogram
wsgi_latency_sum{method="GET",status="200",view="flask.helpers.static"} 23.605999999999998
wsgi_latency_sum{method="GET",status="200",view="app.homepage"} 8083.161
wsgi_latency_sum{method="GET",status="304",view="flask.helpers.static"} 5.361
wsgi_latency_sum{method="GET",status="200",view="app.cloud_and_server"} 2901.036
wsgi_latency_bucket{le="4.0",method="GET",status="200",view="flask.helpers.static"} 4.0
wsgi_latency_bucket{le="8.0",method="GET",status="200",view="flask.helpers.static"} 7.0
wsgi_latency_bucket{le="16.0",method="GET",status="200",view="flask.helpers.static"} 7.0
wsgi_latency_bucket{le="32.0",method="GET",status="200",view="flask.helpers.static"} 7.0
@nottrobin
nottrobin / first-non-ready-pod.sh
Last active March 14, 2019 00:25
Get first non-ready kubernetes pod
app=maas.io
deployment_failed_reason=$(kubectl get deployment --namespace staging --selector app=${app} -o=jsonpath='{.items[0].status.conditions[1].reason}')
if [ "${deployment_failed_reason}" == "ProgressDeadlineExceeded" ]; then
non_ready_pod=$(kubectl get pod --namespace staging --selector app=${app} --output json | jq -r '(.items | map(select(.status.containerStatuses[0].ready==false)))[0].metadata.name')
kubectl logs ${non_ready_pod} --namespace staging
fi
@nottrobin
nottrobin / replace-images.py
Created February 28, 2019 16:55
To replace images in www.ubuntu.com
#! /usr/bin/env python3
# Standard library
import re
from io import BytesIO
from glob import glob
from PIL import Image
from urllib.parse import urlparse, parse_qs
from urllib.request import urlopen
from xml.etree import ElementTree
@nottrobin
nottrobin / converting-juju-docs.sh
Last active February 15, 2019 14:23
Converting juju docs
# Get juju-docs and discoursifier
git clone -b devel https://github.com/juju/docs ~/git/juju-docs
git clone https://github.com/canonical-webteam/discoursifier ~/git/discoursifier
# Setup python venv for discoursifier
python3 -m venv ~/git/discoursifier/env3
source ~/git/discoursifier/env3/bin/activate
pip install -r ~/git/discoursifier/requirements.txt
# Enter the documentation directory
# Get the codebase
git clone git+ssh://{username}@git.launchpad.net/crbs
# Start a new LXC container
lxc launch ubuntu:bionic crbs
# Share the local repository folder with the container (at ~/crbs)
setfacl -Rm user:lxd:rwx,default:user:lxd:rwx,user:165536:rwx,default:user:165536:rwx,user:166536:rwx,default:user:166536:rwx . # Add permissions for the LXD users
lxc config device add crbs crbs-repo disk source=`pwd` path=/home/ubuntu/crbs # Share the folder as a LXD device
@nottrobin
nottrobin / finding-uid-of-lxc-containers.md
Created February 5, 2019 15:02
Find the user IDs of LXC containers, for either Snap or Deb installs

First we need to find the user ID of the container's user.

LXD might be installed in one of two ways. You can tell which, by running:

$ which lxc
/usr/bin/lxc  # This means it's installed as a deb
# OR
/snap/bin/lxc  # This means it's installed as a snap
[tool.poetry]
name = "django-project"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.5"
django = "^2.1"
[tool.poetry]
name = "django-project"
version = "0.1.0"
description = ""
authors = ["Your Name <you@example.com>"]
[tool.poetry.dependencies]
python = "^3.5"
[tool.poetry.dev-dependencies]