Skip to content

Instantly share code, notes, and snippets.


Simon Whitaker simonwhitaker

View GitHub Profile

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
View dogshit.swift
let opts: NSJSONReadingOptions = NSJSONReadingOptions(
rawValue: NSJSONReadingOptions.MutableContainers.rawValue
| NSJSONReadingOptions.MutableLeaves.rawValue
View json-snippet.swift
// Error: Cannot invoke 'JSONObjectWithData' with an argument list of type '(NSData, options: Int)'
NSJSONSerialization.JSONObjectWithData(data!, options: 0)
// Error: Type 'NSJSONReadingOptions' does not conform to protocol 'NilLiteralConvertible'
NSJSONSerialization.JSONObjectWithData(data!, options: nil)
// This works, but having to pass in 'rawValue' just feels hacky
NSJSONSerialization.JSONObjectWithData(data!, options: NSJSONReadingOptions(rawValue: 0))
// I'd expect to be able to do something like: