Skip to content

Instantly share code, notes, and snippets.

View springmeyer's full-sized avatar

Dane Springmeyer springmeyer

View GitHub Profile
@springmeyer
springmeyer / trim-white-edges.sh
Created January 17, 2014 03:02
fixup aerial for tilemill with gdal nearblack
nearblack -of GTIFF building.tif -o buildings_alpha.tif -white -setalpha -near 2
gdalwarp -t_srs EPSG:3857 buildings_alpha.tif buildings_merc.tiff
@springmeyer
springmeyer / testing-32-on-64.md
Created January 13, 2014 01:33
Testing 32 bit code on 64 bit systems

This commit contains some logic to be able to:

  • compile node-srs to 32 bit code
  • test it using a 32 bit version of node
  • all from a 64 bit operating system (either Ubuntu Linux or OS X)

Why 32 bit?

32 bit operating systems are becoming more and more rare as the days pass. All of us increasingly work with applications (like web browsers) or code (like node.js) where cpu architecture does not matter. Both browsers and node.js are written in C++ and the complexities of process architecture are hidden from us with the exception of the ability to ask node which architecture it was built for:

@springmeyer
springmeyer / README.md
Last active January 2, 2016 21:29
Mapnik demo of loading a single map and rendering each layer inside it. Originally forked example from https://gist.github.com/springmeyer/7459452

Mapnik example

This shows how to programmatically turn on and off layers on a Mapnik map from python.

Then the map is rendered twice to show how only active layers are displayed.

Depends

Mapnik >= 2.2 and the python bindings

@springmeyer
springmeyer / bootstrap-clang-precise.sh
Created December 19, 2013 19:10
boostrap clang based compile on ubuntu precise
git clone https://github.com/mapnik/mapnik-packaging.git
cd mapnik-packaging
export CXX11=true
export CXX="clang++"
export CC="clang"
wget http://llvm.org/releases/3.3/clang+llvm-3.3-amd64-Ubuntu-12.04.2.tar.gz
tar xf clang+llvm-3.3-amd64-Ubuntu-12.04.2.tar.gz
mv clang+llvm-3.3-amd64-Ubuntu-12.04.2 /home/ubuntu/clang-3.3
export PATH=/home/ubuntu/clang-3.3/bin:$PATH
export LD_LIBRARY_PATH=/home/ubuntu/clang-3.3/lib
@springmeyer
springmeyer / libzip-open-crash.c
Created December 17, 2013 15:19
libzip crash testcase on invalid data
#include <errno.h>
#include <zip.h>
/*
Test on OS X:
brew install libzip
# create bogus file like:
echo 'bogus data' > bogus.zip
clang -o testcase libzip-open-crash.c -I/usr/local/opt/libzip/include/ -I/usr/local/opt/libzip/lib/libzip/include/ -L/usr/local/opt/libzip/lib/ -lzip
@springmeyer
springmeyer / build-osrm-against-mapnik-sdk.sh
Last active December 31, 2015 06:59
Build OSRM against custom directories and with custom C++ compiler flags
SDK_DIR=/Users/dane/projects/mapnik-packaging/osx/out/build-libc++-x86_64
export CXXFLAGS="-std=c++11 -stdlib=libc++"
export LINK_FLAGS="-std=c++11 -stdlib=libc++"
rm -rf build/ && mkdir build/ && cd build/
cmake ../ -DWITH_TOOLS=1 \
-DCMAKE_BUILD_TYPE=Release \
-DBoost_NO_SYSTEM_PATHS=ON \
-DCMAKE_INCLUDE_PATH=${SDK_DIR}/include \
-DCMAKE_LIBRARY_PATH=${SDK_DIR}/lib
make VERBOSE=1 -j8
@springmeyer
springmeyer / gist:7916411
Created December 11, 2013 19:05
test node-osmium binary
# requires node v0.10.x
npm install https://github.com/osmcode/node-osmium/tarball/pre-gyp
wget http://download.geofabrik.de/europe/germany/berlin-latest.osm.pbf
node -e "console.log(require('osmium'))"
@springmeyer
springmeyer / test.js
Created December 10, 2013 22:57
simply node-osmium.js testcase
var osmium = require('./');
var reader = new osmium.Reader('test/data/berlin-latest.osm.pbf',{node:true});
var handler = new osmium.Handler();
handler.on('node',function(node) { });
reader.apply(handler);
reader.close();
@springmeyer
springmeyer / node-c++-perf.md
Last active April 27, 2016 15:06
Node.js C++ addon performance tips

Don't use String::NewSymbol

String::NewSymbol is recommended by v8 docs for wrapping string data that represent commonly used keys. The reason is for lookups to be faster (https://bugs.webkit.org/show_bug.cgi?id=104082#c0). But in testing this is actually usually a deoptimization because creating new symbols is slower than strings. This is confirmed by this Node.js core commit Remove v8::String::NewSymbol() entirely: https://github.com/joyent/node/commit/f674b09f40d22915e15b6968aafc5d25ac8178a2. More details: https://bugs.webkit.org/show_bug.cgi?id=94574#c10

Typed Arrays

can be done in node.js like nodejs/node-v0.x-archive#4201 (comment)

other resources:

#!/bin/bash
# Settings: edit these as needed
PROJECT_NAME="test"
OUTPUT_DIRECTORY="~/Documents/MapBox/export/"
# first change into TileMill code directory
cd /Applications/TileMill.app/Contents/Resources/
# hint: use http://bboxfinder.com/ to get bounds in lon/lat