Skip to content

Instantly share code, notes, and snippets.

@bmcbride
bmcbride / example-data-event.js
Last active March 12, 2020 11:31
Turf.js v5.1.6
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));
import sys
import json
from fulcrum import Fulcrum
api_key = 'your_api_key'
form_id = 'your_form_id'
if api_key == '' or api_key == 'your_api_key' or form_id == '' or form_id == 'your_form_id':
sys.exit('api_key and form_id are required!')
@bmcbride
bmcbride / fulcrum-email-notification.gs
Last active January 31, 2020 05:29
Fulcrum Email Notification Webhook (Google Apps Script)
// Special Apps Script function to process HTTP POST request
function doPost(e){
return handleResponse(e);
}
function handleResponse(e) {
// Parse JSON webhook payload
var jsonString = e.postData.getDataAsString();
var payload = JSON.parse(jsonString);
@bmcbride
bmcbride / fulcrum_email_webhook.gs
Last active November 17, 2019 00:39
Simple Google Apps Script, which can be used as a Fulcrum webhook endpoint to email the webhook JSON payload for debugging. Required URL parameter: email. Optional URL parameter: form (Fulcrum form_id).
function doPost(e){
return handleResponse(e);
}
function handleResponse(e) {
var email = e.parameter.email;
var form = e.parameter.form;
var jsonString = e.postData.getDataAsString();
var payload = JSON.parse(jsonString);
var subject = "Fulcrum Webhook Payload";
@bmcbride
bmcbride / find-in-json.js
Last active November 17, 2019 00:28 — forked from iwek/find-in-json.js
//return an array of objects according to key, value, or key and value matching
function getObjects(obj, key, val) {
var objects = [];
for (var i in obj) {
if (!obj.hasOwnProperty(i)) continue;
if (typeof obj[i] == 'object') {
objects = objects.concat(getObjects(obj[i], key, val));
} else
//if key matches and value matches or if key matches and value is not passed (eliminating the case where key matches but passed value does not)
if (i == key && obj[i] == val || i == key && val == '') { //
@bmcbride
bmcbride / gdal_geotiff_to_mbtiles.txt
Created December 15, 2016 16:10
GDAL commands to convert GeoTiff image to MBTiles. Requires GDAL 2.1+.
gdal_translate image.tif image.mbtiles -of MBTILES
gdaladdo image.mbtiles 2 4 8
@bmcbride
bmcbride / routeshoot-kml-to-srt.py
Last active March 25, 2019 09:24
Python script to convert a RouteShoot generated .kml file into an .srt subtitle file for overlaying info on the video. Add the following tag to the YouTube video to force showing the captions when the video plays: yt:cc=on.
import xml.etree.ElementTree as ET
metric = 0
kml = raw_input('Enter the KML file path and name: ')
srt = kml.replace('.kml', '.srt');
file = open(srt, 'w')
if metric == 1:
speedUnits = '(km/h)'
altitudeUnits = '(m)'
@bmcbride
bmcbride / osm2pgsql-to-imposm-schema.sql
Created October 22, 2012 21:11
osm2pgsql-to-imposm-schema.sql Modified for use in TileMill open-streets-dc project
/*********************************************************************
Original Source: https://github.com/jmckenna/basemaps/blob/master/contrib/osm2pgsql-to-imposm-schema.sql
Modified for use in creating shapefiles to replace in TileMill Open Streets, DC project
Purpose: This script will modify tables generated through the osm2pgsql
utilility [1] into tables similar to those as generated from the
imposm utility [2]. The generated tables can then be used
by the mapserver-utils utility [3].
This is most likely useful for the Windows platform.
@bmcbride
bmcbride / fulcrum_mysql_webhook.php
Last active August 4, 2018 12:24
Fulcrum Webhook script for syncing data shares to a MySQL database. Requires PHP with PDO & allow_url_fopen enabled.
<?php
/**
* Title: Fulcrum Webhook for syncing data shares to MySQL database
* Notes: Requires PHP with PDO & allow_url_fopen enabled
* Author: Bryan R. McBride
* Source: https://gist.github.com/bmcbride/44afdc10ee943b4e7b92
*/
# Fulcrum app information
$formID = 'your-fulcrum-form-id';
@bmcbride
bmcbride / proxy.php
Created September 18, 2013 19:35
Simple PHP proxy
<?php
$ch = curl_init($_GET['url']);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
echo $output;
?>