This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Converts JSON into a flat, line-by-line format | |
# Equivalent to https://github.com/soheilpro/catj | |
# Borrowed from this HN comment: https://news.ycombinator.com/item?id=20246957 | |
exec jq -r ' | |
tostream | |
| select(length > 1) | |
| ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
ncso.date AS month, | |
vmpp.bnf_code AS bnf_code, | |
vmpp.nm AS product_name, | |
rx.quantity AS quantity, | |
rx.pct AS pct, | |
rx.practice AS practice, | |
dt.price_pence | |
* rx.quantity | |
* CASE WHEN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import time | |
import sys | |
import lmdb | |
import numpy | |
import pyarrow | |
import scipy.sparse | |
#import zstandard |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import csv | |
import itertools | |
import sys | |
import lmdb | |
import numpy | |
import pyarrow | |
import scipy.sparse |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eo pipefail | |
# https://stackoverflow.com/a/8574392/79992 | |
contains_element () { | |
local e match="$1" | |
shift | |
for e; do [[ "$e" == "$match" ]] && return 0; done | |
return 1 | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf import settings | |
from django.core.exceptions import MiddlewareNotUsed | |
from django.http import HttpResponse | |
class BasicAuthMiddleware(object): | |
""" | |
Adds HTTP Basic Authentication site-wide | |
Useful for protecting staging/demo environments. Additionally, sets auth details |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import collections | |
import json | |
import sys | |
MISSING = object() | |
class ConflictError(Exception): pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo add-apt-repository ppa:morgwai/tpbat | |
sudo apt update | |
sudo apt install tpacpi-bat | |
# Start charging at 40%, stop charging at 80% | |
echo '[Unit] | |
Description=sets battery thresholds | |
[Service] | |
Type=oneshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from whitenoise import WhiteNoise | |
class WhiteNoiseIndex(WhiteNoise): | |
index_file = 'index.html' | |
def add_files(self, *args, **kwargs): | |
super(WhiteNoiseIndex, self).add_files(*args, **kwargs) | |
index_urls = [url for url in self.files.keys() if url.endswith('/' + self.index_file)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# make a quick 30-second gif screencast | |
alias gifcast='byzanz-record -v -c -d 30 --delay 5 screencast.gif' |