Posts

Musings

We were discussing preferences for upper/lower case usages in hex constants in C (wow, that sounds dull) on my favorite C programming forum, when one of the members mentioned poetry in hex, i.e. a poem using only letters A-F.  Haiku was mentioned, so here is what I came up with Cad bade deb abed Deb ebbed, cad beefed, deb ceded Deb dabbed beaded face Hex is too limiting, so we went back to plain old English, and switched over to limericks as well, though we kept it in the tech/nerd realm.  A few more of my creations When it comes to C, I'm quite bad ass But C++ just kicks my ass Why do I blunder OOP, do you wonder? I simply don't have any class. This thread has indeed become glorious Though nerd-rhymes are quite laborious I've become far too lax Now my quality lacks And my bad verse has made me notorious If you are no C++ connoisseur And inherit a non-virtual destructor Then ever so silently Your memory leaks violently And we laugh and say "now

Easier sed than done

sed seems to be one of the least used, and possibly most hated of the standard Unix utilities.  But honestly, I think it gets a bad rap.  Sure, it seems to have a steep learning curve, but vi did too when I first started.  It's just that I use vi heavily, on a daily basis.  Not so much sed.  I must admit, my sed skills are sketchy at best.  I can only produce meaningful sed scripts with a good reference, but it's often the best tool for the job.

Good Preprocessor Usage

I was digging through some code and came across the following preprocessor construct: #if FOO == 0 void foo(int bar) { #endif #if FOO != 0 void foo(float baz) { #endif As a general rule, conditionally-compiled code makes the hairs on the back of my neck stand up, but given that this is code for embedded systems, and the same basic code runs on a number of different hardware platforms, I understand that it is sometimes a necessary evil.  The problem is, people don't always treat preprocessing directives as what they really are: code.  They're instructions processed by a computer, and deserve the same good coding practices that one would apply to the rest of their source code.  Preprocessor code may actually deserve more attention to best practices due to the difficult nature of debugging it.  Taking the above as a case study, here are a few thoughts on how to improve this:

Dynamic Greasemonkey Scripts

A friend and I recently did some work for a client creating a small Greasemonkey script.  Greasemonkey is a nifty little tool that lets you run custom scripts on webpages of your choosing.  These scripts are written in JavaScript and are local to your machine, not served up from some remote server.  They let you make changes to web pages on the fly, as if you got to write your own JS for that page. The GM script had to work for Firefox and Chrome.  Firefox requires an extension, whereas chrome recognizes a GM script automatically.  The task seemed pretty easy.  We needed to dynamically create a GM script to be installed on the user's system.  All a GM script really needs is some JS with a few special comment fields at the top of the script, and you're ready to rock and roll.  No biggie I thought, I'll just hack up a quick PHP script to spit back the custom JS...no dice.  It turns out that the GM plugin in Firefox and Chrome's auto-detection require that the file name

Welcome!

I guess I'm only welcoming myself for now, since nobody else reads this (yet).  It's about time I got one of these things going.  I still have no idea what direction this thing will take, but I might just let it steer itself and enjoy the ride.  I figure there will be a fair amount of techie stuff here, mostly revolving around C, embedded programming and maybe some PHP extensions.  Hobbies include brewing, surfing, working on cars and houses, so some of that will likely pop up.  And I like to follow current events, politics and economics, but on a somewhat light level, so you might see the occasional post about that.  I like to ponder math, religion, philosophy, literature and linguistics, so a bit of that might come up too.  Basically, nothing is off limits, but I'll try to keep it to polite dinner table conversation.  So check back from time to time, and hopefully you'll find something interesting.