Skip to content

Instantly share code, notes, and snippets.

@parkercoleman
parkercoleman / warmup.py
Last active July 18, 2018 18:20
Warmup solution
import nltk
from nltk.corpus import words
# nltk.download()
# print(words.words())
words = words.words()
phrase = "ada lovelace".lower().replace(" ", "")
longest_word = ""
[
{
"trimmed_geom": "GEOMETRYCOLLECTION EMPTY",
"db_id": 291,
"next_edge_id": [
110469155551
],
"lat": 30.093295175369,
"lon": -89.8040764104005,
[
{
"next_edge_name": "US Hwy 190",
"city_name": "Denham Springs",
"lat": 30.4753389421302,
"next_edge_id": 1104259508571,
"trimmed_geom": null,
"lon": -90.9601269552938,
"db_id": 15
TypeError: {'steps': [{'trimmed_geom': None, 'next_edge_id': 1104259508571, 'db_id': 15, 'city_name': 'Denham Springs', 'lat': 30.4753389421302, 'lon': -90.9601269552938, 'next_edge_name': 'US Hwy 190'}, {'trimmed_geom': 'LINESTRING (-90.9612010000000026 30.4754590000000007, -90.9613279999999946 30.4753089999999993, -90.9613700000000023 30.4752599999999987, -90.9615009999999984 30.4751049999999992, -90.9618980000000050 30.4746430000000004, -90.9620299999999986 30.4744899999999994, -90.9621839999999935 30.4743080000000006, -90.9623799999999960 30.4740800000000007, -90.9626499999999965 30.4737650000000002, -90.9626899999999949 30.4737200000000001, -90.9628000000000014 30.4735799999999983, -90.9629350000000017 30.4734209999999983, -90.9632000000000005 30.4731099999999984, -90.9633419999999973 30.4729460000000003, -90.9634800000000041 30.4727899999999998, -90.9635559999999970 30.4727020000000017, -90.9636100000000027 30.4726399999999984, -90.9637840000000040 30.4724380000000004, -90.9638599999999968 30.4723499999
@parkercoleman
parkercoleman / problem0c.sql
Created December 22, 2015 04:52
problem 0c
SELECT name
FROM geo.states_ne
WHERE admin = 'United States of America'
@parkercoleman
parkercoleman / problem0b.sql
Created December 22, 2015 04:47
problem 0b
SELECT name, admin
FROM geo.states_ne
@parkercoleman
parkercoleman / problem0a.sql
Created December 22, 2015 04:45
problem 0a
SELECT *
FROM geo.states_ne
LIMIT 20
@parkercoleman
parkercoleman / problem5.sql
Last active December 10, 2015 04:30
Maptime Seattle Postgis - Problem 4
SELECT p.name, MIN(ST_Distance(p.geom, c.geom, true)) * 0.000621371 AS distance_miles
FROM transport.ports_ne p
CROSS JOIN geo.coastline_ne c
WHERE ST_Within(p.geom, (SELECT geom FROM geo.countries_ne WHERE admin = 'United States of America'))
GROUP BY p.name
ORDER BY distance_miles DESC
@parkercoleman
parkercoleman / problem4.sql
Last active December 10, 2015 03:32
Maptime Seattle Postgis - Problem 4
WITH county_hurricanes AS (
SELECT DISTINCT c.name AS county_name, s.name AS state_name, h.serial_num
FROM geo.counties_cb c
INNER JOIN geo.states_ne s ON c.statefp = right(s.fips, 2) --The FIPS codes in the state table have "US" infront of them, the right() function trims that
INNER JOIN weather.hurricane_lines_noaa h ON ST_Intersects(c.geom, h.geom)
WHERE s.admin = 'United States of America'
)
SELECT county_name, state_name, COUNT(*)
FROM county_hurricanes
@parkercoleman
parkercoleman / problem3.sql
Created December 9, 2015 23:45
Maptime Seattle Postgis - Problem 3
WITH states_with_railroads AS (
SELECT DISTINCT s.name
FROM geo.states_ne s
INNER JOIN geo.railroads_ne r ON ST_Intersects(s.geom, r.geom)
WHERE admin='United States of America'
)
SELECT DISTINCT s.name
FROM geo.states_ne s