Skip to content

Instantly share code, notes, and snippets.

@wcmatthysen
wcmatthysen / import-osm-data.txt
Last active February 19, 2019 10:49
Import OSM-data into Postgres-database.
# Normal command on a country-file.
osm2pgsql --create --hstore --slim -U postgres -d osm-country -H localhost --style openstreetmap-carto.style country.osm.pbf
# Command for planet-wide import.
osm2pgsql --create --number-processes 6 --flat-nodes /tmp/flat_nodes.bin --cache 8000 --hstore --slim -U postgres -W -d osm-world -H localhost --style openstreetmap-carto.style ~/planet-latest.osm.pbf
@wcmatthysen
wcmatthysen / rm-eq-files.sh
Last active October 5, 2016 17:15
Remove all files in directory that are copies of given file.
#!/bin/sh
find "$2" -type f -exec sh -c 'cmp --silent "{}" "$1"; if [ $? -eq 0 ]; then rm "{}"; fi' \;
@wcmatthysen
wcmatthysen / rotate-libgdx-matrix-math.txt
Last active February 19, 2019 10:51
libgdx: rotate a rectangle shape (matrix math calculation).
Rectangle rectangle = (Rectangle)shape;
Vector2 center = new Vector2();
rectangle.getCenter(center);
Affine2 transform = new Affine2();
transform.translate(rectangle.x, rectangle.y + rectangle.height);
transform.rotate(-rotation);
transform.translate(-rectangle.x, -rectangle.y - rectangle.height);
transform.applyTo(center);
@wcmatthysen
wcmatthysen / rotate-libgdx-trig.txt
Last active February 19, 2019 10:51
libgdx: rotate a rectangle shape (manual math calculation).
Rectangle rectangle = (Rectangle)shape;
Vector2 center = new Vector2();
rectangle.getCenter(center);
float centerX = center.x - rectangle.x;
float centerY = center.y - rectangle.y - rectangle.height;
float cos = MathUtils.cosDeg(rotation);
float sin = MathUtils.sinDeg(rotation);
float x = centerX * cos + centerY * sin;