Skip to content

Instantly share code, notes, and snippets.

View mcculley's full-sized avatar

Gene McCulley mcculley

View GitHub Profile
@mcculley
mcculley / NWS2KML.xslt
Created October 15, 2023 14:11
Convert the list of NOAA weather stations to a KML file. (e.g., curl https://w1.weather.gov/xml/current_obs/index.xml | xsltproc nws2kml.xslt - > NWS_stations.kml)
<?xml version="1.0"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<xsl:template match="/wx_station_index">
<kml xmlns="http://www.opengis.net/kml/2.2">
<Document>
#!/bin/bash
# This is a tool to control contactsd on macOS. For some reason, contactsd
# consumes a lot of CPU when running against my (large, 9,779 entry)
# addressbook. I think contactsd is responsible for synchronizing the
# addressbook in the background, but it makes my local instance of the Contacts
# app hang and burns up my battery. So I stop contactsd when I use the Contacts
# app and then restart it to allow the sync to happen. However, modern macOS
# will not allow one to disable the contactsd launch agent. System Integrity
# Protection will also not allow one to disable it. So what I really do is
#!/bin/bash
# This is a tool to control contactsd on macOS. For some reason, contactsd
# consumes a lot of CPU when running against my (large, 9,779 entry)
# addressbook. I think contactsd is responsible for synchronizing the
# addressbook in the background, but it makes my local instance of the Contacts
# app hang and burns up my battery. So I stop contactsd when I use the Contacts
# app and then restart it to allow the sync to happen. However, modern macOS
# will not allow one to stop the contactsd launch agent to be disabled. System
# Integrity Protection will not allow one to disable it. So what I really do is
select individual_contribution."EMPLOYER" as employer, sum(individual_contribution."TRANSACTION_AMT") as total_contribution from individual_contribution where "ENTITY_TP"='IND' group by individual_contribution."EMPLOYER"
; Find the top ten PACs by total contributions from individuals with no employer listed.
select b.cmte_nm as committee_name, a.committee_ID, a.total_contribution
from (select individual_contribution."CMTE_ID" as committee_ID, sum(individual_contribution."TRANSACTION_AMT")
as total_contribution from individual_contribution
where "ENTITY_TP"='IND' and ("EMPLOYER" in ('NONE', 'UNEMPLOYED', 'NOT EMPLOYED', 'N/A', 'NO EMPLOYER', 'NONE GIVEN')
or "EMPLOYER" is null) group by individual_contribution."CMTE_ID")
as a join committee
as b on a.committee_ID = b.cmte_id
order by total_contribution desc;
#!/bin/sh
# Show the differences between two Microsoft Word files.
echo Detecting differences between $1 and $2.
echo MD5 hashes:
md5 "$1" "$2"
# Unpack the contents of the documents. The Word .docx format is a ZIP file containing XML files.
mkdir "$1".contents
// This is a gross hack to make it possible to run without any fonts in the Lambda environment.
private static void configureStubFontConfiguration() {
final Properties p = new Properties();
p.put("version", "1");
p.put("sequence.allfonts", "nonexistent"); // Just need at least one entry to satisfy FontManager.
try {
final File targetFile = File.createTempFile("fontconfig.properties", null);
targetFile.deleteOnExit();
try (FileOutputStream o = new FileOutputStream(targetFile)) {
p.store(o, "stub to make sun.awt.FontConfiguration not break when no fonts are available");
/**
* Eagerly execute some initialization such as loading of standard fonts.
*/
public static void initializePDFRenderer() {
final PDDocument document = new PDDocument();
new PdfBoxFontResolver(null, document, null, PdfRendererBuilder.PdfAConformance.NONE, false);
try {
document.close();
} catch (final IOException e) {
throw new RuntimeException(e);
import org.junit.jupiter.api.Test;
import org.junit.platform.commons.support.AnnotationSupport;
import org.junit.platform.commons.support.HierarchyTraversalMode;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.List;
import java.util.logging.Logger;
import static org.junit.jupiter.api.Assertions.assertEquals;
@mcculley
mcculley / Account.java
Last active July 1, 2020 16:45
Class with embedded tests
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
public class Account {
public static class InsufficientFundsException extends Exception {
}
private int balance;