Skip to content

Instantly share code, notes, and snippets.

View dpfoose's full-sized avatar

Daniel Patrick Foose dpfoose

View GitHub Profile
@dpfoose
dpfoose / connecticut_planning_regions.geojson
Last active November 5, 2024 20:55
Connecticut Planning Regions GeoJSON
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dpfoose
dpfoose / cbsas.json
Created July 10, 2024 16:30
United States Core-Based Statistical Areas
{"Aberdeen, SD \u00b5Sa": [{"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Brown County"}, {"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Edmunds County"}], "Brookings, SD \u00b5Sa": [{"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Brookings County"}], "Huron, SD \u00b5Sa": [{"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Beadle County"}], "Mitchell, SD \u00b5Sa": [{"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Davison County"}, {"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Hanson County"}, {"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Sanborn County"}], "Pierre, SD \u00b5Sa": [{"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Hughes County"}, {"state": "South Dakota", "state_postal_abbreviation": "SD", "county_equivalent": "Stanl
@dpfoose
dpfoose / unit_id.sparql
Created July 3, 2023 18:56
Get All Wikidata Entries with IPEDS Unit IDs
SELECT ?item ?itemLabel ?unit_id ?openalex_id ?mag_id ?ror_id WHERE {
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
OPTIONAL { ?item wdt:P6782 ?ror_id. }
?item wdt:P1771 ?unit_id
OPTIONAL { ?item wdt:P10283 ?openalex_id. }
OPTIONAL { ?item wdt:P6366 ?mag_id. }
}
@dpfoose
dpfoose / plotly_scatter_confidence_ellipse.py
Last active September 4, 2024 09:56
Plot a 95% confidence ellipse for a scatter plot in Plotly
import numpy as np
def confidence_ellipse(x, y, n_std=1.96, size=100):
"""
Get the covariance confidence ellipse of *x* and *y*.
Parameters
----------
x, y : array-like, shape (n, )
import os
ADMIN_GROUP = os.environ['ADMIN_GROUP']
AUTHORIZED_GROUP = os.environ['AUTHORIZED_GROUP']
# LDAP connection settings
LDAP_URI = os.environ['LDAP_URI']
LDAP_BASE_DN = os.environ['LDAP_BASE_DN']
LDAP_USER_BASE_DN = os.environ['LDAP_USER_BASE_DN']
@dpfoose
dpfoose / rigid_motion_alignment.py
Last active July 13, 2023 02:36
Rigid-motion least-squares algnment of two sets of corresponding points.
from sklearn.base import BaseEstimator, TransformerMixin
from sklearn.utils import check_array
from sklearn.utils.validation import check_is_fitted, column_or_1d
import numpy as np
def rigid_motion_alignment(P, Q, sample_weight=None):
if sample_weight is None:
sample_weight = np.ones(P.shape[1])
p_centroid = np.sum(sample_weight * P, axis=1) / np.sum(sample_weight)
@dpfoose
dpfoose / in_docker.py
Last active July 29, 2025 17:01
Get the path on a Docker host from a path in a Docker container if the path is in a bind-mounted volume
'''
Copyright (C) 2018 by Daniel Foose
Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE
'''
import re
import docker