Skip to content

Instantly share code, notes, and snippets.

View mindcruzer's full-sized avatar

mindcruzer mindcruzer

View GitHub Profile
@mindcruzer
mindcruzer / telemetry.py
Created January 15, 2016 05:46
Polling script for displaying AWS IoT thing temperature
# -*- coding: utf-8 -*-
import json
import time
import os
from boto3.session import Session
session = Session(aws_access_key_id='<access key>',
aws_secret_access_key='<secret key>',
@mindcruzer
mindcruzer / msp430_distance_measurement.c
Last active August 26, 2019 04:51
TI MSP430F5529 distance measurement with HC-SR04 ultrasonic range sensor.
#include <intrinsics.h>
#include <stdint.h>
#include <msp430.h>
#define TRIGGER_PIN BIT1 // P6.1
#define ECHO_PIN BIT3 // P1.3
#define LED_PIN BIT0 // P1.0
#define DISTANCE_THRESHOLD 60 // cm
#define MEASURE_INTERVAL 2048 // ~250 ms
"""
Convert a CSV file to a series of SQL INSERT statements.
ex.
> python csv_to_sql.py data.csv dbo.SomeTable > data.sql
"""
import sys
if len(sys.argv) != 3:
@mindcruzer
mindcruzer / number_to_words.py
Created May 9, 2015 05:06
Convert a number to its English description
ZERO = "zero"
DIGITS = ["one", "two", "three", "four", "five", "six", "seven", "eight", "nine"]
TEENS = ["ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "ninteen"]
TENS = ["twenty", "thirty", "forty", "fifty", "sixty", "seventy", "eighty", "ninety"]
GROUPS = ["hundred", "thousand", "million", "billion", "trillion"]
def number_to_words(n):
"""
Converts a number, n, into its English description.
"""
This is my answer to Exercise 3 in Chapter 2 of ThinkComplexity. It
works by cycling through the nodes in the graph, adding edges until
it is k-regular.
See: http://greenteapress.com/complexity/html/thinkcomplexity003.html
"""
def add_regular_edges(self, degree):
"""
"""
A zero-indexed array A consisting of N integers is given. An equilibrium
index of this array is any integer P such that 0 = P < N and the sum of
elements of lower indices is equal to the sum of elements of higher indices, i.e.
A[0] + A[1] + ... + A[P-1] = A[P+1] + ... + A[N-2] + A[N-1].
Sum of zero elements is assumed to be equal to 0. This can happen if
P = 0 or if P = N-1.
"""
I'm the CTO at a startup in London, so I'm spending a lot of my time interviewing developers
as we try to grow our team. As part of that, I ask each of them to do what I consider to
be a very simple programming exercise (See below.)
Yet, the results of this are disappointing. About 10% of candidates will be able to produce
a solution in 10 minutes or less, another 30% of candidates will eventually produce something
close to a solution in 30 minutes (though often with errors), and 60% of candidates will
simply be unable to produce anything close to a solution. These are not junior or graduate
developers, but senior, experienced programmers asking for £50k or £60k.