Milo Land

Fun script I made recently

I've been working on a volunteer coding project for the last little bit. Making a basic CRUD app for a non-profit. I've been working with Pug, Sass, Node, Postgres, and aiming really heavily at progressive enhancement. It's been a great exercise in making a fully accessible frontend with minimal shiny development things. Pug and Sass in particular have been making progressive enhancement less tedious and building/maintenance more composable and fun.

Pug

Sass

While I've been doing this, I've had to do a few data migrations and I'm always proud of these silly little scripts. A few different times, I've had to convert a list of country codes, zip codes, state names, or whatever, into a useful list for migrating a ton of data. Awk has saved the day many times already.

Awk

One easy one I had to do was convert a bunch of country codes and their names into a select field. Absolute pain to do manually, of course. But converting a CSV into a bunch of lines of Pug was easy:

# Data was in the format of `country-code,alpha-3,alpha-2,name`
sort -t ',' -k4 data.csv | \
  awk 'BEGIN { FS="," } { print "option(value=\""$1"\" selected= (value === "$1")) "$4 }'
# Output example:
# option(value="840" selected= (value === 840)) United States of America

I know it's not sexy or special, but it's great to remember that these tools someone made like 40 or 50 years ago still can do so much with so little. And that they make me so happy to build them.