Skip to content

Instantly share code, notes, and snippets.

@bmcbride
bmcbride / google-form-to-github-issue.md
Last active April 5, 2024 15:47
Create a new GitHub Issue from a Google Form submission

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 / postgis_geojson.php
Created February 26, 2012 05:43
PHP PostGIS to GeoJSON
<?php
/**
* PostGIS to GeoJSON
* Query a PostGIS table or view and return the results in GeoJSON format, suitable for use in OpenLayers, Leaflet, etc.
*
* @param string $geotable The PostGIS layer name *REQUIRED*
* @param string $geomfield The PostGIS geometry field *REQUIRED*
* @param string $srid The SRID of the returned GeoJSON *OPTIONAL (If omitted, EPSG: 4326 will be used)*
* @param string $fields Fields to be returned *OPTIONAL (If omitted, all fields will be returned)* NOTE- Uppercase field names should be wrapped in double quotes
* @param string $parameters SQL WHERE clause parameters *OPTIONAL*
@bmcbride
bmcbride / Code.gs
Created March 28, 2018 17:46
Google Apps Script for exporting CSV files from the Fulcrum Query API to a Drive folder
/**
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 November 22, 2022 14:15
Google Apps Script for importing CSV files from Drive into Fulcrum
/**
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 / LeafletToWKT.js
Last active June 7, 2022 02:17
Leaflet layer to WKT
function toWKT(layer) {
var lng, lat, coords = [];
if (layer instanceof L.Polygon || layer instanceof L.Polyline) {
var latlngs = layer.getLatLngs();
for (var i = 0; i < latlngs.length; i++) {
latlngs[i]
coords.push(latlngs[i].lng + " " + latlngs[i].lat);
if (i === 0) {
lng = latlngs[i].lng;
lat = latlngs[i].lat;
@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 / 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 / fulcrum-selectize.js
Created July 8, 2021 21:03
Selectize Fulcrum editor visibility & requirement rule select controls
$('head').append('<script src="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.13.3/js/standalone/selectize.min.js"></script>');
$('head').append('<link href="https://cdnjs.cloudflare.com/ajax/libs/selectize.js/0.13.3/css/selectize.bootstrap3.min.css" type="text/css" rel="stylesheet" />');
$('.visibility-conditional-modal').on('shown.bs.modal', selectizeIt);
$('.required-conditional-modal').on('shown.bs.modal', selectizeIt);
function selectizeIt() {
$('.condition-field').selectize({
sortField: 'text',
dropdownParent:'body'
});
$('.selectize-dropdown').css('z-index', 9999);
@bmcbride
bmcbride / gdal.txt
Last active January 11, 2021 17:48
GDAL commands to convert NYSDOP orthoimagery JPEG2000 files to GeoTiff & PDF
SINGLE FILE CONVERT
gdal_translate input_nysdop_ortho.jp2 output.tif -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co JPEG_QUALITY=25 -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES -a_srs EPSG:2260
BATCH CONVERT
for /r %g in (*.jp2) do gdal_translate -of GTiff "%g" "%~dpng.tif" -b 1 -b 2 -b 3 -mask 4 -co COMPRESS=JPEG -co JPEG_QUALITY=25 -co PHOTOMETRIC=YCBCR --config GDAL_TIFF_INTERNAL_MASK YES -a_srs EPSG:2260
BUILT VIRTUAL RASTER (CATALOG)
gdalbuildvrt catalog.vrt e_06811416_06_05000_4bd_2011.jp2 e_06811414_06_05000_4bd_2011.jp2 e_06781416_06_05000_4bd_2011.jp2 e_06781414_06_05000_4bd_2011.jp2
gdalbuildvrt -allow_projection_difference -hidenodata -vrtnodata "255 255 255" nysdop.vrt *.jp2 -a_srs EPSG:2260