Month: September 2024

vim: five tips to become a more mediocre vim user

i am a mediocre vim user. sure, i’ve been using vim for over twenty years, have handcrafted a custom vimrc, and even written a syntax file, but for my day-to-day usage, my skills are resoundingly and undeniably mediocre.

this is a good place to be. people who are ‘power users’ spend so much time fiddling with plugins and configurations to build their perfect homerolled ide that they never get any real work done. vim becomes their personality, not their tool. by contrast, novices don’t have the skill or knowledge to leverage vim’s power. they thrash around, treating vim like a cumbersome and difficult nano; they google how to quit. that’s not good for productivity!

the sweet spot is in the middle: mediocrity.

this post is going to go over five vim features that will get you on the path from novice to mediocre.

nobody cares if you’re mediocre at vim
Continue reading →

mysql: “thai food near me”, or: doing geo distance calculations in your database.

we’re all familiar with the whole “thai food near me” thing. you type that phrase into your phone and it responds with a list of thai restaurants that are, well, near you. and we have a kind-of understanding of how that works under the hood: google or whoever has a database of thai restaurants with their latitudes and longitudes and knows our location from our phone and then does ‘some process’ to figure out which thai places are nearby.

in this post,we’ll be going over that ‘some process’ part, looking at how to use mysql to do some standard location stuff. we’ll cover mysql’s POINT and POLYGON types, finding the distance between two points on a sphere (which the earth, contrary to what you may have read on the internet, is), determining if a point is inside of a polygon defined by points, and look at things like ‘spatial reference systems’ which define how coordinates are plotted on the surface of the earth.

a restaurant attempts an sql injection attack
Continue reading →

nginx: putting your site in ‘downtime’ for everyone except you

we’ve all been in that less-than-ideal situation of something going horribly awry in production and having to put the site into downtime while we fix it. that “scheduled maintenance”[sic.] page is important because it keeps users from seeing our glaring error, but it makes investigating or fixing production more difficult because, well, the site is in downtime.

in this post, we’re going to go over a couple of ways we can use nginx to show different content to different users based on their ip address; configuring our web server so that everyone in the world gets our downtime message, except us. we get to see site as normal, allowing us to engage in the not-quite-best-practice of debugging in production.

two users (left) are served the well-crafted downtime page, while the developer (right) sees the real site.
Continue reading →