Skip to content

Instantly share code, notes, and snippets.

View gmaclennan's full-sized avatar

Gregor MacLennan gmaclennan

View GitHub Profile
@gmaclennan
gmaclennan / README.md
Created May 24, 2017 15:20
Using hyperx instead of JSX

Some notes on how to use hyperx as a replacement for JSX. Need to try this out.

@gmaclennan
gmaclennan / README.md
Last active June 21, 2019 14:57
Marker Dispersion

Uses d3-force to disperse overlapping markers on a mapbox-gl map.

Markers are tethered to their actual location, but have a collision force based on the radius of the icon. An additional force pulls icons towards their previous location (locations are calculated each time you move the map) to avoid markers jumping around excessively as they settle into different local minima on each re-draw.

const functions = require('firebase-functions')
const path = require('path')
const gcs = require('@google-cloud/storage')()
module.exports = functions.storage.object().onChange(event => {
const object = event.data
const bucket = gcs.bucket(object.bucket)
// Exit if this is triggered on a file that is not an image.
@gmaclennan
gmaclennan / index.patch
Last active February 22, 2017 18:50
osm-p2p-db deletion batch ops
index ec505de..ff29709 100644
--- a/index.js
+++ b/index.js
@@ -191,25 +191,13 @@ DB.prototype.del = function (key, opts, cb) {
// OsmVersion, Opts -> [OsmBatchOp]
DB.prototype._getDocumentDeletionBatchOps = function (key, opts, cb) {
var self = this
- self.kv.get(key, function (err, docs) {
+ self.kv.get(key, {fields: true}, function (err, docs) {
if (err) return cb(err)
/--- A1 <---\
A0 <---- ---- A3 (deleted)
\--- A2 <---/
@gmaclennan
gmaclennan / existing_way_deleted.json
Last active February 5, 2017 00:04
osm-p2p-db delete record example
{
"value": {
"refs": [
"A",
"C",
"A",
"D"
],
"d": "F"
},
@gmaclennan
gmaclennan / hyperkv.patch
Created February 4, 2017 23:40
Patch for hyperkv 2.0.0
diff --git a/index.js b/index.js
index 79f78e4..e9897c0 100644
--- a/index.js
+++ b/index.js
@@ -101,7 +101,8 @@ KV.prototype.del = function (key, opts, cb) {
}
if (!opts) opts = {}
if (!cb) cb = noop
- self._put(key, { d: key }, opts, function (err, node) {
+ var value = xtend(opts.fields || {}, { k: key, d: true, v: opts.value })

Keybase proof

I hereby claim:

  • I am gmaclennan on github.
  • I am gmaclennan (https://keybase.io/gmaclennan) on keybase.
  • I have a public key ASBkNcWJZSORRsuupjzXIeg2sMS2fE_Kou6h5fEc5_UAGwo

To claim this, I am signing this object:

@gmaclennan
gmaclennan / connected-line-fixture.geojson
Last active January 21, 2017 20:50
Dissolve connected GeoJSON LineStrings
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gmaclennan
gmaclennan / multipolygon.geojson
Created January 13, 2017 13:18
OSM XML Polygon from relation example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.