Monthly Archive for June, 2006

Foxit

Despite the cheezy website, Foxit is a great PDF reader.

It starts up freaking instantly. Multiple documents open in multiple windows by default. Better still, there is no installation required because it’s just a single .EXE.

This is what Acrobat would be if it weren’t too busy moonlighting as the posterchild for software bloat. I wish I had discovered this a long time ago.

The “Operated by” Scam

I just got back from a trip to Colorado, and everything was great save for the air travel. If you’re considering a flight from Seattle to Denver, or vice-versa, here’s a tip: don’t get suckered into the “operated by” scam.

I bought my tickets from American, only to later discover that the flight was actually operated by Alaska Airlines. This is because American doesn’t actually fly between Seattle and Denver. Instead, they sub contract to Alaska to fill the otherwise gaping hole in their coverage.

In my capacity as glorified cargo, I didn’t figure such a detail should matter to me. I don’t really care if the flight is operated by Santa Claus, just so long as he gets me where I want to go. Boy, was I mistaken.

I won’t bore you with all the details, but I had troubles on both my departing and returning flights, and in both cases I found that American blamed Alaska and Alaska blamed American. Each time one airline pointed the finger, I was forced to get in line and wait at the other airline’s counter.

In one instance, an Alaska representitive expressed worry that American would not pay them because of what he had done to help me. Talk about a lack of encapsulation. A passenger should simply not be exposed to this level of detail. I don’t care of American pays Alaska in greasy expired Chucky Cheese tokens, I bought a damn ticket and now I should be able to get on the plane!

So my advice to everyone is to avoid these “operated by” flights. If you have any suggestions on how to detect these things before the fact, I’d love to hear about them.

More Musings on Versioned C++

A couple of weeks ago I was bemoaning the lack of a C/C++ analog to Perl’s require statement. Today, I realized we’ve already solved this problem. Just google for __GNUC__ or _MSC_VER to see what I mean.

Let me back up for a second. Do you have copies of the C and C++ language specifications? Which versions? More to the point, I’d bet $10 you don’t really understand them (I sure as heck don’t).

But it’s OK — it doesn’t matter. Despite the noble efforts of our beloved standards body, we are only truly beholden to the de facto standard that is our compiler and library implementation.

Simply moving from the ACME C/C++ 8.0 to ACME C/C++ 8.1 may well require so many source changes as to be considered porting. And don’t feel safe just because you compiled and linked! We’ve got to test the whole shebang all over again. The newsgroups are rife with tiny snippets of code which are enough to invoke the specter of “undefined behavior.” Not to mention the fact that compilers have bugs too. Yes, even your code could be the next addition to ACME’s compiler QA suite!

So why fret over backwards compatibility? People with existing source code have existing compilers and libraries. They can just continue using them. Case in point:


   mark@turing ~ $ file `which gcc`
   /usr/bin/gcc: symbolic link to `gcc-4.0'
   mark@turing ~ $ ls /usr/bin/gcc-*
   /usr/bin/gcc-2.95
   /usr/bin/gcc-3.2
   /usr/bin/gcc-3.3
   /usr/bin/gcc-4.0

Maybe we can just forget this whole versioning thing and get on with improving C++.

Is Google Adsense Illegal in Washington?

On March 28th, 2006, Senate Bill 6613 was signed into law by Governor Christine Gregoire, making extra sure that internet gambling stays illegal in Washington state. The law took effect on June 7th, and makes it a felony to “transmit or receive gambling information” over the internet.

Thanks to the vague wording of the legislation, it may now be illegal for a WA-based web site to even link to a gambling site. One online casino review site (integritycasinoguide.com) has gone offline rather than risk potential jail time.

Indeed, because Mark++ is hosted in WA, it’s possible that the context-sensitive advertisements you will undoubtedly see associated with this blog post are illegal.

Linkage:

Click Here to Be Offended

CBS is being fined $3.6M for indecency after a rerun of a Without a Trace which depicted a teen orgy. The FCC recieved 4,211 complaints about the episode, many of which were apparently due to the Parents Television Council.

The PTC’s Take Action Now site has instructions for all you christian conservative lemmings out there.

The site explains how to get your name added to the formal complaint and, amazingly, includes a link to the offending scene in case you missed it.

(via BoingBoing)

Vista WiFi is Buggy

Every so often Vista decides that I have “Local Connectivity Only”, which is a very odd way of describing the situation where DHCP can assign me an IP address, but I can’t even ping my gateway.

It eventually just starts working.

Update:
Problem solved! I discovered that the problem correlated very highly with unplugging my laptop from the power outlet. It looks like Vista’s default power saving policy goes a little too far. In the advanced power settings menu I have now selected “low” power saving for my WiFi device, rather than the overzealous “medium”.

Hedberg on YouTube

There is a ton of great Mitch Hedberg stuff on YouTube. This joke (from his Comedy Central special) had me laughing out loud:

I was at a casino. I was standing by the door. A security guard came over and said, “You’re gonna have to more. You’re blocking the fire exit.”

As though, if there was a fire, I wasn’t gonna run.

If you’re flammable and have legs, you are never blocking a fire exit.

Or this one:

I like the escalator, man, cause the escalator can never break. It can only become stairs.

Confessions of a Street Addict

I just finished this one 10 minutes ago and had to blog about it. However you feel about Jim Cramer, he’s got a great story here and it was impossible to put down. It’s unfair to compare this to his second work, Real Money, because they are so different. (Confessions is a narrative about his hedge fund, and his early days at TheStreet.com, whereas Real Money is written in a how-to style.) Unfair as it may be, I vastly preferred Confessions.

Jim Cramer - Confessions of a Street Addict - Cover Image

Memoize.cpp

Here’s my attempt at writing a higher-order-function in C++ which allows one to memoize a function. It’s not complete. It doesn’t work for functions with signatures much more complicated than int fib(int).

Perhaps most disappointing is that there appears to be no way to generically memoize the recursive calls, the way Memoize.pm can.


#include <boost/function.hpp>
#include <map>
#include <iostream>

using namespace std;

template< typename T >
struct memoized_function;

template< typename R, typename A >
class memoized_function : public boost::function
{
   private:
   mutable std::map m;
   typedef boost::function super;

   public:
   template< typename T >
   memoized_function( const T& x ) : super(x) {}

   R operator()(A& a) const
   {
      if( m.find(a) != m.end() )
         return m[a];

      m[a] = super::operator()(a);
      return m[a];
   }
};

template< typename T >
memoized_function memoize( const T& f )
{
   return memoized_function(f);
}

int fib( int n )
{
   cout << "called fib(" << n << ")\\n";

   if( n < 2 )
      return n;

   return fib(n-1) + fib(n-2);
}

int main()
{
   cout << fib(5) << endl << endl;

   typedef boost::function func;
   func fastfib = memoize( fib );
   cout << fastfib(5) << endl;
   cout << fastfib(5) << endl;  // just a look up
}

The Upshot of Ugly Syntax

I just realized that one of the reasons I choose Perl for “quick hacks” is because the syntax is so ugly and inconsistent.

It’s a psychological thing. If I were to select Ruby, for example, I’d feel a tremendous obligation to write a beautiful well-designed program. I’d probably create a subversion repository, create unit tests, automate, etc. These are all important things, but I want to amortize their up front cost over the term of a long project.

I choose Perl because it takes the pressure off.




Creative Commons Attribution-NonCommercial 3.0 United States
Creative Commons Attribution-NonCommercial 3.0 United States