Skip to content

Instantly share code, notes, and snippets.

@andersontep
andersontep / pre-commit
Last active November 16, 2015 18:26
Automatically run flake8 on only your changes before each commit
#!/usr/bin/env python
"""
To use this hook, copy this file to REPOSITORY_NAME/.git/hooks/pre-commit
This pre-commit hook relies mainly on the diff_cover package to check for style
violations only in the lines of code you are about to commit. It's been pretty
awesome for me so far and it's definitely useful when working on legacy code!
In use, it might not be much different than git diff HEAD~1 | flake8 --diff
but I prefer the readability of the diff-quality output.
@andersontep
andersontep / usaddress_adapter.py
Last active August 20, 2020 17:15
Normalizing addresses with the usaddress package
"""
* requires usaddress https://github.com/datamade/usaddress
* check out the website! https://parserator.datamade.us/usaddress
The usaddress package is pretty great for normalizing inconsistent address data,
especially when if you have a lot to process and can't rely on using a geocoding api.
The results are really granular, probably moreso than you'll need, and definitely
more than most CRM systems if integrating these addresses is your goal.
This is just a simple wrapper around the usaddress.tag() function that I feel will