Skip to content

Instantly share code, notes, and snippets.

@bmcbride
bmcbride / fulcrum-cartodb-webhook-hardcoded.php
Last active May 18, 2016 23:56
Fulcrum webhook endpoint for updating a CartoDB table
<?php
# CartoDB Info
$cartodb_username = 'your-cartodb-username-goes-here';
$cartodb_api_key = 'your-cartodb-api-key-goes-here';
$table = 'your-cartodb-table-goes-here';
# Fulcrum Info
$form_id = 'your-fulcrum-form-id-goes-here';
$fulcrum_api_key = 'your-fulcrum-api-key-goes-here';
@bmcbride
bmcbride / fulcrum-device-delete-webhook.php
Created February 12, 2014 16:51
Fulcrum webhook endpoint used for deleting a record from the device when the Status field is changed. In this case the Status field data name was left at the default 'status' (line 15). I set the default status to 'Active' (green) and added an additional status of 'Deleted' (red). When a user changes the status to 'Deleted' and syncs their devic…
<?php
# Fulcrum Info
$form_id = 'my_form_id'; // Get from App URL: https://web.fulcrumapp.com/data/{my_form_id}#
$fulcrum_api_key = 'my_fulcrum_api_key'; // Get from Fulcrum settings page
//$input = file_get_contents('payload.json'); # local file for testing
$input = file_get_contents('php://input'); # POST data from webhook
$data = json_decode($input, TRUE);
# Make sure it's the form we want
@bmcbride
bmcbride / fulcrum-delete-all-records.py
Last active November 9, 2015 16:30
Delete all records in a particular app.
import sys
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!')
fulcrum = Fulcrum(key=api_key)
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 / 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 / geojson-length.py
Created March 31, 2014 20:41
Calculate the length of a GeoJSON linestring using the Python GDAL/OGR API
from osgeo import ogr
from osgeo import osr
source = osr.SpatialReference()
source.ImportFromEPSG(4326)
target = osr.SpatialReference()
target.ImportFromEPSG(3857)
transform = osr.CoordinateTransformation(source, target)
@bmcbride
bmcbride / index.html
Created May 2, 2014 19:31
Fulcrum GeoJSON Data Shares
<!DOCTYPE html>
<html>
<head>
<title>Fulcrum Data Shares</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.css" />
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.min.css" />
<script src="http://cdn.leafletjs.com/leaflet-0.7.2/leaflet.js"></script>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/fancybox/2.1.5/jquery.fancybox.pack.js"></script>
@bmcbride
bmcbride / fulcrum-photo-viewer.php
Last active August 29, 2015 14:01
A simple script for viewing a contact page of photos, based on a column of comma delimited photo ID's as fetched from Fulcrum. Simply prepend 'http://someurl.com/fulcrum-photo-viewer.php?photos=' to your list of photo ID's.
<?php
$fulcrum_api_key = 'your-fulcrum-api-key-goes-here';
if (!isset($_GET['photos']) && !isset($_GET['photo'])){
print 'photo or photos parameter required!';
}
if (isset($_GET['photos'])) {
$photos = explode(',', $_GET['photos']);
@bmcbride
bmcbride / datashare-proxy.php
Last active March 15, 2018 16:24
A simple proxy script for filtering out data fields and masking the URL of Fulcrum data shares. Specify ?format=csv to return CSV instead of default GeoJSON.
<?php
# Fields to be removed (optional)
$remove = ['fulcrum_id','created_by','updated_by','assigned_to'];
# Fulcrum data share ID
$shareID = 'your-share-id';
# Format- 'geojson' or 'csv'
if (isset($_GET['format'])) {
$format = $_GET['format'];
} else {
$format = 'geojson';
@bmcbride
bmcbride / fulcrum_download.py
Created June 26, 2014 15:20
Python script for fetching a Fulcrum data share and saving it locally.
import urllib2
url = 'https://web.fulcrumapp.com/shares/b711f907a8d42665.csv'
u = urllib2.urlopen(url)
localFile = open('fulcrum_data.csv', 'w')
localFile.write(u.read())
localFile.close()