Skip to content

Instantly share code, notes, and snippets.

View jbrown123's full-sized avatar
Looking for a new opportunity

James Brown jbrown123

Looking for a new opportunity
View GitHub Profile
jbrown123 /
Last active July 7, 2024 21:13
SQLite database for USHCN data

Database to process USHCN data

The U.S. Historical Climatology Network USHCN data are used to quantify national and regional-scale temperature changes in the contiguous United States (CONUS). The dataset provides adjustments for systematic, non-climatic changes that bias temperature trends of monthly temperature records of long-term COOP stations.

USHCN defines these elements as follows:

  • tmax = monthly mean maximum temperature
  • tmin = monthly mean minimum temperature
  • tavg = average monthly temperature (tmax+tmin)/2
  • prcp = total monthly precipitation
jbrown123 / NST_EST2021_POP.csv
Last active October 10, 2022 01:01
Include SQLite commands at the top of a data file
We can make this file beautiful and searchable if this error is corrected: Illegal quoting in line 1.
-- sqlite3 -init "NST_EST2021_POP.csv"
name text unique,
pop2020 int,
pop2021 int);
.import "NST_EST2021_POP.csv" pop --csv --skip 12
.mode list
.headers on
select count(*) from pop;
jbrown123 / mylib.scad
Created February 9, 2020 22:12
A library of openscad functions that I frequently use in my designs
* MyLib.scad
* A bunch of openscad functions that I might need from time to time in various projects
* Usage: use <mylib.scad>;
* Version: 20200209
* Copyright (c) 2011-2020 by James H. Brown
jbrown123 / uta-wifi.user.js
Created August 15, 2019 14:35
Auto login to UTA (Utah Transit Authority) WiFi - ticks the accept conditions checkbox, then clicks the connect button
// ==UserScript==
// @name Auto login to UTA WiFi
// @namespace
// @version 0.1
// @description Check the box and press the button on the UTA wifi page
// @author James Brown
// @match
// @grant none
// @require
// ==/UserScript==
jbrown123 /
Last active July 18, 2024 16:59
How to use PuTTY with github on Windows

How to use PuTTY with github on Windows

To make things easier, we can tell git to use the PuTTY tools rather than the built in ssh client. The PuTTY tools include an identity manager and an SSH replacement.

Follow these four steps:

  1. Download and install PuTTY using the MSI installer package from the PuTTY download page. Alternately, you can just get the "PLink" and "Pageant" executables from the same page and save them somewhere in your path.

  2. Add a new user or system environment variable:

  • Press Windows+R and enter sysdm.cpl
jbrown123 /
Created March 21, 2019 14:49
A simple recurring alarm clock written in Perl (does not require any packages, just plain perl). This version is specific to Windows but could easily be converted to other platforms.
#!/usr/bin/env perl
# a (very simple) recurring alarm clock for windows
# easily converted to any other platform by replacing the call to the windows msg tool
# all data is stored in the file itself (in the __DATA__ section at the bottom)
# this is written in pure perl, no packages are required
# under windows I suggest using the ActiveState wperl interpreter to launch the alarm clock
# that prevents you from having a command processor hanging around just to run the alarm clock
# the unfortunate side effect is that you have to kill it using task manager since it never exits
jbrown123 / unsplash_random.html
Created March 20, 2019 23:27
Unsplash randomly rotating images
<title>Unsplash images</title>
// randomly cycle through unsplash images in the browser window every 5-30 seconds
// this works great in full screen (F11) mode on wall monitors as random artwork
// tested on Chrome; should work on most modern browsers but don't blame me if it doesn't
// I used info from the following sites to create this
jbrown123 /
Last active May 5, 2024 20:57
Reference bookmarklet - generate a string containing the page title, URL and any selected text

Reference bookmarklet

This bookmarklet will grab 2 or 3 bits of info from the currently viewed webpage and put them into an 'alert' so you can copy & paste into another document.

It should work in any desktop browser (chrome, firefox, ect.) on any OS but I've only personally tested it in Chrome on Windows.

You can press either enter or escape after copying the text. It doesn't make any difference which one you use.

For example, the above URL points to the bookmarklet entry on Wikipedia. If you used the reference bookmarklet on that page it would return the following:

jbrown123 / -Recursive Queries Using Common Table
Last active July 12, 2024 11:34
Creating arbitrary-depth recursive queries in SQLITE (works for any SQL compliant system) using CTEs (common table expressions)

Recursive Queries Using Common Table Expressions

Common Table Expressions (CTEs) are a bit complex and difficult to understand at first blush. Many of the tutorials and examples on the net don't make it any easier for those just starting out. I thought I'd put together a quick gist that tries to simplify the concept and demonstrate how to do recursive queries using CTEs.

Keep in mind that CTEs have other uses besides just recursive queries but this gist is just about how they can be used to create recursive searches.

I'm using SQLite in this example but any SQL language that implements the WITH keyword should be able to do the same thing. If you've never used SQLite before, you are missing out on an amazing, open source, stand alone, SQL engine. I encourage you to check it out.

A practical example

jbrown123 / US Zip Codes to Lat Lon from 2016 Government Census Data
Last active May 5, 2017 17:51
All US zip codes (technically "five digit ZIP code tabulation area census codes") with their corresponding latitude and longitude coordinates. Positive values = North or East; Negative values = South or West. Comma delimited for easy import. Source: Built with the following commands: unzip …