Skip to content

Instantly share code, notes, and snippets.

View gmaclennan's full-sized avatar

Gregor MacLennan gmaclennan

View GitHub Profile
@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 })
@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"
},
/--- A1 <---\
A0 <---- ---- A3 (deleted)
\--- A2 <---/
@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)
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 / 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.

@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 May 26, 2017 17:57
Map Pan & Zoom & Fit

This is similar to Map Pan & Zoom IV but with unprojected raw GeoJSON, which is scaled to fit the canvas.

@gmaclennan
gmaclennan / client.js
Last active July 3, 2017 19:17
Hyperlog http replicate test
const request = require('request')
const duplexify = require('duplexify')
const hyperlog = require('hyperlog')
const memdb = require('memdb')
const log = hyperlog(memdb())
const url = 'http://localhost:4001/'
log.add(null, 'hello', function (err, node) {
if (err) throw err
@gmaclennan
gmaclennan / guyana-volunteer-wifi.md
Last active July 4, 2018 18:43
Long-distance solar-powered wifi in the forests and savannahs of Guyana

Overview

Digital Democracy is looking for a volunteer to help pilot long-distance solar-powered wifi antennaes in indigenous communities in Guyana.

Background

Digital Democracy is working with the Wapichan people in the South Rupununi in Guyana to support them in efforts to secure their ancestral territory and increase their autonomy and self-determination. The Wapichan live in 17 villages and 7 smaller "satellites" in a large semi-natural savannah ecosystem surrounded by tropical forest. Communication between villages and with the outside world is difficult due to limited or no cellphone or internet access. We want to help the Wapichan improve their means of communicating with the rest of the world and communicating and coordinating between villages.

Location