Skip to content

Instantly share code, notes, and snippets.

View andrewharvey's full-sized avatar

Andrew Harvey andrewharvey

View GitHub Profile
@andrewharvey
andrewharvey / index.html
Last active September 20, 2022 10:21
Mapbox GL JS Text Styled as Link on Hover
<!DOCTYPE html>
<html>
<head>
<meta charset='utf-8' />
<title></title>
<meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />
<script src='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.js'></script>
<link href='https://api.tiles.mapbox.com/mapbox-gl-js/v0.38.0/mapbox-gl.css' rel='stylesheet' />
<style>
body { margin:0; padding:0; }
@andrewharvey
andrewharvey / tilecache_cache_size_
Created August 28, 2011 02:07
Munin Plugin to monitor the disk usage of a TileCache Disk Cache
#!/bin/bash
# This is a Munin plugin to report the disk usage of TileCache disk caches.
# Use it by linking with the name tilecache_cache_size_LAYERNAME
# The "standard" way to install this script for Munin is to place it in /usr/share/munin/plugins/
# and then run (replacing LAYERNAME with the TileCache layer name as in tilecache.cfg)
# ln -s -T /usr/share/munin/plugins/tilecache_cache_size_ /etc/munin/plugins/tilecache_cache_size_LAYERNAME
# Author: Andrew Harvey <andrew.harvey4@gmail.com>
@andrewharvey
andrewharvey / shape_merge
Created December 17, 2015 06:06
Merge many Shape files together using ogr2ogr
#!/bin/bash
dest_dir="output"
dest_layer="shape_file"
mkdir -p "${dest_dir}"
i=0
for src_file in source/*.shp ; do
echo "Reading ${src_file}"
@andrewharvey
andrewharvey / countTiles.py
Created January 25, 2012 09:23
Given a WGS84 bounding box and an OSM tile zoom range calculates a total number of tiles.
#!/usr/bin/python
# This script should be considered CC0 licensed
# the deg2num function is from http://wiki.openstreetmap.org/wiki/Slippy_map_tilenames#lon.2Flat_to_tile_numbers_2
import math
def deg2num(lat_deg, lon_deg, zoom):
lat_rad = math.radians(lat_deg)
n = 2.0 ** zoom
@andrewharvey
andrewharvey / SideWalksPlus.mapcss
Created June 28, 2021 11:13
Sidewalks Plus JOSM Map Style, derived from https://josm.openstreetmap.de/wiki/Styles/Sidewalks with enhanced :left :right and separate support.
meta {
title: "Sidewalks Plus";
description: "Visualizes the sidewalk attribute of highways. sidewalk=* is rendered as a thick dashed line, separately mapped sidewalks tagged footway=sidewalk are rendered thicker.";
link: "https://wiki.openstreetmap.org/wiki/Key:sidewalk";
author: "Cobra;Aharvey";
version: "0.7_2021-06-28";
min-josm-version: "4399";
}
meta[lang=de] {
@andrewharvey
andrewharvey / listFontsByStyle.js
Last active April 20, 2021 12:33
Lists fonts used within a Mapbox account, which fonts each Style is using, and which Styles are using each font. Useful for knowing which fonts you can clear out of your account to keep under the 100 fonts limit.
#!/usr/bin/env node
/* eslint-disable */
const MapboxClient = require('.');
const MapboxStyles = require('./services/styles');
const MapboxFonts = require('./services/fonts');
const fs = require('fs');
const fontsService = MapboxFonts({ accessToken: process.env.MAPBOX_ACCESS_TOKEN });
@andrewharvey
andrewharvey / polygon-with-a-hole.geojson
Created August 24, 2019 09:39
GeoJSON Polygon with a hole
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@andrewharvey
andrewharvey / logrotatecat
Created December 15, 2011 09:34
cat's a bunch of log rotate log files in correct order
#!/bin/bash
# using,
#
# ./logrotatecat access.log
#
# inside a directory of log rotate logs in a form like
#
# access.log
# access.log.1
@andrewharvey
andrewharvey / feed.sh
Created July 21, 2020 06:40
ArcGIS Rest Services Listing as FeedJSON
#!/bin/sh
wget -O - 'http://data.actmapi.act.gov.au/arcgis/rest/services/actmapi/?f=pjson' | jq '{"version": "https://jsonfeed.org/version/1", "title": "data.actmapi services", "home_page_url": "http://data.actmapi.act.gov.au/arcgis/rest/services/actmapi/?f=pjson", "items": [.services[].name | {"id": ., "content_text": .}]}' > feed.json