Skip to content

Instantly share code, notes, and snippets.

Hiring! See my profile for details.

Simon Whitaker simonwhitaker

Hiring! See my profile for details.
View GitHub Profile

Python: Type Aliases vs New Types

If you're a fan of Python type hinting, you may have noticed that there are two different ways to create your own types: type aliases and using the NewType helper.

Type aliases look like this:

Vector = list[float]

Take-home coding exercise: ShiftAdd

When completing the exercise, please consider the following:

  1. Allow no more than 3 hours to complete the exercise. (Mostly because I find it useful to set a limit, otherwise the temptation to just make one more change can be endless!)
  2. It's fine to use any resources that you could use in your job; Google, Stack Overflow, etc. But the code you submit should be your own.
  3. We use Python a lot at Shift Lab, so solutions in Python are preferred.
  4. Please include documentation explaining how to run your code



Setting up Pi-hole on Raspbian Stretch

Prepare your Pi

First off, you need a Raspberry Pi running the latest version of Raspbian ("Stretch"). If you don't already have a Pi, I really like this kit for £49 from Amazon. Once you have your Pi, grab the latest copy of Raspbian Stretch Lite and flash it to an SD card using Etcher. (That kit on Amazon comes with an SD card.)

Enable SSH

With the SD card still attached to your computer, create a file in the root of the SD card called ssh. The contents can be blank. On a Mac, you can do this easily in the Terminal app:

View matrix-compare.c
#include <stdio.h>
#include <Accelerate/Accelerate.h>
void print_matrix(const double *matrix, int rows, int cols) {
// for debugging
for (int i = 0; i < rows * cols; i++) {
printf("%.2f", matrix[i]);
if (i % cols == cols - 1) {
} else {
View gist:112645e318047aded6e005ce4912341b
MatrixDemo (master|✚1) $ time -l ./build/Release/MatrixDemo 2000 1000 1000 dumb
algorithm: dumb_matrix_multiply
Done! (332833500000.0) 14.05 real 14.00 user 0.04 sys
40906752 maximum resident set size
0 average shared memory size
0 average unshared data size
0 average unshared stack size
10001 page reclaims
0 page faults
0 swaps
View matrix-multiplication.c
#include <stdio.h>
#include <Accelerate/Accelerate.h>
int main(int argc, const char * argv[]) {
double A[] = {
1.0, 2.0, 3.0,
4.0, 5.0, 6.0
import numpy as np
A = [
[1.0, 2.0, 3.0],
[4.0, 5.0, 6.0]
B = [
[1.0, 2.0],
[3.0, 4.0],
View gist:42d8875b6da890479801
1. 4086
2. 10/11
3. 36
4. D
5. 11
6. 1
7. 6
8. 336
9. 36
10. 1/12
View gist:455ab01c47d4d1f37630
# A solution to
# Bonus points for only using three of the four available instructions??
start: left
goto start
loop: left
goto loop

Can't play videos in Vimeo for iOS

I'm unable to play videos in the app. I believe this is due to a known issue with NSDateFormatter when used to parse/format dates for machine-to-machine communication without setting a locale on the date formatter instance. This affects a number of locales, including the UK (but only when the phone is set to use the 12-hour clock); we see these kind of issues a lot!

Steps to reproduce

Note: you must use a physical iPhone – you can't repro this in the simulator.

  1. Set your phone's locale to UK: Settings > General > Language and Region, set Region to United Kingdom
  2. Set your phone to use the 12-hour clock: Settings > General > Date & Time, set 24-Hour Time to OFF