The earliest memory I have of ‘programming’ is in the early/mid 90s when my father brought home a computer from work. We could play games on it … so of course I took the spreadsheet program he used (LOTUS 123, did I date myself with that?) and tried to modify it to print out a helpful message for him. It … halfway worked? At least I could undo it so he could get back to work…

After that, I picked up programming for real in QBASIC (I still have a few of those programs lying around), got my own (junky) Linux desktop from my cousin, tried to learn VBasic (without a Windows machine), and eventually made it to high school… In college, I studied computer science and mathematics, mostly programming in Java/.NET, although with a bit of everything in the mix. A few of my oldest programming posts on this blog are from that time.

After that, on to grad school! Originally, I was going to study computational linguistics, but that fell through. Then programming languages (the school’s specialty). And finally I ended up studying censorship and computer security. That’s about where I am today!

But really, I still have a habit of doing a little bit of everything. Whatever seems interesting at the time!

CSV to JSON

Today at work, I had to process a bunch of CSV data. Realizing that I don’t have any particularly nice tools to work with streaming CSV data (although I did write about querying CSV files with SQL), I decided to write one:

$ cat users.csv

"user_id","name","email","password"
"1","Luke Skywalker","[email protected]","$2b$12$XQ1zDvl5PLS6g.K64H27xewPQMnkELa3LvzFSyay8p9kz0XXHVOFq"
"2","Han Solo","[email protected]","$2b$12$eKJGP.tt9u77PeXgMMFmlOyFWSuRZBUZLvmzuLlrum3vWPoRYgr92"

$ cat users.csv | csv2json | jq '.'

{
  "password": "$2b$12$XQ1zDvl5PLS6g.K64H27xewPQMnkELa3LvzFSyay8p9kz0XXHVOFq",
  "name": "Luke Skywalker",
  "user_id": "1",
  "email": "[email protected]"
}
{
  "password": "$2b$12$eKJGP.tt9u77PeXgMMFmlOyFWSuRZBUZLvmzuLlrum3vWPoRYgr92",
  "name": "Han Solo",
  "user_id": "2",
  "email": "[email protected]"
}

read more...


Advent of Code: Day 9

Source

Part 1: Given a list of distances between cities of the form London to Dublin = 464, calculate the shortest route that visits each city exactly once.

read more...


Advent of Code: Day 8

Source

Part 1: Given an escaped string of the form "\xa8br\x8bjr\"", convert it to the escaped form: br js. Calculate the total difference of lengths between the former (16) and the latter (5).

read more...


Advent of Code: Day 7

Source

Part 1: Given a list of definitions of the form 123 -> x, NOT e -> f, and x AND y -> z, with possible operations NOT, AND, OR, LSHIFT, and RSHIFT, find the value of a. Assume all values are 16-bit integers.

read more...


Advent of Code: Day 6

Source

Part 1: Given a 1000 by 1000 grid of lights and a list of instructions of the form (turn on|turn off|toggle) 5,10 through 15,20, determine how many lights are on.

read more...


Advent of Code: Day 5

Source

Part 1: A ’nice’ string contains at least three vowels, one double letter (such as xx), and none of the strings ab, cd, pq, or xy. Count nice strings.

read more...


Advent of Code: Day 3

Source

Part 1: Given a string of <>^v characters which mean move west, east, north, or south respectively and starting at the origin, how many unique positions do you pass through?

read more...