//TODO: professional stuff of software engineerĀ 1001010
Monthly Archives: April 2012
Testing JavaScript Clocks

Here’s a quick little experiment to show the current time, as a time_t number of seconds since the Linux epoc, displayed as a code39 barcode. That feels nice and geeky šŸ™‚

This is just a proof of concept, I doubt the barcode will scan. It’s based upon c39 font typed into mspaint and cut up into pieces šŸ˜‰ The fun parts were..

  • Chopping up the barcode symbols. Ā It was a flashback to old school icon editing
  • Getting WordPress to not muck up the javascript – use HTML view & check it again if you switch back to visual editor.
  • Put a “window.onload = MyFunc();” at the bottom of your script block. Feels dirty overwritting the onload event & not adding it to a list of functions to call
  • switched to using window.addEventListener – feels sooo much cleaner than window.onload
  • preloading the images to cut down on flicker as an image is used for the first time
  • getting everything to work in my non-primary browsers

Now to search for the right css that will keep the div tag from word wrapping it’s image contents. Ā That initial load on some browsers is annoying. If you care to do something like this – view the source – it’s all there. Longer term

  • Test that the generated c39 symbology is valid. Ā I’m sure theĀ asterisks at the start and end are fine – I’veĀ stared at enough barcodes to recognize that at least šŸ˜‰
  • Shrink it & put it in the side bar
  • Maybe do a QR Code clock? Ā That could be interesting
C++ const ref member

I know people bag on c++ (for many valid reasons) but it still amazes me to learn something new: read only members using const references. It’s even better when a c++ non-fan teaches you about it. Thanks Nico!

class Test
{
public:
  Test() : readOnlyVersion(m_writableVersion)
  {}
  const SomeType & readOnlyVersion;
private:
  SomeType m_writableVersion;
};

Never having a need, I had always filtered out reference data members – I just categorized them with static members and their special initialization. Now that I see a use case, I’m basking in the “Ah that makes total sense” moment.