During my commute to work yesterday (that's what I call the hallway between my bathroom and bedroom) I was inspired by a shared tweet from a friend.
I don't agree with Zuck on much, but the more things we can ban Trump from the better. So now I just need to figure out the best way to ban the Orange one from my website, which considering he doesn't have an account here yet is actually harder than it sounds. But hacking together random garbage for fun is my bread and butter, so we're off on an adventure!
First up is checking if my DNS or hosting provider can do any sort of location or IP based serving or in this case blocking. Given how janky and barebones this site currently is the answer to that is a resounding no. I don't even have a backend server at this point so we are going to have to get extra creative, or change hosing providers but I'd rather write code than click through someone else's interface.
Well my next thought is, Trump at this point is probably only in a couple of locations, and I can get the browser client location with permission or from IP Address lookup. Trump is unlikely to visit this site, and he is probably even less likely to allow browser location permissions, so I'll have to use IP lookup. A quick Google search leads me to
https://www.geoplugin.com/ where I can make requests with a clients IP address and get back location information. Now I can see all the parts fall into place and I can make this happen.
At this point I can start writing some code, and if you read my previous post you'll know that I've been interested in giving Brython a shot; Well no time like the present. Cut to sweet hacker montage where I
- Got Brython and Geo Plugin working, which converts your browser IP to Latitude and Longitude
- Looked up the lat/long coordinates for Trump's most likely locations, The White House, Trump Tower NY and Mar-a-Lago
- Found a formula for calculating the distance between two sets of lat/long coordinates
- Connected the logic so if you are within 5 miles of one of those locations on site load you get a popup that stops you from reading this site's content.
Well that's it, Donald Trump is now 100% definitely, unquestionably, banned from markmiscavage.com (assuming he visits the site from one of his predetermined locations, and his ISPs location actually maps to a location within 5 miles of the coordinates I found), but what about all the innocent bystanders that will be caught in my broad net to squash the outgoing Presidents attempts to view my content. I can't just callously ban everyone else on the White House staff from viewing my sweet, sweet website. I need some sort of Trump-capcha to 100% affirm that someone who is at a banned location, is in fact Donald Trump.
Well I can do that with a bit more Brython code and a clever question no human (or computer) could possibly beat.
Click Here To Pass The Trump-Capcha Yourself
Now I think we can, with 120% certainty say that Donald Trump cannot view my content and no innocent bystanders will be harmed by my extremely secure and foolproof solution, and that makes me happy.