Skip to content

Instantly share code, notes, and snippets.

View pmgreen's full-sized avatar

Peter Green pmgreen

  • Narrow Ridge Center
  • TN
View GitHub Profile
@pmgreen
pmgreen / trello_to_json.py
Last active January 20, 2026 20:38
Script to get a tabular view of Trello JSON exports. This example gets road work from a DONE column. Thanks to Real Orange One.
#!/usr/bin/env python3
"""
Convert a Trello board export (JSON) into filtered JSON that can be more easily converted to CSV.
The filter_road_done function is an example of how to report on keywords and columns (e.g. give me all cards containing "road" in the "DONE!" column).
Adapted from https://gist.github.com/RealOrangeOne/c35751ee794e90df512bdfba6f22574d
Lumo was used for formatting (and code suggestions).
Usage:
Export JSON from Trello (three dots > print, export and share > export as JSON), run this script:
python trello_to_json.py <input_file.json> <output_file.json>
@pmgreen
pmgreen / treemap_grainger.js
Created January 8, 2026 04:48
Google Earth Engine JavaScript to get USDA TreeMap data for a defined area
// This is just a start.
// See: https://developers.google.com/earth-engine/datasets/catalog/USFS_GTAC_TreeMap_v2022
// Get the USDA TreeMap dataset
var dataset = ee.ImageCollection('USFS/GTAC/TreeMap/v2022');
// 'Official' TreeMap 2016 palettes
var bamako = ['00404d', '134b42', '265737', '3a652a', '52741c', '71870b', '969206', 'c5ae32', 'e7cd68', 'ffe599'];
var bamako_r = JSON.parse(JSON.stringify(bamako)).reverse();
var lajolla = ['ffffcc','fbec9a','f4cc68','eca855','e48751','d2624d','a54742','73382f','422818','1a1a01'];
/* Google Earth Engine script to get forest loss and gain since 2016 for an area of interest in TN (because TN LiDAR data dates back to 2016).
Images (GeoTIFF) can be exported to Google Drive then downloaded and imported into QGIS.
Adapted from Josef Clifford's Udemy course Open Source GIS & Remote Sensing for Conservation (Advanced). */
// Set map center over NRC in Grainger County, TN
Map.setCenter(-83.6562908309219, 36.326523130233674, 13);
// Load US Grainger county dataset
var graingerCounty = ee.FeatureCollection('TIGER/2018/Counties')
.filter(ee.Filter.eq('GEOID', '47057'));
@pmgreen
pmgreen / get_qgis_layer_fieldnames.py
Created September 15, 2025 00:53
Get field names from QGIS attribute table
# generated from multiple sources by Brave Leo (AI)
# from the Python console in QGIS:
# activate the layer you want field names for and then enter...
from qgis.utils import iface
layer = iface.activeLayer()
prov = layer.dataProvider()
field_names = [field.name() for field in prov.fields()]
for f in enumerate(field_names):
print(f"{f}")
# frozen_string_literal: true
require 'nokogiri'
require 'csv'
# Get Alma publishing job data enhancement schema.
# Download data enrichment html and point this script to it.
# TODO: clean this up and refine it, if needed again
@pmgreen
pmgreen / valva2marc.rb
Last active February 7, 2020 17:41
Rough script for generating MARC records from tabular data for the Valva music collection: https://library.princeton.edu/music/valva
#!/usr/bin/env ruby
# For the Valva project
# Creates marc records from a spreadsheet
# 201911
require 'csv'
require 'marc'
require 'optparse'
require 'facets/string/titlecase'
@pmgreen
pmgreen / rednotebook on macOS
Last active September 6, 2019 19:05
Install Rednotebook on macOS Mojave
https://rednotebook.sourceforge.io
Of the three mac installation methods listed on the Rednotebook downloads page, these got the closest:
https://jarrousse.org/installing-rednotebook-from-source-on-mac-os-x/
Here's a summary of modified steps ...
$ git clone https://github.com/jendrikseipp/rednotebook
$ brew install gtk # <= using brew to install gtk worked
$ brew install pygobject3 glib libffi cairo gtksourceview3
$ brew install atk librsvg # <= don't install gdk-pixbuf at this step
$ brew install gsettings-desktop-schemas adwaita-icon-theme
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Simple test script to get a list of ids from bibs containing given subject headings
pmg
"""
import os
import pymarc
import re
@pmgreen
pmgreen / peter_ward_report.py
Created August 13, 2018 17:13
Get simple reports from Peter Ward files, reading LDR/05.
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Get simple reports from Peter Ward files, reading LDR/05.
Peter Ward files come from a paid subscription as of 201808, processed by ke, jeb, pmg.
Run like this: python peter_ward_report.py -f 'unname18.01'
It produces a csv file like this ...
ldr05,status,lccn
c,changed,n 00004614
#!/usr/bin/env python
#-*- coding: utf-8 -*-
"""
Query dbpedia. Input is csv which includes authorized names ...
...
96,"Abdelamir, Chowki"
9,"Abraham, Nicolas"
31,"Abraham, Nicolas"
...
Queries local copy of LCNAF, then viaf for viaf uri, then dbpedia for various values (sparql).