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
/* 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).
#!/bin/bash
# update marcedit on Ubuntu
rm ~/Downloads/marcedit.bin.zip # remove any previous downloads
wget -P ~/Downloads/ http://marcedit.reeset.net/software/marcedit.bin.zip
unzip ~/Downloads/marcedit.bin.zip -d /opt/local/ # unzip to /opt/local/
rm ~/Downloads/marcedit.bin.zip
@pmgreen
pmgreen / strawn_vger_test.md
Created March 18, 2016 15:38
Getting Gary Strawn's programs to work with Voyager Test db at PUL

How to get Gary Strawn's programs to work with Test db

Tested with Record Reloader and VgerSelect on Windows 7 machine, Voyager BatchCat2009-11 (C:\Voyager\System)

  • Edit tnsnames.ora (indentation is important!). Under VGER config put:
TEST =
 (DESCRIPTION = 
   (ADDRESS_LIST =
 (ADDRESS = (PROTOCOL = TCP)(HOST = test.ip.addr)(PORT = 1521))