Using more of our brains: visualizing bridge data

Lots of bridges need maintenance. We can't fix them all at once. We're already collecting useful data during bridge inspections, but it's hard to interpret in raw form.

So this professor was inspired to take advantage of the fact that we're in 2015. He created a rich document (he used SketchUp) to bring together inspection data, photos, and a simplified 3D model of a bridge. It's immediately obvious how helpful this would be for the vital work of prioritizing infrastructure repair.

Simple but effective. We have to see it to understand it.

Capture state of Rails test database

Ever want to explore the state of the database during a Rails test run? I was recently writing a test to create a seam in some complex legacy code and needed this. Dropping this code in does the job in MySQL:

ActiveRecord::Base.connection.tables.each do |table_name|
ActiveRecord::Base.connection.execute("select * from #{table_name} into outfile '/tmp/datadump-#{table_name}.outfile'")

(or see this gist)

That creates a series of tab-separated files in /tmp/. Then LOAD DATA INFILE queries can bring the data back in, or in my case I used Sequel Pro’s import command configured for tab-separated input.

Get PHP APC cache uptime in seconds

I just posted about getting Apache uptime. For what I’m seeking, I need to compare the system uptime, Apache’s uptime, and the uptime of the PHP APC opcode cache.

Here’s code for a PHP page that will simply output the number of seconds the APC cache has been up.


$limited = true;
$info = apc_cache_info('', $limited);
print_r(time() - $info['start_time']);