Skip to content

Instantly share code, notes, and snippets.

@troyswanson
troyswanson / geometry.py
Created November 2, 2022 20:43
Geometry Utility Functions
import math
from shapely.geometry import Point, LineString, Polygon, MultiPolygon
def create_rectangle(x, y, width, depth, angle):
width_theta = math.radians(angle)
width_x = width * math.cos(width_theta)
width_y = width * math.sin(width_theta)
@troyswanson
troyswanson / list_names.csv
Created June 5, 2019 22:26
NYT Best Sellers
list_name_encoded display_name list_name newest_published_date oldest_published_date updated
combined-print-and-e-book-fiction Combined Print & E-Book Fiction Combined Print and E-Book Fiction 2019-06-09 2011-02-13 WEEKLY
combined-print-and-e-book-nonfiction Combined Print & E-Book Nonfiction Combined Print and E-Book Nonfiction 2019-06-09 2011-02-13 WEEKLY
hardcover-fiction Hardcover Fiction Hardcover Fiction 2019-06-09 2008-06-08 WEEKLY
hardcover-nonfiction Hardcover Nonfiction Hardcover Nonfiction 2019-06-09 2008-06-08 WEEKLY
trade-fiction-paperback Paperback Trade Fiction Trade Fiction Paperback 2019-06-09 2008-06-08 WEEKLY
mass-market-paperback Paperback Mass-Market Fiction Mass Market Paperback 2017-01-29 2008-06-08 WEEKLY
paperback-nonfiction Paperback Nonfiction Paperback Nonfiction 2019-06-09 2008-06-08 WEEKLY
e-book-fiction E-Book Fiction E-Book Fiction 2017-01-29 2011-02-13 WEEKLY
e-book-nonfiction E-Book Nonfiction E-Book Nonfiction 2017-01-29 2011-02-13 WEEKLY
@troyswanson
troyswanson / ortools-tsp.py
Created June 5, 2019 21:07
TSP solver with Google's or-tools
from ortools.constraint_solver import routing_enums_pb2
from ortools.constraint_solver import pywrapcp
cost_matrix = [
[0, 10938, 4542, 2835, 29441, 2171, 1611, 9208, 9528, 11111, 16120, 22606, 22127, 20627, 21246, 23387, 16697, 33609, 26184, 24772, 22644, 20655, 30492, 23296, 32979, 18141, 19248, 17129, 17192, 15645, 12658, 11210, 12094, 13175, 18162, 4968, 12308, 10084, 13026, 15056],
[10938, 0, 6422, 9742, 18988, 12974, 11216, 19715, 19004, 18271, 25070, 31971, 31632, 30571, 31578, 33841, 27315, 43964, 36944, 35689, 33569, 31481, 41360, 33760, 43631, 28730, 29976, 27803, 28076, 26408, 23504, 22025, 22000, 13197, 14936, 15146, 23246, 20956, 23963, 25994],
[4542, 6422, 0, 3644, 25173, 6552, 5092, 13584, 13372, 13766, 19805, 26537, 26117, 24804, 25590, 27784, 21148, 37981, 30693, 29315, 27148, 25071, 34943, 27472, 37281, 22389, 23592, 21433, 21655, 20011, 17087, 15612, 15872, 11653, 15666, 8842, 16843, 14618, 17563, 19589],
[2835, 9742, 3644, 0, 28681, 3851, 4341, 11660, 12294, 13912, 18893,
@troyswanson
troyswanson / main.py
Created April 25, 2019 03:40
Facebook Photo Downloader
import requests
import urllib
def get_photos(access_token, url='https://graph.facebook.com/v2.10/me/photos?fields=images,from'):
r = requests.get(url, headers={'Authorization': 'Bearer %s' % (access_token)})
payload = r.json()
data = payload['data']
for photo in data:
print '>>> %s' % (photo['from'])

Departing

Who Who Where What What
Clearance Skyhawk 413ES Atlantic with India VFR to Lockhart, 3,500 feet
Ground Skyhawk 413ES Spot 1 N/A Ready to taxi
Tower Skyhawk 413ES Holding short runway 1-7 Left at Foxtrot N/A Ready for departure
Departure Skyhawk 413ES Passing 1,300, climbing 3,500 N/A N/A

Arriving

@troyswanson
troyswanson / consul-server
Last active February 20, 2017 14:30
init.d scripts
#!/bin/sh
### BEGIN INIT INFO
# Provides: consul-server
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start daemon at boot time
# Description: Enable service provided by daemon.
### END INIT INFO
@troyswanson
troyswanson / section-1.md
Created November 7, 2016 21:21
SoFi Loan Document

I. DEFERMENT, FORBEARANCE AND LOAN DISCHARGE

1.

In the event that I experience a financial or other hardship and am unable to make my regular monthly payments, or in the event I return to school after obtaining this Loan, but only for the purpose of obtaining a graduate degree and not for obtaining an additional undergraduate degree or license, you may offer certain deferment and forbearance options. Requests for forbearance must be submitted in accordance with your reasonable procedures and requirements, and the decision to grant my request for forbearance shall be solely at your discretion. I may obtain copies of deferment or forbearance request forms that explain the eligibility and documentation requirements for the type of deferment or forbearance I am requesting by sending an e-mail request to CustomerService@sofi.org or mailing your office a request at P.O. Box 29372, San Francisco, CA 94129-0372 or any future address or electronic method you provide to me. If I am in default on my Loan, I may n

@troyswanson
troyswanson / t4-c1.rst
Last active July 21, 2016 20:16
United States Code

CHAPTER 1—THE FLAG

§ 1. Flag; stripes and stars on

The flag of the United States shall be thirteen horizontal stripes, alternate red and white; and the union of the flag shall be forty-eight stars, white in a blue field.

§ 2. Same; additional stars

@troyswanson
troyswanson / keybase.md
Last active February 6, 2017 15:48
Keybase proof

Keybase proof

I hereby claim:

  • I am troyswanson on github.
  • I am troyswanson (https://keybase.io/troyswanson) on keybase.
  • I have a public key ASBiJJAvfq-cGJorZUAGMVW2eJRt9x4cIJrTmaK9Ui1k4Ao

To claim this, I am signing this object:

@troyswanson
troyswanson / csgo_log.txt
Created September 9, 2015 15:25
CS:GO Log
L 09/08/2015 - 22:10:57: Log file started (file "logs\L192_168_001_140_27015_201509082210_000.log") (game "C:\Program Files (x86)\Steam\steamapps\common\Counter-Strike Global Offensive\csgo") (version "6102")
L 09/08/2015 - 22:10:57: Loading map "de_dust2"
L 09/08/2015 - 22:10:57: server cvars start
L 09/08/2015 - 22:10:57: "mp_c4timer" = "45"
L 09/08/2015 - 22:10:57: "mp_roundtime" = "10"
L 09/08/2015 - 22:10:57: "sv_gravity" = "800"