Skip to content

Instantly share code, notes, and snippets.

View khurchla's full-sized avatar
📊
studio|classroom|office

Kathryn Hurchla khurchla

📊
studio|classroom|office
View GitHub Profile
@veltman
veltman / README.md
Last active January 18, 2025 16:17
Redistricting

Old vs. new proposed North Carolina congressional districts, data via WRAL.

Polygons were pre-processed for gentler animation as follows:

  1. For each district, find the difference n in the number of vertices between the old and new district.
  2. Add n vertices to whichever one has fewer, evenly spaced along the existing polyline, so the old and new shape each have the same number of vertices (not great for performance).
  3. For each pair of old/new district, wind the old district around to minimize the sum of the squared distances between point index i in the old district and point index i in the new district.
Please note that these warnings are just used to help the Homebrew maintainers
with debugging if you file an issue. If everything you use Homebrew for is
working fine: please don't worry and just ignore them. Thanks!
Warning: Broken symlinks were found. Remove them with `brew prune`:
/usr/local/share/ghostscript/9.10/Resource/Font/logo10.pfb
/usr/local/share/ghostscript/9.10/Resource/Font/logo8.pfb
/usr/local/share/ghostscript/9.10/Resource/Font/logo9.pfb
/usr/local/share/ghostscript/9.10/Resource/Font/logobf10.pfb
/usr/local/share/ghostscript/9.10/Resource/Font/logod10.pfb
@msrose
msrose / combining-git-repositories.md
Last active May 20, 2025 14:44
How to combine two git repositories.

Combining two git repositories

Use case: You have repository A with remote location rA, and repository B (which may or may not have remote location rB). You want to do one of two things:

  • preserve all commits of both repositories, but replace everything from A with the contents of B, and use rA as your remote location
  • actually combine the two repositories, as if they are two branches that you want to merge, using rA as the remote location

NB: Check out git subtree/git submodule and this Stack Overflow question before going through the steps below. This gist is just a record of how I solved this problem on my own one day.

Before starting, make sure your local and remote repositories are up-to-date with all changes you need. The following steps use the general idea of changing the remote origin and renaming the local master branch of one of the repos in order to combine the two master branches.

@creaktive
creaktive / mojo-crawler.pl
Last active November 28, 2020 13:15
Simple web crawler/scraper implemented using Mojolicious
#!/usr/bin/env perl
use 5.010;
use open qw(:locale);
use strict;
use utf8;
use warnings qw(all);
use Mojo::UserAgent;
# FIFO queue
@rogerallen
rogerallen / us_state_abbrev.py
Last active March 18, 2025 20:33
A Python Dictionary to translate US States to Two letter codes
# United States of America Python Dictionary to translate States,
# Districts & Territories to Two-Letter codes and vice versa.
#
# Canonical URL: https://gist.github.com/rogerallen/1583593
#
# Dedicated to the public domain. To the extent possible under law,
# Roger Allen has waived all copyright and related or neighboring
# rights to this code. Data originally from Wikipedia at the url:
# https://en.wikipedia.org/wiki/ISO_3166-2:US
#
@schuyler
schuyler / get-centroid.py
Created June 22, 2011 17:46 — forked from mager/get-centroid.py
Find centroid for Polygon
from shapely.geometry import asShape
from simplegeo import context
client = context.Client('your-key','your-secret')
context_response = client.get_context(37.775255,-122.40289)
neighborhoods = [feature for feature in context_response['features'] if feature['classifiers'][0]['category'] == 'Neighborhood']
if neighborhoods:
neighborhood_handle = neighborhoods[0]['handle']
neighborhood_boundary = asShape(client.get_feature(neighborhood_handle).to_dict()['geometry'])
centroid = neighborhood_boundary.centroid.wkt