Posts

Showing posts from September, 2019

JavaScript Unit Testing with Jasmine

Image
So I built a fairly involved single-page JavaScript / HTML app that generates litigation calendar events using some convoluted logic (calculating holidays, when those holidays are observed (e.g., if November 11th falls on a Saturday, Veterans Day is observed on the preceding Friday, but if it falls on a Sunday, it's observed the next Monday - CRC 1.11 ), etc. It’s large, and important, enough, I finally sat down and learned how to build Jasmine unit tests for JavaScript. My code may be spaghetti (I never really sat down to learn JavaScript, and kind of winged it with ES6 for this app), but at least it will be validated spaghetti. I have a book, JavaScript Unit Testing , that covers Jasmine 1.2, so I’m using the ancient 1.3.1-standalone version here. It works, for now (I’ll learn the new stuff as I have time). src/testCode.js The code being tested. This is a silly, simple example: function returnsTrue() { return true; } spec/testCodeSpec.js A “suite” is a group of te

Enabling an HTML application for offline use in iOS

I have a couple of single-page HTML / JavaScript applications I’ve built that can be loaded onto an iPad or iPhone for use when offline (10,000' in the air, or buried in an ancient concrete-and-steel courthouse building). Steps required (paraphrased from, e.g., here ): Create a cache.manifest file Mine are pretty simple; here’s an example: CACHE MANIFEST # Serial number 2 apple-touch-icon.png index.html Make sure the web server is properly configured to serve .manifest files with the proper MIME type (text/cache-manifest). Here, I’m verifying that using Lynx (I’ve highlighted the MIME type information in bold): $ lynx -head -dump http://www.punctumarchimedis.com/garmin/cache.manifest HTTP/1.1 200 OK Date: Sun, 15 Sep 2019 22:41:32 GMT Server: Apache/2.2.15 (CentOS) Last-Modified: Sat, 02 Mar 2019 05:05:41 GMT ETag: "80797-41-5831579a458e8" Accept-Ranges: bytes Content-Length: 65 Connection: close Content-Type: text/cache-manifest

Dynavin N7 Pro

Decided to finally upgrade my 15 year old E46 M3 and bring it into the 20th century. There are a variety of options, including Chinese Android boxes (some of which have more capability), hacks that put a double-DIN into the sculpted dash (which looks about like what you’d expect), and, for my money, the gold standard, the Dynavin N7 Pro . (I briefly had installed an older N7 with the iLink module, which I got before the N7 Pro was available.) It required relocating the environmental controls using a kit they sell (and giving up the little sunglass compartment, c’est la vie), but was otherwise plug-and-play. Seriously, I’ve done probably a dozen stereo installs into the vehicles I’ve had over the years, and this was by far the easiest. Pictures to come, but, trust me when I say it really looks OEM, and no crimping or soldering required for the install. The wiring harness, etc., just clips in, and you’re up and running. The only hiccup I had: The steering wheel controls didn’t work in