Skip to content

Instantly share code, notes, and snippets.

View simonwhitaker's full-sized avatar

Simon Whitaker simonwhitaker

View GitHub Profile
@simonwhitaker
simonwhitaker / Local Host Privacy Notice.md
Last active February 5, 2023 22:34
Local Host Privacy Notice

Privacy Notice for Local Host

Local Host doesn't collect any of your data. Nothing.

  • It does not connect to any external services
  • It does not show ads
  • It does not attempt to monetise you in any way.

I hope you enjoy Local Host! If you have any questions about this privacy notice, drop me a line on hi@s1mn.io and I'll be happy

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

Specification

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:

#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) {
printf("\n");
} else {
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
#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],
1. 4086
2. 10/11
3. 36
4. D
5. 11
6. 1
7. 6
8. 336
9. 36
10. 1/12
# A solution to http://david-peter.de/parachuting-robots/
#
# Bonus points for only using three of the four available instructions??
start: left
skipNext
goto start
loop: left
left
goto loop