Random Thoughts of a Scatterbrain.
 Friday, January 19, 2007

Well I'll Be Damned...

1/19/2007 1:26:54 PM (Eastern Standard Time, UTC-05:00)

Just a few days ago, I was praising Microsoft hardware and support after calling to get my broken IntelliMouse replaced.

So today when I got back from lunch, to my surprise, I found a huge package sitting on my front steps.

new-keyboard.jpg

Awesome!  They sent a whole new set.  Now I have an extra wireless keyboard.

I'm heading out to Utah in 5 hours, so I'll leave this week on a random note:

quincy-log.jpg

For those of you who have been following along, this is my lizard Quincy, who just a few months ago, was the size of my pinky.

 Wednesday, January 17, 2007

Forgive And Forget

1/17/2007 5:33:04 PM (Eastern Standard Time, UTC-05:00)

I really think that one of the big keys to success and happiness in life is to be able to forgive and forget.  With some people, it just comes naturally and easily; they can move on and mend relationships without regards to whatever transpired.

Of course, for many people, this is an acquired life skill that comes with maturity.  Take my mother, for example.  In her younger days, she was probably too unwilling to compromise and too headstrong.  She held her grudges against my father for the longest time, but as the years have passed, she has come to understand how she erred in not being more flexible.  Nowadays, she's pretty much always happy-go-lucky when you bump into her.  Even when we have disagreements or we have a small fight, she never holds it against me.  It's not just me, she's the same way with everyone she meets.

I'm still working on it.  I am kind of egotisctical and unerring in my presumption that I'm always right :-P (just ask my sister).  On top of that, it takes me a long time to forgive and a longer time still to forget.  I hope that I can correct this over time...life's truly too short to hold grudges.  It's just that for some, like me, it takes a really long time for that to set in.

I started thinking about this after reading an article on Jeff McInnis, who was basically banished from the Nets team for a whole year and whose career was put in limbo - especially so considering his age.  But of course, one of the things that comes with age is maturity:

McInnis has refused to criticize New Jersey coach Lawrence Frank, who was apparently upset with McInnis' work ethic following knee surgery last January.

"If that was the case, I'd hold a grudge against every team I've played for," said McInnis, who has played for eight teams. "I can't think of it like that. They gave me $7 million to better my family. I can't be mad at Jersey. They made a decision last summer not to bring me back, but I'm here now. I want to focus on the Bobcats."

"When I was younger I probably wouldn't understand it, but I'm older, I know what's going on. I don't have anything personal against Jersey."

To be honest, with all the trash and rumors I had heard about McInnis and how the Nets treated him (not the classiest ways of doing business), this is a surprisingly mature response.  I hope that I can develop that same outlook on life and learn to be more optimistic and forgiving.

 Tuesday, January 16, 2007

I <3 Microsoft Hardware

1/16/2007 3:19:40 PM (Eastern Standard Time, UTC-05:00)

I know I'll probably come across like a "fanboi", but I really, really like Microsoft's keyboards and mice.  I'm currently using the Natural Ergo 4000 keyboard and it's awesome (you can read my review of it at Amazon).  It's the most comfortable "mainstream" (as in anyone can pick it up in Staples or Office Max) keyboard out there for extended typing usage.  I haven't had cramps or pain in my pinkies for months (CamelCase will do that to you...)!  Months!  And I'm in front of the computer for a good 8-10 hours a day!

Prior to this, I was rocking a Wireless Desktop Pro keyboard/mouse set (which I also reviewed at Amazon).  While quite comfortable in its own right, cannot compare to my current setup of the aforementioned 4000 and Logitech MX Revolution (along with UberOptions).

