Random Thoughts of a Scatterbrain.
 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.

 Thursday, January 04, 2007

More on Dean Karnazes

1/4/2007 9:21:29 PM (Eastern Standard Time, UTC-05:00)

I mentioned a short article on Dean Karnazes in the current (January, 2007) issue of Outside magazine in my previous post.

There's a great passage that I really liked:

I think Western culture has things backwards.  We equate comfot with happiness, and now we're so comfortable we're miserable.  There's no struggle in our life, no sense of adventure.  I've found that I'm never more alive than when I'm pushing and I'm in pain and I'm struggling for high achievement.  In that struggle, I think there's a magic.

Unless you're pushing yourself, you're not living to the fullest.  You can't be afraid to fail, but unless you fail, you haven't pushed hard enough.  If you look at successful people and happy people, they fail a lot, because they're constantly trying to go further and expand.

It's a good mindset to keep in mind as you start out your new year and try to stick to your resolutions :-)

 Wednesday, January 03, 2007

I Want To Dunk.

1/3/2007 11:16:33 AM (Eastern Standard Time, UTC-05:00)

I have no idea why, but I woke up this morning and I thought to myself "I want to dunk" :P

First, a little background: I've been playing basketball on and off during the last 10 years, some times really intensely (like in high school, when I played 2-3 hours every day) and sometimes less (like nowadays, when I only have time to play an hour or two at the gym).  During my high school days, I could actually dunk a ball on the rim (it's true, I actually did it once).  (But alas, cursed with average sized hands for a 5'10" guy, I could never palm the ball with a strong enough grip with one hand for a dunk.)  Yes, at one time, I could actually jump vertically (no running start) and grab onto the rim.

Over the years, as I've become more sedentary, as most programmers are inclined to, I've lost much of that leaping ability (although my calves still look fantastic (no, really :-D)) even with regular weightlifting and workouts.

For the past three months, I've been battling various issues that have hampered my usual workouts: a sprained ankle in Sept./Oct., my intensely dry skin which basically precludes me from playing basketball at all, and my fractured finger (which is just now healing to the point where I can close my fist).  Not to mention that I packed on 6 pounds (mostly -- okay, all -- fat) due to inactivity and holiday feasting.

But I figure now is as good a time as any to work on this goal and get back to my regular regiment.

By way of Google, I stumbled upon an article by Josh McHugh of Outside (which, by the way, recently had an excellent mini article on Dean Karnazes -- so good that someone actually ripped the page out of the Outside magazine at the gym) and Wired magazine fame.  I think I'm gonna try for it.  There's quite a bit of investment involved in some equipment (enough to get myself a Treo 700wx!), but I think it'll be worth it even if I can't dunk, at least so that I can swat some more shots at my gym pickup games :P (man I sound like such an old fart).

JumpUSA has most of the products including:

I'm having a hard time deciding between the weight vest and the belt.  The vest seems like it's more natural and easier to deal with (less motion on the body when running/jumping) but seems like it'd collect more sweat and also add more weight above the waist, which could strain my lower back.

So it'll be interesting to see how far I can take it.  I'll keep my progress posted.

RSS 2.0 Atom 1.0 CDF