« September 2006 | Main | November 2006 »

October 21, 2006

Privacy

Much has been said around the lose of privacy particularly in this growing world of identity theft. People have been thinking about trust and computers since the beginning. Scott McNealy once said "You have zero privacy now. Get over it" (the PC Week "Quote of the Week," Feb. 1, 1999). The ACLU is fighting against the lose of privacy as are many other groups. Now I learn of a site called Abika (part of the Intelius network) that will not only lookup background information for a fee but also will compile physiological profiles. If that site doesn't suit your needs try one of the many others available.

I've previously talked about what a liability this blog is. Yet at his point the concept of erasing something from the web is all but impossible. Server down? Just search for it on Google and click the little "Cached" link. Yes you can turn that off they are only guidelines. Maybe your site isn't big enough to make it on the Internet Archive or maybe NeoPhi does qualify. My point is even if I wanted to remove the potentially questionable pages on this blog, I've still left other digital trails. Hell look at the bottom of that page and you can even track my future Usenet postings.

Maybe McNealy was right. My digital trail is huge and I would never be able to erase it all. People can find me, but I'm going to adopt the Wikipedia mentality; assume good faith. I will continue to do what I can to protect my online privacy while still being connected. I think of it like the lock on my front door, it is there to stop the curious, not the determined.

Tags: life privacy

Google's New Slogan?

Chris Anderson made an on-the-fly remark concerning The Long Tail during his Pop!Tech Q&A session concerning how to find things in the long tail. It didn't come out quite the way he wanted:

Google is the worlds greatest tail finder.

Tags: funny

October 17, 2006

Been Busy

Nothing of substance on here as of late since I've been busy. Or busy in my mind at least. Part of that being busy is procrastinating about what should really be keeping me busy but that I'm not doing. I'm not sure how well that parses. Let me try again. I'm not always doing what I should be doing so I feel like I'm always busy but not everything that is using up my time is productive.

I think I've mentioned in the past that I'm lucky to have large blocks of free time, in the sense that there isn't something that I should be doing at that point. Some have argued that having large chunks of free time like that is vital to working on big problems. I won't even begin to claim that I'm working on something more important. Call me selfish, and to some extend I am, but I like me time when it is my time.

I don't like me time when it is work time. I like having something to do at work. Having something to do when it is mine time varies from good to bad. The good is when it is something that I want to be spending time doing. Sometimes that's pure leisure like watching the entire 4400 marathon in a day. Other times it is something neat like playing with new software or odd jobs around the house.

Right now my procrastination centers around the class I'm taking. Yes, I'm back in class trying to complete that Masters I started a couple of years ago. I'm going through a serious love-hate relationship with it. I find the work interesting, when I understand it, and having the long-term goal is great, but when it is eating up that free time I sometimes don't love it as much. I'm finding it mostly centers around my mood. Some days I can wake up or come home from work and really want to work on my course work, while other days I really just want to watch TV.

The problem is course work has deadlines and my mood and those deadlines don't always match up. Couple that with some of that lack of understanding and the problem just gets worse. Keep in mind I'm not trying to make excuses and I really don't want to sound like I'm complaining, I chose this. If anything else I'm trying to reason aloud about how to make it work for myself.

During some of that procrastination time I've done some activities that had been sitting on the back burner for many years. In no particular order:

Played Racquetball, I won all the games.

Played an entire 7 game cribbage set, I lost while tied 6-6 by flubbing my pegging and landing in dead man's hole. That's what 5 and a half hours of play will do.

Tags: life

October 6, 2006

Nihilism

If ever there was a comic that captured much of what I feel this is it. That being the squirrel guy :)

Tags: life

October 2, 2006

Singleton Pattern in AS3

AS3 does not support private or protected constructors which makes it harder to implement the singleton pattern. Below are some approaches I've run across on the Internet, problems with them, and what I hope (please tell me if I'm wrong) corrections to get a real singleton pattern working.

First up is an entry by Andrew Trice about Singletons in AS3. His code was:

// faulty example
package {
    public class Singleton {
        private static var singleton : Singleton;
		
        public static function getInstance() : Singleton {
            if ( singleton == null )
                singleton = new Singleton( arguments.callee );
            return singleton;
        }
	
        //NOTE: AS3 does not allow for private or protected constructors
        public function Singleton( caller : Function = null ) {	
            if( caller != Singleton.getInstance )
                throw new Error ("Singleton is a singleton class, use getInstance() instead");
            if ( Singleton.singleton != null )
                throw new Error( "Only one Singleton instance should be instantiated" );	
            //put instantiation code here
        }
    }
}

