The Latest

PHP 7.2 and 7.3 Highlights

Having recently researched migrating off of Mcrypt, I’m looking forward to seeing a codebase I work on make the leap from PHP 7.1 to 7.3. With large codebases like this one, upgrades can be a bit of a slog, so I find it helps to get excited about the benefits and changes that they bring. Here are some highlights that I’m personally looking forward to in the jump from 7.1 to 7.3!

You can of course read about all the changes in 7.2 and 7.3 in the PHP docs.


Wild Assumptions About Entropy

I recently conducted a brief audit of two factor auth recovery codes patterns employed by major tech companies. One of the factors I considered was how “complex” their patterns were. In other words, how hard it would be for someone (or some machine) to guess the recovery code. As these codes are generated randomly, brute forcing would be the only way to break them.

In computer science, this type of complexity is represented as “bits of entropy”, and the formula for calculating it is pretty straightforward. Unfortunately, it’s a bit too complex for me to do in my head, so I created some JavaScript functions to help.


Avoiding the Worst Technical Debt

..or, how not to paralyze your future self.

When we talk about technical debt, we’re talking about paralysis. It means an organization can’t do something good today, because it handcuffed itself in the past with a poor decision.

There is nothing inherently bad about old code. Over time, coding styles, architectures, and environments may change, but code can often be operational and maintainable for a surprisingly long time. In many cases, tech debt is a treatable condition. It might slow you down, but it needn’t paralyze you.


Explore the Russian Troll Tweet Dump

NBC has published a database of the deleted Russian troll tweets. There’s even a nifty graph database for exploring them, Neo4j.

But what if you want to explore the data in your own PostgreSQL database? Here is some SQL to create the database and tables, import the CSV files, and convert text data to more convenient formats:

Tested on PostgreSQL 9.3.21, may require adaptation to work with other RDBMSs or versions. Enjoy!

New Tool: SQL to CSV

I write a lot of SQL queries at work and, quite regularly, find myself exporting them to CSV files. PostgreSQL’s command line client, psql, has a command to handle this task – \COPY – that you can use to output the results of a SELECT statement to a local CSV file. It looks like this:

\COPY (SELECT * FROM foo) TO '~/output.csv' CSV

That works well, but it’s tedious to constantly convert commented, indented SQL into a one-line COPY command. Sure, I could create a macro in my text editor to handle this. Since I’m probably not the only person annoyed by this though, I created a simple tool anyone can use to automate the conversion: SQL to CSV. Give it a try!

Screenshot of SQL to CSV tool