Skip to content

Instantly share code, notes, and snippets.

View gmaclennan's full-sized avatar

Gregor MacLennan gmaclennan

View GitHub Profile
@gmaclennan
gmaclennan / gist:8610640
Last active January 4, 2016 10:39
Google Sheets update cell value from cell colour (hex code)
// Will update the value of the cell to the hex value of the color of the cell
// It is triggered by typing a "#" into the cell
// Unfortunately changing the color of a cell does not trigger an edit event in sheets
// Will not work in the new version of Google Sheets
function onEdit(e) {
var cell, value;
var values = e.range.getValues();
for (var i=0; i < values.length; i++) {
@gmaclennan
gmaclennan / open-file.js
Created December 3, 2016 21:37
React Drag and Drop example
const React = require('react')
const dragDrop = require('drag-drop')
const RaisedButton = require('material-ui/RaisedButton').default
const fileExtension = require('file-extension')
const blobToBuffer = require('blob-to-buffer')
const { connect } = require('react-redux')
const {replaceFeatures} = require('../action_creators')
const styles = {
@gmaclennan
gmaclennan / babel-plugin-insert-css.js
Created December 12, 2016 03:58
Insert css with a babel plugin
var resolve = require('resolve').sync
var nodePath = require('path')
var fs = require('fs')
var rework = require('rework')
var reworkImport = require('rework-import')
module.exports = function ({types: t}) {
return {
visitor: {
CallExpression: function (path, state) {
@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.
@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.

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 / 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 <---/