Skip to content

Instantly share code, notes, and snippets.

Bryan McBride bmcbride

Block or report user

Report or block bmcbride

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View example-data-event.js
storage = STORAGE();
ON('load-record', function (event) {
if (storage.getItem("turf")) {
eval(JSON.parse(storage.getItem("turf")));
turf = module.exports;
} else {
REQUEST({url: 'https://gist.githubusercontent.com/bmcbride/568bb31c073af412f35db3a558cc246a/raw/b9d0c3265fffec8119151c647cb74be7f349beb3/turf.js'}, function(error, response, body) {
if (error) {
ALERT('Error with request: ' + INSPECT(error));
@bmcbride
bmcbride / Code.gs
Created Mar 28, 2018
Google Apps Script for exporting CSV files from the Fulcrum Query API to a Drive folder
View Code.gs
/**
Title: Google Apps Script for exporting CSV files from the Fulcrum Query API to a Drive folder
Notes: Be sure to manually run the exportData() function at least once to authorize the script. Set a timed trigger to automate exports.
Author: Bryan R. McBride
**/
var fulcrumToken = "abcdefghijklmnopqrstuvwxyz";
var fulcrumFormName = "My App";
var filesFolder = "1_NGfsxszanv2evVJgfKMXxmU54SZ92FW";
@bmcbride
bmcbride / Code.gs
Last active Aug 16, 2018
Google Apps Script for importing CSV files from Drive into Fulcrum
View Code.gs
/**
Title: Google Apps Script for importing CSV files from Drive into Fulcrum
Notes: Be sure to manually run the getFiles() function at least once to authorize the script. Set a timed trigger to automate imports.
Author: Bryan R. McBride
--CSV file format--
latitude,longitude,name,color
27.770787,-82.638039,Building 1,red
**/
var fulcrumToken = "abcdefghijklmnopqrstuvwxyz";
@bmcbride
bmcbride / apbp_karner_barrens.geojson
Created Sep 16, 2017
Albany Pine Bush Preserve - Karner Barrens Trails
View apbp_karner_barrens.geojson
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@bmcbride
bmcbride / osgb.js
Created Jan 18, 2017
Fulcrum Data Event to convert WGS84 coordinates to Ordnance Survey Great Britain (OSGB) / British National Grid (BNG).
View osgb.js
/**
* GeoTools javascript coordinate transformations
* http://files.dixo.net/geotools.html
*
* This file copyright (c)2005 Paul Dixon (paul@elphin.com)
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
@bmcbride
bmcbride / gdal_geotiff_to_mbtiles.txt
Created Dec 15, 2016
GDAL commands to convert GeoTiff image to MBTiles. Requires GDAL 2.1+.
View gdal_geotiff_to_mbtiles.txt
gdal_translate image.tif image.mbtiles -of MBTILES
gdaladdo image.mbtiles 2 4 8
@bmcbride
bmcbride / fulcrum_fetch_shapefile.sh
Created Sep 21, 2016
Bash script for fetching GeoJSON data from Fulcrum and converting to shapefile via ogr2ogr
View fulcrum_fetch_shapefile.sh
#!/bin/bash
curl "https://web.fulcrumapp.com/shares/{token}.geojson" > records.geojson
ogr2ogr -f "ESRI Shapefile" records.shp records.geojson
@bmcbride
bmcbride / thumbnail.sql
Last active Aug 22, 2016
Get a direct link to the thumbnail of the first image in a photo field with Fulcrum data shares. Useful for pulling an image into a CartoDB image header info window.
View thumbnail.sql
SELECT *, CASE WHEN photos != '' THEN left(photos_url, position('/view' in photos_url)) || split_part(photos, ',', 1) || '/thumbnail.jpg' ELSE photos END AS thumbnail FROM my_fulcrum_table
@bmcbride
bmcbride / google-form-to-github-issue.md
Last active Sep 6, 2019
Create a new GitHub Issue from a Google Form submission
View google-form-to-github-issue.md

Wiring up a Google Form to GitHub is not that difficult with a little bit of Apps Script automation. All you need is a Google account, a GitHub account, and a web browser...

Set up your GitHub Personal Access Token

Personal access tokens provide an easy way to interact with the GitHub API without having to mess with OAuth. If you don't already have a personal access token with repo or public_repo access, visit your GitHub settings page and generate a new token.

Be sure to copy your token some place safe and keep it secure. Once generated, you will not be able to view or copy the token again.

Set up the Form & Spreadsheet

  1. Create a Google Form.
@bmcbride
bmcbride / polygon_insert.sql
Created Dec 4, 2015 — forked from andrewxhill/polygon_insert.sql
Polygon insert Named Function
View polygon_insert.sql
-- Create a function withn the security set to Definer so that it can insert
CREATE OR REPLACE FUNCTION AXH_NewMinneapolis(integer, geometry) RETURNS integer
AS 'INSERT INTO minneapolis (parent_id, the_geom) (SELECT id, geom FROM (SELECT $1 id,$2 geom) a WHERE ST_NPoints(geom) < 100) RETURNING cartodb_id;'
LANGUAGE SQL
SECURITY DEFINER
RETURNS NULL ON NULL INPUT;
--Grant access to the public user
GRANT EXECUTE ON FUNCTION AXH_NewMinneapolis(integer, geometry) TO publicuser;
You can’t perform that action at this time.