More LEGO Sets

Back at the cottage means more of my old LEGO sets! These were the smaller sets that you could sometimes convince your parents to buy you on a whim if you happened to be at the mall and begged loud enough, whereas the bigger ones like the seaport were reserved for Christmas.

6524: Blizzard Blazer

6644: Road Rebel

6646: Screaming Patriot

6351: Surf N’ Sail Camper

The names of the sets are absolutely hilarious. “Screaming Patriot”? They sound like the names of unlicensed Halloween costumes. You know the type, where it’s clearly “The Incredible Hulk” but it’s called something like “Angry Green Man”. I’m guessing they were named by some Swedish guy who worked at LEGO in the 1980’s and 1990’s and was given the job because he had a relative in America.

More LEGO Sets

Hidden Metro

I am rapidly approaching my fortieth birthday. That means I’m old enough to remember when Toronto was “Metro Toronto”. Long story short: Toronto used to be governed by many small regional entities who all cooperated under a framework called Metropolitan Toronto. Just before the end of the previous century this was replaced with one monolithic government in the name of “cost savings”. Whether that was actually successful or not I can’t say for certain (though my completely non-scientific intuition says it’s not terribly likely) but the neat thing is that you can still find the logo for Metro Toronto hiding all over the place. I try to take pictures of it when I see it.

On overpasses
On crosswalk buttons
On bollards
Hidden Metro

Unzip a File to Memory in Scala

Recently I had some trouble unzipping a file in Scala.  After combing through many different StackOverflow threads I eventually worked out this solution:


def unzip(path: String): Map[String, Array[Byte]] = {
val zipFile = new ZipFile(path)
zipFile.entries().asScala
.filter(!_.isDirectory)
.map { entry =>
val in = zipFile.getInputStream(entry)
val out = new ByteArrayOutputStream
IOUtils.copy(in, out)
IOUtils.closeQuietly(in)
IOUtils.closeQuietly(out)
entry.getName -> out.toByteArray
} toMap
}

Unzip a File to Memory in Scala

Merged Cells and Formatted Text in SpreadsheetApp

Google Apps Script is a really nice way to interact with Google Docs programatically.  You can write add-ons or stand-alone scripts to read or modify documents and have access to a DOM, which is a much nicer way to do things than attempting to use a REST endpoint or similar. The only problem is that while the DOM/object model is reasonably complete, it isn’t totally so.  As of this writing there is no way, when dealing with spreadsheets, to determine if a cell is merged, or, more frustratingly, obtain the formatted contents of the cell.  We really needed this information recently, so we decided to parse it out of the HTML that you get when exporting the document.  This can be done in Apps Script itself.

You can see the gist here.

Basically we build up an associative array, where for a given cell index you can get back the row span, column span and formatted value.


parsedHtml['Sheet1:A1'] = {index: 'Sheet1:A1', text: '123,456', rowspan: 2, colspan: 2}

If there is no entry for a given cell index then that cell is part of a merged range or outside the data range.  The latter should be known beforehand.

NOTE: that this code requires underscore.js to work, you can read an article from Google about how to use it in apps script projects here.

Merged Cells and Formatted Text in SpreadsheetApp

View Adobe Swatch Exchange Files Online

The other day I was trying to do some web design according to IBM’s design guidelines.  They provide color swatches as .ase files, which are read by Adobe products like Illustrator, PhotoShop, etc.  I have none of these applications but I figured “hey how hard can it be to parse the file myself?”

Two days and a fair bit of hair tearing later witness palettes.mybluemix.net!

I later found out that IBM Design does provide a site that shows the same information, but by that time I was way to consumed with the problem.  That happens sometimes.  But hey, now I can look at any .ase file!  And so can you!

View Adobe Swatch Exchange Files Online

Why Does Apple’s Revenue Spike Every Fourth Quarter?

http://xbrl.mybluemix.net/show/b4fe1406-41f8-4cb7-a22a-efd1c86b4195

Could be again that I’m just not displaying the data the right way.  Or, that the fourth quarter is more important from an analyst perspective so Apple will try and “close” more revenue in Q4?

These are the things I find confusing about accounting, though it’s interesting to learn the reasons why things are the way they are.

Why Does Apple’s Revenue Spike Every Fourth Quarter?