Skip to content

Instantly share code, notes, and snippets.

View niqueco's full-sized avatar

Nicolás Lichtmaier niqueco

  • Buenos Aires, Argentina
View GitHub Profile
@niqueco
niqueco / PolylineDecoder.m
Last active December 31, 2015 20:27
Google Maps polyline decoder in Wolfram Mathematica
(* Decoder for polylines as defined in https://developers.google.com/maps/documentation/utilities/polylinealgorithm
*)
decodePolyline[encoded_String] := Module[{deltas},
deltas = With[{x = FromDigits[#, 32]},
If[OddQ[x], -BitShiftRight[x, 1] - 1, BitShiftRight[x, 1]]
] & /@ Reverse[BitAnd[ToCharacterCode@StringCases[encoded, RegularExpression["[_-~]*[ -\\^]"]] - 63, BitNot@32], 2];
Rest@FoldList[Plus, {0, 0}, Partition[deltas / 100000., 2]]
@niqueco
niqueco / tintninepatch
Created December 12, 2014 02:43
Utility to "tint" an Android nine-patch file without breaking it using ImageMagick
#! /bin/bash
set -e
if [ $# -lt 2 ]; then
echo Usage: >&2
echo " $0 color image..." >&2
exit 1
fi