Archive for November, 2008

“I disapprove of what you say, but I will defend to the death your right to say it”

Tuesday, November 25th, 2008

Despite the title, the LA Times article below is well worth a read. It touches upon one of the issues that has arisen after the Prop 8 loss in California*: the silencing of the opposition. Personally, I feel that Prop 8 was an immense miscarriage of justice. However, it is very important to remember that there are a number of people out there - some in surprising spots - who whole heartedly disagree with me. That is their legal right. It is entirely inappropriate to go after anyone who may have supported Prop 8 on a personal level. No one’s job should be at risk for their politics. Discrimination based on support for Prop 8 is still discrimination. If nothing else folks, think about how you would feel if the shoe were on the other foot! (ENDA anyone?)

* In case you haven’t heard, the CA Supreme Court has taken up a case considering the constitutionality of Prop 8. I’d say there’s a close to even chance it gets struck down. Let us hope not.


Liberal Hollywood ponders next step in fight for same-sex marriage

After the passage of Proposition 8, some are calling for boycotts and firings. Others worry about free speech rights being trampled.
By Rachel Abramowitz and Tina Daunt, Los Angeles Times
November 23, 2008

In case you didn’t recognize the quote from the title of this post, it’s a famous one in support of free speech by Voltaire (probably).

Using an ostrsteam correctly

Thursday, November 20th, 2008

At work, I recently ran across a bug in some legacy code using ostrstream. As it turns out ostrsteam is extremely bug prone. In fact, ostrsteam has actually been deprecated in favor of stringstream. If you’re writing new code, do yourself a favor, stop now, and go use stringstream.

If you can’t - say you’re maintaining legacy code - I strongly advise checking to ensure that your code follows the pattern below. If you’re not - and you’re using dynamic buffering (the default) - you probably have at least one bug and one memory leak in your code.


/* By default the constructor allocates a 512 byte block of memory which is managed by the object itself. */
ostrstream stream;

stream << /* some data */;

/* This is the first bug fix. An ostrstream is a BINARY stream. It is not NULL terminated by default, even when calling str(). Since an allocator is not guaranteed to give you a zeroed block of memory, your string may be much longer then you expect. This could cause memory corruption, data corruption, or stack dumps. (Mine was the first two and was a royal pain in the ass to track down.) */
stream << std::ends;

/* Not absolutely required, but the second parameter is an example of paranoid programming. Just in case someone comments out the line above, you'll still be safe from memory corruption. Note: Depending on you're implementation of string, you might get a string with two null characters at the end. This shouldn't cause any problems, but is worth mentioning for clarity sake. */
std::string str( stream.str(), stream.pcount() );

/* This is the fix for the memory leak. The str() call above gave the caller (you) responsibility for deleting the dynamically created buffer. Rather than worry about how that buffer was allocated (new[] versus malloc), you can just tell ostrstream that you don't have a reference to its internal buffer and it will take ownership of the buffer again. Thus the dynamic buffer gets deleted when stream goes out of scope. */
str.freeze(false);

Now if only more UI designers would read this

Tuesday, November 18th, 2008

I have occasionally been tempted to write a post/rant about about interface design. Instead, I’ll just refer you to a couple of useful resources, and say “what they said!”

What reading Tufte won’t teach you: Interface design guidelines - Simply stated rules for designing UIs.

User Interface Design for Programmers by Joel - If you haven’t read this, and you claim to be a UI programmer, who the heck are you kidding?

more to come.. Suggestions welcome.

Join the Impact Rallies/Protest TOMORROW Nov 15th

Friday, November 14th, 2008

If you’re friends with me on Facebook, you just a got an event invitation for a series of rallies that occurring all over the nation tomorrow. I usually don’t spam everyone I know with political events since I hate it when people do so to me. This time though, I’m making an exception.

Enough is enough folks! Proposition 8 was a f*cking slap in the face. Its time we, queer folks and straight allies alike, stood up and said something about it. Please take some time tomorrow and join a local protest in your town. Don’t just stand by and let this go unopposed.

To find out about a rally in your town, see http://jointheimpact.com/. Or if you’re as much of a Facebook junkie as I am, check out http://www.facebook.com/event.php?eid=33598248873#/event.php?eid=45356108205. There are events in literally every state in the nation. You won’t have to go far to find one.