Skip to content

Instantly share code, notes, and snippets.

@bmcbride
bmcbride / fulcrum_classification_set_example.json
Created March 26, 2015 17:37
Example classification_set JSON for an API request
{
"classification_set": {
"name": "Agricultural Products",
"description": "A list of common agricultural products",
"items": [
{
"label": "cereals",
"value": "cereals",
"child_classifications": [
{
@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";
import os
import urllib
import urllib2
import base64
import json
import sys
import argparse
try:
import requests
except ImportError:
@bmcbride
bmcbride / fulcrum-basic-webhook.php
Created November 10, 2014 22:11
Basic Fulcrum webhook endpoint written in PHP. Enter your form id & email, upload to a web server, and configure your webhook settings in Fulcrum to point to this endpoint. Default action emails webhook JSON payload, but realistically, you would want to do something with the recordArray and formArray variables.
<?php
$form_id = 'your-fulcrum-form-id-goes-here';
$email = '[email protected]';
$input = file_get_contents('php://input'); # POST data from webhook
//$input = file_get_contents('payload.json'); # local file for testing
$webhook = json_decode($input, true);
# Webhook data
$webhookID = $webhook['id'];
@bmcbride
bmcbride / pdfmaps-shapefile.sh
Last active October 28, 2016 13:25
Bash script that uses GDAL/OGR to convert PDF Maps exported KML or KMZ Placemarks, Tracks, and Lines to shapefiles. Modify as needed for additional formats or custom attributes.
#!/bin/bash
echo "File type (kmz or kml):"
read TYPE
echo "Enter the filename (without the .kmz or .kml extension) to process:"
read FILENAME
# Unzip KMZ file
if [[ $TYPE = "kmz" ]]; then
Unzip "$FILENAME.kmz"
@bmcbride
bmcbride / index.html
Created October 15, 2014 14:59
Leaflet.fullscreen plugin iframe demo
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1,user-scalable=no,maximum-scale=1,width=device-width">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<title>Leaflet Fullscreen Iframe</title>
</head>
<body>
@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 / deleteFromImgur.js
Last active May 25, 2022 17:53
Upload image from HTML form to http://imgur.com/
function deleteFromImgur() {
$.ajax({
url: "https://api.imgur.com/3/image/{id}",
type: "DELETE",
headers: {
"Authorization": "Client-ID YOUR-CLIEND-ID-GOES-HERE"
},
success: function(response) {
//console.log(response);
}
// Create or open an existing Sheet and click Tools > Script editor and enter the code below
// 1. Enter sheet name where data is to be written below
var SHEET_NAME = "Sheet1";
// 2. Run > setup
// 3. Publish > Deploy as web app
// - enter Project Version name and click 'Save New Version'
// - set security level and enable service (most likely execute as 'me' and access 'anyone, even anonymously)
// 4. Copy the 'Current web app URL' and post this in your form/script action
// 5. Insert column names on your destination sheet matching the parameter names of the data you are passing in (exactly matching case)
@bmcbride
bmcbride / README.md
Last active August 29, 2015 14:04
Post-processing scripts for generating OpenTrails compliant Trailheads CSV & GeoJOSN files from the Fulcrum OpenTrails Trailhead App- http://fulcrumapp.com/apps/opentrails-trailheads

Data exported out of the Fulcrum OpenTrails Trailhead App requires some post processing in order to generate the proper files, per the OpenTrails trailheads.geojson specification. Simply export as Shapefile and execute the following GDAL/OGR commands:

ogr2ogr -f "SQLite" opentrails-trailheads.sqlite -nln "trailheads" -a_srs "EPSG:4326" opentrails_trailheads.shp
ogr2ogr -update -f "SQLite" opentrails-trailheads.sqlite -nln "osm_tags" opentrails_trailheads_osm_tags.dbf