But anyways, I replaced the mouse included with the WDP set a few months back as the scroll wheel started to gum up and would not scroll or click anymore (damn cats >.<).  So I finally decided to call Microsoft today and see if I could get a replacement since the receiver and keyboard are both still fine.  Fully ready to pay for the replacement and the shipping cost, to my surprise,

  1. The service rep. that answered my phone call was American and spoke "normal" English,
  2. The service rep. was polite and friendly,
  3. The service rep. hooked it up with a replacement mouse, no questions asked (well, except for the standard ones) with no charge at all to me...no shipping, no replacement fee,
  4. The confirmation was sent to me in under an hour...

Yes indeed.  I <3 Microsoft hardware :-D (and great support to boot).

 Monday, January 15, 2007

In Memory of MLK...

1/15/2007 9:57:46 AM (Eastern Standard Time, UTC-05:00)

In celebration of this day, I think it's worth the time to listen to a recording of his historic speech.

Could the civil rights movement have had a better, more visionary, and stronger leader than MLK?  It's hard to believe so.  Let's hope that his message doesn't die and lose it's power with today's generation.

I often find myself wondering whom in our time can even be compared to the great people of years past.  Who will we remember as "great" in the decades to come?  It often seems that such people are increasingly rare these days...

I leave you with a passage from his speech which resonates with me:

But there is something that I must say to my people, who stand on the warm threshold which leads into the palace of justice: In the process of gaining our rightful place, we must not be guilty of wrongful deeds. Let us not seek to satisfy our thirst for freedom by drinking from the cup of bitterness and hatred. We must forever conduct our struggle on the high plane of dignity and discipline. We must not allow our creative protest to degenerate into physical violence. Again and again, we must rise to the majestic heights of meeting physical force with soul force.
 Sunday, January 14, 2007

Updated Site Layout

1/14/2007 2:25:06 AM (Eastern Standard Time, UTC-05:00)

I'm just too lazy to update the blogging engine :P

But at least now, the site renders correctly in FF and IE.

Now what to do about those other link items...

 Saturday, January 13, 2007

Adding Users To A Document Workspace

1/13/2007 6:49:08 PM (Eastern Standard Time, UTC-05:00)

