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
# -*- 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>', |
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
#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 |
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
""" | |
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: |
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
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 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
""" | |
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): | |
""" |
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
""" | |
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. | |
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
""" | |
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. |