You can defeat this approach with:

var a:Singleton = new Singleton(Singleton.getInstance);
var b:Singleton = new Singleton(Singleton.getInstance);
// a !== b

The constructor is doing a function reference comparison, but the function being compared to is available to the caller which is why it can be passed in to defeat the test.

I was also pointed at an approach created by Matt Chotin and posted to Flex Coders. This is a direct cut'n'paste so there are some syntax errors.

// faulty example
package whatever {
  public class MySingleton {
    public function MySingleton(singletonEnforcer:MySingletonEnforcer) { }

private static var instance:MySingleton;

pubic function getInstance():MySingleton {
if (instance == null)
instance = new MySingleton(new MySingletonEnforcer());
return instance;
}
}
}

//this is in MySingleton.as but is outside the package block
class MySingletonEnforcer {}

You can defeat this approach with:

var a:MySingleton = new MySingleton(null);
var b:MySingleton = new MySingleton(null);
// a !== b

If you don't know about private classes I wrote up some information. This is just a missing null check in the constructor to make sure that a valid reference was passed in. I like this approach better overall since it has more compile time support. Trying to call "new MySingleton()" gives an "expected 1 argument" compile time error and trying to call "new MySingleton(XXX)" with anything but null will give you a class cast exception. But that is my personal preference.

I'd also recommend that you add final to the class definition. While I'm pretty sure you can't get access to stuff that easily in AS3, it is probably best to guard against subclassing.

If you want to use the first approach, it can be fixed with the introduction of a private method:

package {
    public final class Singleton {
        private static var singleton : Singleton;
		
        public static function getInstance() : Singleton {
            if ( singleton == null )
                singleton = new Singleton( hidden );
            return singleton;
        }
        private static function hidden():void {}	
        //NOTE: AS3 does not allow for private or protected constructors
        public function Singleton( caller : Function = null ) {	
            if( caller != hidden )
                throw new Error ("Singleton is a singleton class, use getInstance() instead");
            if ( Singleton.singleton != null )
                throw new Error( "Only one Singleton instance should be instantiated" );	
            //put instantiation code here
        }
    }
}

The second approach can be fixed with the introduction of a null check:

package whatever {
  public final class MySingleton {
    public function MySingleton(singletonEnforcer:MySingletonEnforcer) {
        if (singletonEnforcer == null) {
            throw new Error ("MySingleton is a singleton class, use getInstance() instead");
        }
    }

private static var instance:MySingleton;

public static function getInstance():MySingleton {
if (instance == null)
instance = new MySingleton(new MySingletonEnforcer());
return instance;
}
}
}

//this is in MySingleton.as but is outside the package block
class MySingletonEnforcer {}

This final example, which I think is best, comes from Daniel Hai via Ted Patrick's JAM. The entry is "Singleton Take 2":


package {
public final class Singleton {
private static var instance:Singleton = new Singleton();

public function Singleton() {
if( instance ) throw new Error( "Singleton and can only be accessed through Singleton.getInstance()" );
}
public static function getInstance():Singleton {
return instance;
}
}
}

I've updated Wikipedia with this last example. Please change it if you notice any problems.

Tags: as3 flex pattern singleton

October 1, 2006

10 months

For a long time I listened to my collection of music on a random album basis. iTunes was one of the few programs that actually lets you randomize by album instead of track. While trying to find a sample in a song that borrowed from a movie I decided to start listening to my music collection in alphabetical order by album (I never did find the sample I was looking for). This is all based off of listening to music on my computer when I'm working at it. I also listen to a lot of music at work and on CDs. Yes I still listen to CDs since I have a decent enough stereo system that CDs still sound better and don't require me to have cords running all over the place.

While looking for a piece of music today I looked over the last played times of all my music. Turns out 10 months later I've started my second loop. Meaning it's taken me almost 10 months to listen to everything in my music collection. iTunes reports that I have 21.6 days of music. Roughly that means that I'm listening to music on average 1.75 hours per day. That also means that I'm sitting at my computer that much per day. Scary thought.

Tags: life music