In WSS3, the process of adding users to a document workspace (or any sub-web) has changed from WSS2.  The following snippet will allow you to add a user (I've only tested with users mapped to domain accounts) to the workspace:

using(SPSite site = new SPSite("http://ashelia:2345")) {
    using(SPWeb workspace = site.OpenWeb()) {
        string resourceLogin = "ASHELIA\\cchen";

        // Ensure that the user exists and conveniently, get
        // an SPUser reference.
        SPUser user = workspace.EnsureUser(resourceLogin);

        // Create a new SPRoleAssignment for the user.
        SPRoleAssignment assignment =
            new SPRoleAssignment(
                user.LoginName, user.LoginName,
                user.Name, user.Notes
            );

        // Add the "Contribute" role definition to the role
        // assignment.
        assignment.RoleDefinitionBindings.Add(
            workspace.RoleDefinitions["Contribute"]
        );

        // Add the assignment to the web.
        workspace.RoleAssignments.Add(assignment);

        // Update the web.
        workspace.Update();
    }
}

Note that when you create a new sub-web, by default, there are 5 role definitions defined for you already.  These are:

  1. Full Control
  2. Design
  3. Contribute
  4. Read
  5. Limited Access
 Thursday, January 11, 2007

Final Fantasy 12 - The Movie

1/11/2007 1:44:12 PM (Eastern Standard Time, UTC-05:00)

Or rather, the cut scenes (in game and pre-rendered) from the game.

If you're like me, you really don't have the time to spend plunking down in front of your TV to play 40-60 hour games anymore.  Most of my gaming time these days is spent with the DS (the greatest gaming platform of this generation?).

But I can't shake my adoration for the Final Fantasy series, even though sometimes it seems like it's been milked to death.  The game always features some of the most creative character, architectural, landscape, and creature designs.  In this respect, Final Fantasy XII does not disappoint...some of the bosses and their specials are just jaw dropping.  It blows my mind that they were able to create this world with such detail, creativity, richness, and beauty.

In any case, if you want to skip to the good stuff, then hop on over to videogamesheaven.net and check out the FFXII cutscenes.  It's worth watching through the whole thing.  I actually think it's fairly well written and the voice acting isn't terrible (Vaan is possibly the worst one but Fran, Balthier, Basch, and Penelo are all great).

On some level, the main theme relates to one of the central themes of the Blade of the Immortal series: how does one come to grips with the desire for revenge and the reality of bloodshed that such a path would entail and the cycle of hatred that is driven by such actions? 

 Tuesday, January 09, 2007

On Software "Architects"

1/9/2007 10:28:54 AM (Eastern Standard Time, UTC-05:00)

I've always had a disdain for the term "architect" in the context of software development. Possibly due to my not-so-fond experience with an "architect" during my days at Factiva.

I popped open Fred Brooks' The Mythical Man Month last night searching for a specific passage on project management, but stumbled on another passage that I had highlighted which caught my attention:

The manual, or written specification, is a necessary tool, though not a sufficient one. The manual is the external specification of the product. It describes and prescribes every detail of what the user sees. As such, it is the chief product of the architect.
The manual must not only describe everything the user does see, including all interfaces, it must also refrain from describing what the user does not see. That is the implementer's business and there his design freedom must be unconstrained. The architect must always be prepared to show an implementation for any feature he describes, but he must not attempt to dictate the implementation.

I think this is a golden rule that is often broken by software architects. The reason that it's so common to break this rule is that in most organizations and teams, the architect is not necessarily:

  1. labeled as such; instead, the term that might more commonly be used to describe such a person would be "business analyst",
  2. a distinct position/role, which means that a high level/senior (read:"been here the longest") developer assumes the role of architect,
  3. accustomed to the practice of separating usage from implementation.

On point 1, by Brooks' definition, an architect is not necessarily a developer, but an individual more aligned with the business side of the client/company with perhaps some technical background or maybe even a trusted technical advisor. The architect must be able to interface with business users and extract the information required to create the right product.  Such incorrect labeling of the position often leads to conflict.  When Confucius was asked what his first measure would be as a minister in the court of Wei, he commented:

It will certainly concern the rectification of names.  If names are not rectified, then language will not be in accord with truth.  If language is not in accord with truth, then things cannot be accomplished.  If things cannot be accomplished, then ceremonies and music will not flourish.

-- Confucius (Chan, A Source Book in Chinese Philosophy, p.40)

The role of architect and developer should be distinct and well defined.  This is not to say that the architect shouldn't have a development background.  Quite the opposite is true; the architect should know the technologies and know the tools, but should refrain from telling others how to implement a feature.  By Brooks' definition, the architect should only tell others what to implement.

On point 2 and 3, in most cases, companies do not always specifically allocate the role of "architect" without also making sure that said individual does not lead the direction of development. In smaller organizations, it's perhaps not an option to create such a distinct role. In these cases, the architect-developer must be able to separate the responsibilities of the duties of both roles.  The problem that arises when this happens is that the developer-cum-architect needs to have the discipline to switch contexts between architect mode and developer mode.  The individual must not think of interfaces in terms of code, but in purely terms of use cases.  This is a difficult task as when I'm presented with a proposed interface (be it visual or programmatic), my natural reaction is to wonder "how will I implement this feature?", "what libraries can I use?", and other such thoughts instead of focusing on dissecting the features of the interface from a use case perspective.

In any case, the architect can still guide the development process by continually updating the specs, conveying user feedback, and offering implementation advice when requested, but the architect must not dictate the details of the woodwork. Doing so always inevitably causes friction between those that create the code and those that create the specification. For, as Brooks says, the act of software engineering is, ultimately, a creative process for the programmer and by restricting this aspect, only begrudging compliance can be achieved.

 Monday, January 08, 2007

ContentTypeIds In WSS3

1/8/2007 4:50:43 PM (Eastern Standard Time, UTC-05:00)

In WSS3, if you execute the following SQL:

    SELECT
        ContentTypeId
    FROM 
        ContentTypes

You will notice that the content types are represented in the output as hex.  If you take a look at the table definition, you'll see that the actual data type of the column is VARBINARY(512).

Doing a lookup like so:

    SELECT
        ContentTypeId
    FROM 
        ContentTypes
    WHERE 
        ContentTypeId = '0x101'

Will not work since you cannot perform a comparison between VARBINARY and a character data type directly.

Doing the following will also not work:

    SELECT
        ContentTypeId
    FROM 
        ContentTypes
    WHERE 
        CAST(ContentTypeId AS VARCHAR(512)) = '0x101'

This doesn't work because the underlying type of the binary data isn't character data.  It's integer data.  You can confirm this by running the following query:

    SELECT
        ContentTypeId,
        CAST(ContentTypeId AS VARCHAR(512))
    FROM 
        ContentTypes

You'll see that it's just a bunch of gibberish.  Try the same query with INT and you'll see that the data makes much more sense.  What you'll notice is that content types that inherit from a base content type will have numerical values that increment by 1.

This information is useful, but not nearly as useful as the data that you can glean from the hex string representation of the ContentTypeId.  You see, in the hex string representation, the base ID is a substring of the ID of any inheriting content type.  For example, if I have a content type which has a ID (as a hex string) of 0x0101345346345312234346, then any child content types will have 0x0101345346345312234346 as a substring (e.g. 0x010134534634531223434601, 0x010134534634531223434602).

So how do we get this data in SQL Server for comparison purposes?  We need to use an "undocumented" SQL function: fn_varbintohexstr().

This allows you to do nifty queries to find a given content type and all child content types (or any query where you have to retrieve information about a hierarchy of content types) like so:

    SELECT
        *
    FROM 
        ContentTypes
    WHERE 
        master.dbo.fn_varbintohexstr(ContentTypeId) LIKE 
            '0x0101345346345312234346%'

You can find out more information on this function here.

 Sunday, January 07, 2007

A Note On Copying Files In WSS3

1/7/2007 2:52:33 PM (Eastern Standard Time, UTC-05:00)

I dunno if this was supported in WSS2 or not, but in WSS3, when a file is copied to a new destination, a link is stored which indicates where the new document is copied from.

In the database, you can see this by running the query:

SELECT
    tp_dirname,
    tp_leafname,
    tp_copysource,
    tp_hascopydestinations,
    tp_guid,
    *
FROM ALLUSERDATA

The tp_CopySource column holds the URL of the source document from which the given file is copied from.  If you simply change the URL here, you can point it to any file you want.  If the file is a copy, then the following information bar will be displayed on top of the file properties in the properties page:

copy-indicator.jpg

However, it's not so obvious how to do this programmtically.  First, I tried using the CopyTo() method of SPFile.  Aside from not having the desired effect, this method does not seem to allow copying files across site boundaries (for example, from a root site to a document workspace -- for that, you have to use the Add() method on the Files property of the target SPWeb).

On my second attempt, I tried to set the "Copy Source" property of the file.

foreach (object key in file.Properties.Keys) {
    Console.Out.WriteLine("{0} : {1}", key, file.Properties[key]);
}

Iterating through the properties of an SPFile instance, I found that one of the properties, was "Copy Source" (internal name of "_CopySource") and in fact, held the URL of the source document.  I tried to set this value and update the file, but this was unsuccessful yet again.

On my third attempt, I came across the CopyTo() method on the SPListItem class and this did it for me :-) Conveniently, it also allows you to copy an item across site boundaries.

I felt so stupid afterwards because it should have been obvious that I had to use the CopyTo() method on the SPItem because the SPItem is also where the UnlinkFromCopySource() method is located.

RSS 2.0 Atom 1.0 CDF