Posts

Showing posts from September, 2020

Understanding UNIX `time` command output

Bizarrely, I couldn’t find any documentation as to the output from the UNIX (BASH shell version  3.2.57(1)-release , here) `time` command. I thought I had it, but I wanted to be sure, so I wrote a quick shell script to verify my understanding. A script that takes 1 minute, 5 seconds to run will have output that looks something like this: iMac:~ me$ cat time_test.sh  #!/bin/bash sleep 65 echo " Done. " iMac:~ me$ time ./time_test.sh  Done. real 1m5.016s user 0m0.003s sys 0m0.006s An hour, 2 minutes, and 8 seconds ( sleep 3728 ): real 62m8.083s user 0m0.003s sys 0m0.007s A script that completes in approximately 2 seconds ( sleep 2 ): real 0m2.014s user 0m0.003s sys 0m0.006s Mystery solved.

Parsing and modifying Microsoft Word docx XML in PHP

Image
I’m implementing Microsoft Word templates in PHP. That is, taking an existing Word document, modifying some particulars on the fly, and spitting out the finished product (think: automatically generating legal forms, pre-populated with case names and docket numbers, assigned judges, that sort of thing.) The easiest way I’ve found to do that is to make liberal use of custom properties: Those custom properties can then be inserted into the document using the DOCPROPERTY field:   Modifying these on the fly should, in theory, be easy. Microsoft’s “ docx ” file format, in use since Office 2007 (Windows) and 2008 (Mac), is a ZIP archive containing multiple XML files. Easily enough processed with PHP’s ZipArchive functionality: // Store the supplied ZIP file data in a temporary file: $fp = tmpfile (); fwrite ( $fp , $data ); $stream = stream_get_meta_data ( $fp ); $filename = $stream [ 'uri' ]; $za = new ZipArchive(); $za ->open( $filename ); $nza = new ZipArchive(); $new_filename

On the dangers of flight

Found these quotes recently: In the catalog of human endeavors, few activities are as fragile as flight. The air offers no mercy for mistakes and no second chances. Flight is, as Winston Churchill observed, “an extremely dangerous, jealous and exacting mistress, ” demanding unfettered attention and respect. WINSTON S. CHURCHILL, THOUGHTS AND ADVENTURES 128 (Leo Cooper pub., 1990). “Flying is not inherently dangerous but very intolerant of errors.” (Which appears to be a twist on: “ Aviation in itself is not inherently dangerous. But to an even greater degree than the sea, it is terribly unforgiving of any carelessness, incapacity or neglect.”  Captain A. G. Lamplugh, British Aviation Insurance Group, London.)

Mooney back from the dead. Again.

  https://www.aopa.org/news-and-media/all-news/2020/september/03/pilots-aircraft-owners-buy-mooney-international . I’m not going to try and count how many times this makes it, that Mooney’s been “dead” and then revived. Hope springs eternal. They really are bitchin’ machines.

Freshly?

Image
 After looking at my DoorDash/Grubhub/etc. spends, I’m going to try Freshly for a minute. Reviews seem promising: An Honest Review of Freshly’s Meal Delivery Service Freshly Review: Is The Prepared Meal Delivery Service Worth It? Fingers crossed. Meal 1: Steak Peppercorn with Sautéed Carrots & French Green Beans September 21, 2020. Meals were delivered yesterday. Popped this in my ~1100 watt microwave for 3:30 and sat down with what was left of a bottle of Babcock’s Backroads Red Blend . Verdict: Not bad. Compared to Lean Cuisine? Blows it away. Compared to a homecooked meal from scratch? On par with what I’d whip up with budget ingredients. Nowhere near what I’d produce if I spent for even “high quality for the local supermarket” beef and veggies. But, it’s not meant to substitute for meals I actually make. It’s Bachelor Chow®: Now with flavor!™ Would eat again. Only 490 calories, too, well within where I want to be (I aim for about 600 calories per meal, give or take). October 3,