Skip to content

Instantly share code, notes, and snippets.


Jonathan Thornton jonblatho

View GitHub Profile
jonblatho /
Last active Mar 30, 2021
Calculates the population of ZIP Code Tabulation Areas (ZCTAs) which intersect with Howell County, MO
import shapefile
from shapely.geometry import shape
def __shapely_polygon__(s):
return shape(s.shape.__geo_interface__)
# Read Missouri census block shapefile
block_file = shapefile.Reader("block/tabblock2010_29_pophu.shp")
# Obtained from
# Read ZIP code tabulation area shapefile
jonblatho / PointInPolygon.swift
Last active Feb 17, 2021
Some Swift code to determine whether a point is inside a polygon.
View PointInPolygon.swift
/// Contains the coordinates of a point in a 2D Cartesian coordinate system.
public struct Point: Hashable {
/// The x-coordinate of the point.
public var x: Double
/// The y-coordinate of the point.
public var y: Double
extension Array where Element == Point {
/// Returns only the unique points in the array.
# Calculates the overlap area between two circles of radii r1 and r2 with
# center points d apart.
def circle_overlap_area(r1, r2, d):
# Expression from
return r2**2 * acos((d**2+r2**2-r1**2)/(2*d*r2))+r1**2*acos((d**2-r2**2+r1**2)/(2*d*r1)) - 1/2*sqrt((-d+r2+r1)*(d+r2-r1)*(d-r2+r1)*(d+r2+r1))
# A few possible cases if there's a math domain error...
if r1 == r2 and d == 0:
# Identical circle radii and center points
View UIStackView+attachToScrollView.swift
extension UIStackView {
Fills the given scroll view with this stack view. This method automatically creates
and activates constraints and adds the stack view to the scroll view.
- parameter scrollView: The scroll view into which this stack view should be inserted.
internal func attachToScrollView(_ scrollView: UIScrollView) {
// Add this stack view to the given UIScrollView
jonblatho / ModelName.swift
Last active Jun 10, 2019
An easy way to get a pretty name for an iOS device model.
View ModelName.swift
import UIKit
extension UIDevice {
/// A "pretty" device name for the machine identifier.
/// Current for devices supporting iOS 9 and later and tvOS 9 and later, as of WWDC 2019.
var modelName: String {
var machineString = String()
var systemInfo = utsname()
View minimal-swift.Dockerfile
FROM swift:4
WORKDIR /build
COPY Sources ./Sources
COPY Package.swift .
RUN swift package resolve
RUN swift build
COPY /usr/bin/pkg-swift-deps
import sys
import re
import fileinput
# This script takes a list of air temperatures extracted from historical METARs
# obtained from
# Use it in the command line with something along the lines of
# $ python2.7 asos-1997.csv
# where the parameter is the text file you want to filter through. It only
View HomeTableViewController.swift
// HomeTableViewController.swift
// Created by Jonathan Thornton on 12/22/17.
// Copyright © 2017 Jonathan Thornton. All rights reserved.
import UIKit
class HomeTableViewController: UITableViewController {

Keybase proof

I hereby claim:

  • I am jonblatho on github.
  • I am jonblatho ( on keybase.
  • I have a public key whose fingerprint is 6917 A05E 6986 965B C18B E13E 027C D5CD BAFF 8E89

To claim this, I am signing this object: