Skip to content

Instantly share code, notes, and snippets.

@michaeltandy
michaeltandy / setup-mapbox.sh
Last active November 15, 2022 06:45
Set up Tilemill on Ubuntu 12.04 and the OSM bright stylesheet and postgres/postgis and imposm and import OpenStreetMap data for the Isle of Wight (it's fairly small so it'll import quickly)
#!/bin/bash
# Based on http://www.mapbox.com/tilemill/docs/guides/osm-bright-ubuntu-quickstart/
sudo add-apt-repository --yes ppa:developmentseed/mapbox
sudo apt-get update
sudo apt-get --yes install tilemill libmapnik nodejs postgresql postgresql-9.1-postgis build-essential python-dev protobuf-compiler libprotobuf-dev libtokyocabinet-dev python-psycopg2 libgeos-c1 python-pip git
sudo pip install imposm
mkdir osm
@michaeltandy
michaeltandy / serializer.c
Created November 22, 2016 08:29
frama-c validation attempt for serializer and deserializer
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
const uint16_t MESSAGE_TYPE_A = 123;
typedef struct {
uint16_t messageType;
} Message;
@michaeltandy
michaeltandy / sendbreak.c
Last active January 2, 2016 04:28
Send a break to a serial/rs232 device from the terminal using tcsendbrake termios. I use this on OS X to soft-reset my mbed LPC1768. To compile: gcc -o sendbreak sendbreak.c Don't have gcc installed? I think it comes with xcode.
#include <termios.h>
#include <fcntl.h>
#include <stdio.h>
int main(int argc,char** argv) {
if (argc<2) {
printf("Usage: One parameter, the device to send the "
"break to. Example: %s /dev/tty.usbmodem622 \n",argv[0]);
} else {
int tty_fd = open(argv[1], O_RDWR | O_NONBLOCK);
@michaeltandy
michaeltandy / Inflate.java
Created October 4, 2015 21:48
Inflating hex data (IDAT section from a PNG file)
import java.io.*;
import java.util.Arrays;
import java.util.zip.InflaterInputStream;
import javax.xml.bind.DatatypeConverter;
public class Inflate {
public static void main(String[] args) throws Exception {
String input = "6881EDC1010D000000C2A0F74F6D0E37A00000000000000000BE0D21000001";
@michaeltandy
michaeltandy / uk-up-down-shortest.js
Created June 13, 2015 22:18
GeoJSON Contraction Hierarchies search. Map data (c) Open Street Map contributors.
This file has been truncated, but you can view the full file.
{"type":"FeatureCollection","features":[
{"type":"Feature","properties": {"stroke":"#ff0000"},"geometry": {"type": "LineString","coordinates": [[-0.106218,51.522217],[-0.108231,51.522064]]}},
{"type":"Feature","properties": {"stroke":"#ff0000"},"geometry": {"type": "LineString","coordinates": [[-0.110502,51.522018],[-0.108231,51.522064]]}},
{"type":"Feature","properties": {"stroke":"#ff0000"},"geometry": {"type": "LineString","coordinates": [[-0.107955,51.523087],[-0.108231,51.522064]]}},
{"type":"Feature","properties": {"stroke":"#ff0000"},"geometry": {"type": "LineString","coordinates": [[-0.113311,51.521507],[-0.110502,51.522018]]}},
{"type":"Feature","properties": {"stroke":"#ff0000"},"geometry": {"type": "LineString","coordinates": [[-0.110594,51.525040],[-0.107955,51.523087]]}},
{"type":"Feature","properties": {"stroke":"#ff0000"},"geometry": {"type": "LineString","coordinates": [[-0.105331,51.518532],[-0.108231,51.522064]]}},
{"type":"Feature","properties": {"stroke":"#ff0000"},"geometry": {"type": "Li