Monday, July 14, 2008
Monday, July 14, 2008 2:16:15 AM (SE Asia Standard Time, UTC+07:00) (Utilities)

Well - I admit it - apart from some installation batch files I wrote when I was a junior helpdesk guy a long time ago - I'm a bit of a late bloomer to the command line.

cmdI've got some time off over the summer before heading back to school in October - and so I've been working through a backlog of to-do items and small projects; the most important of which was finally getting up-to-speed with automated builds, testing and deployment using NAnt, MSBuild and the very cool WiX - which of course leads to the command line and editing build and batch files.

I know Notepad2 and Notepad++ are popular replacements for notepad in the hacking community - but I've become rather attached to EditPadPro - so that will do for now. I've renamed the .exe to ep.exe - and added the path to EditPadPro to my system wide path environment setting.

I also love this post from Scott - Prompt(s) along with PushD and PopD and the very cool prompt tip...

$P$_$+$G Which, when I set it via either the prompt command or the PROMPT environment variable, gives me a command line that looks like this:
C:\data\Projects\flexwiki\FlexWikiCore
++>

TAB AutoCompletion is hot too - and I honestly didn't know it was there. :-(

Last on my list of productivity improvements is a replacement for Windows Vista Explorer - and I'll be trying both Total Commander and [xplorer²] - because Windows Vista Explorer is driving me nuts.

Back to the command line and build scripts... :-)



| Comments [0] | | #  
Sunday, July 06, 2008
Sunday, July 06, 2008 11:56:46 AM (SE Asia Standard Time, UTC+07:00) (Hardware | Other Tech)

Update: In Search of The World's Best Computer Keyboard Part II

For a couple of years now - on and off, I've been trying to find the perfect small form factor mini size keyboard. Like David Bau in his own quest to find the World's Best Computer Keyboard, I came to the conclusion that I really don't want a full length, full size, 101 to 104 key keyboard on my desk. I rarely use the number pad, and when I do -  I don't mind it being separate.

My old keyboards I want my posture to be straight when I'm using my computer - from my back, to my shoulders, to my arms, wrists and hands. I found that when I was using a full size keyboard with a built-in number pad on the right, that the extra length on the right side of the keyboard was causing me to reach just a few inches further than I wanted to in order to use my mouse; just enough to change my posture - and enough for me to feel it in my shoulders and wrist when using my mouse.

So that started the search... and man did I search. I tried a bunch - including an expensive Cherry POS keyboard as well as the ThinkPad Travel UltraNav, but they were all far from perfect. The UltraNav in particular was a disappointment (it's up there in my little keyboard mountain) since it was nothing like the real ThinkPad keyboard in my notebook; the quality, key action and feel was very different.

I don't understand why PC users have such a poor choice in desktop keyboards. If you took the average manufacturer's PC desktop keyboard and tried to put it into a notebook, the notebook wouldn't sell. In fact it was while using my notebook that I realized my posture was better. Not only that but the keyboard in my notebook was so much better than my desktop - it was the famous IBM ThinkPad keyboard - the benchmark in notebook keyboards.

For a while I was using a Deck Legend - and I loved the key backlighting, but this was before my quest for a smaller keyboard. I actually contacted TG3 - the manufacturer of the Deck Legend, hoping that they might be about to update one of their current small form factor models, or possibly modify a BL82 for me into the standard Windows keyboard layout. I was prepared to pay. My keyboard is a tool I use for work, just like a tool any other professional would use in their job.

HP8150W    The first thing you'll discover when you start looking for small form factor keyboards is that there's a variety of different keyboard layouts. That was the first big stumbling block. I'm a CTRL-S freak. I hit CTRL-S for nearly every line I write, code or otherwise - so having the CTRL key in the usual position - bottom left - is important (although I confess I've 'adapted' when using my ThinkPad, which has a function key in the bottom left position - but that's my only complaint with the ThinkPad). The standard CTRL-Windows-ALT arrangement bottom left would be great, followed by, from the top right, down the right side - DELETE, HOME, PG-UP, PG-DN, END, and then the arrow keys. This is the layout used by most notebook manufacturers these days and it would be good to have a matching desktop and notebook keyboard. The HP 8150W (shown) has a good keyboard - although I whish they'd put the Function key to the right of the spacebar.

The other thing you'll discover when looking for a keyboard of any size - is that most of the models advertised online don't have a good quality larger version picture of the keyboard. It was pretty hard to figure out how the keys (especially top row keys) were arranged before shortlisting a keyboard for purchase.

I've also looked at the growing number of media keyboards that are slowly coming onto the market. The growth in home media centers means that more people are now actually looking for smaller (and wireless) keyboards - but again - quality, keyboard layout and in particular function keys vary a lot. I've looked at the Logitech diNovo Edge - which is just a fraction wide, and the key action wasn't quite what I was looking for - but it was close. Also the Microsoft Wireless Entertainment Desktop 8000 - another close call - but again, a little wide and poor function key support since the function keys are in a flat membrane key strip across the top.

Slimblade Media Set My current keyboard (and mouse) is the Kensington Slimblade Media Notebook Set. So very very close. The layout is almost perfect. I wish the function keys were full-size - but they work. Key action is superb and the closest so far I've come to feeling like I'm on a ThinkPad. The right side key arrangement is a little odd - with END at the top-right - followed by PG-UP, PG-DN, INSERT, DELETE and then the arrow keys. It's taken me a little while to get used to the DELETE key in this position. Still - this is the closest I've come to finding the perfect small form factor keyboard. Kensington have always made good quality accessories. Want to know why? Well I think it's because they make accessories for the Macintosh as well. And Mac users, having become accustomed to brilliant design and ergonomics, wouldn't tolerate a low quality accessory (in fact I popped into a local i-Studio Mac shop recently and saw a brushed aluminum small form factor keyboard that was just lovely).

So what would my dream small form factor keyboard look like? It would be matt-black brushed aluminum, use the keyboard layout shown in the HP8150W keyboard above - but with full size function keys. It would have illuminated keyboard characters (blue back-lit LEDs) and would totally rock in terms of quality and keyboard action. Until then... my Slimblade will do nicely. I may even give the IBM SpaceSaver II a try (as mentioned in David Bau's article) if I can find one.

While searching - I came across these two very expensive honorable mentions...

The Optimus Maximums from Art.Lebedev Studio. This is an incredible keyboard - would love to put my hands on one, and if they ever make a smaller version with a separate number pad - I'll buy it.

And then there's Datamancer - not sure whether to be scared, or in love with this stuff. Maybe when I'm wealthy, one day - I'll ask this guy to make me a keyboard (the equivalent of American Chopper for geeks - so cool).



| Comments [2] | | #  
Friday, July 04, 2008
Friday, July 04, 2008 1:05:17 AM (SE Asia Standard Time, UTC+07:00) (C# | Utilities)

Thanks to Alexander Groß for pointing me to syntaxhighlighter.  I still think Leo Vildosola's Code Snippet plugin and highlighter for Windows Live Writer is amazing. They're both good choices - but I thought I'd give syntaxhighlighter a try. It produces less markup than Leo's plugin, although it is dependant on a JavaScript lib on the site for the actual highlighting.

PreCodePlugin_Full_2.0.2 The only challenge in using syntaxhighlighter- is that unlike Leo's all-in-one solution - you need to work out a way to format and encode your snippets first, placing them in either a <pre> or <textarea> element. There are a couple of plugins out there that do this - but I wasn't thrilled with the results, and I've wanted to take a quick look at the WLW plugin API for a while now. Seems like everyone is having a go at this - including Rick Strahl.  So here is my attempt - a code snippet plugin for Windows Live Writer...

Scott also directed me to the Past As plugin on Codeplex - which I'll be trying out as well.

The result - using my plugin - and syntaxhighlighter on the site...

 

public override void CleanUp()
{
    //Remve the Async event listener
    AsyncTaskManager.ItemProcessComplete -= AsyncTaskManager_PreviewItemProcessed;
    this.Logger = null;
}
:-)


| Comments [0] | | #  
Tuesday, July 01, 2008
Tuesday, July 01, 2008 2:27:13 AM (SE Asia Standard Time, UTC+07:00) (C#)

Using an enumeration to display a list of values in the user interface (UI) has obvious limitations. You'll be limited to the rules of enumeration values - no spaces, multi-words etc. You won't be able to offer localized versions of the strings used to describe each enumeration value. And you'll have to hard code and parse all possible values in order to present a list of values in a UI element.

Here's an article on five great patterns that can be used to create "look-up" or "reference" types (reference type in this case meaning a data structure that is used to represent a list of possible values that another type will depend on - like High, Medium, Low, or Fast and Slow).

Below is the code I used recently to create a type based on the descriptor pattern; a  reference type that will be used to assign a JobStatus to a Job class. What I like about this approach, is that with correct == and != operator overloads - it's a 1:1 swap with an existing enumeration type - so no code changes are required where an enumeration type may have been used initially.

The weakness of this pattern is that like enumerations - the class has to be coded - and so if the list of values changes the code will need to change too. That said, for small to medium size lists of "look-up" values (combined with a little code generation) this is a great way to offer type safe values as well as a UI and culture friendly list.

The ToString() override and the IList<JobStatius> GetValues() method make this type databinding friendly too.

public sealed class JobStatus
{
    //Private constructor - only our static properties are allowed to create instances
    private JobStatus(int value, string name)
    {
        _value = value;
        _name = String.Copy(name);
    }
    
    //Readonly Value property
    private int _value;
    public int Value { get { return _value; } }

    //Readonly Name property
    private string _name;
    public string Name { get { return _name; }}

    private static JobStatus _waiting = new JobStatus(1, "Waiting");
    public static JobStatus Waiting
    {
        get { return _waiting; }
    }

    private static JobStatus _notRun = new JobStatus(2, "Not Run");
    public static JobStatus NotRun
    {
        get { return _notRun; }
    }

    private static JobStatus _active = new JobStatus(3, "Active");
    public static JobStatus Active
    {
        get { return _active; }
    }

    private static JobStatus _completed = new JobStatus(4, "Completed");
    public static JobStatus Completed
    {
        get { return _completed; }
    }

    private static JobStatus _cancelled = new JobStatus(5, "Cancelled");
    public static JobStatus Cancelled
    {
        get { return _cancelled; }
    }

    private static JobStatus _failed = new JobStatus(6, "Failed");
    public static JobStatus Failed
    {
        get { return _failed; }
    }

    public override string ToString()
    {
        return _name;
    }
    
    public override int GetHashCode()
    {
        return _value.GetHashCode();
    }

    public override bool Equals(object obj)
    {
        if (obj == null)
            return false;

        if (GetType() != obj.GetType())
            return false;

        JobStatus status = (JobStatus)obj;

        if (_value != status.Value)
            return false;

        return _value == status.Value;
    }     

    public static bool operator ==(JobStatus status1, JobStatus status2)
    {
        return Object.Equals(status1, status2);
    }

    public static bool operator !=(JobStatus status1, JobStatus status2)
    {
        return !Object.Equals(status1, status2);
    }

    public static IList<JobStatus> GetValues()
    {
        List<JobStatus> values = new List<JobStatus>();

        foreach (PropertyInfo pi in typeof(JobStatus).GetProperties())
        {
            if (pi.PropertyType.Name.Equals("JobStatus", StringComparison.Ordinal))
            {
                values.Add((JobStatus)pi.GetValue(null, null));
            }
        }

        return values;
    }
}


| Comments [0] | | #  
Friday, June 27, 2008
Friday, June 27, 2008 10:42:20 AM (SE Asia Standard Time, UTC+07:00) (Other Tech)

During my recent trip to Hong Kong - I popped into a mobile device shop and took a quick look at the HTC Touch Diamond. touchdiamond The phone looks pretty good - and I was impressed (and I'd really really like to see something that can just about compete with the Apple iPhone). However for me at least, there has been a missing feature in the Windows Mobile dialer from the early versions to the present.

I travel a lot - and in many of the places I travel, there are special calling codes you can use to get a discount on your outbound international calls. So for example - instead of using an international calling code like; 
+1 212 1111 1111 (notice the +1 for North America, 212 for New York) - you swap the + sign for the discount calling code. From here in Thailand - if I use 009 1 212 1111 1111 with the 009 prefix - I get a whopping 30% discount with no strings attached. I seem to remember similar schemes in the states using Sprint and AT&T calling codes as well.

Here's the problem. On every Nokia mobile phone I've ever owned, there has always been an option to 'Use Number'. Which means that when you've looked up the contact you want to call - instead of dialing - you choose 'use number' and it loads the number into the dialer, where you can then make ad-hoc changes to the number before you dial. As far as I can tell, and after experimenting with the Touch Diamond, this feature still doesn't exist in the Windows Mobile dialer. There is no way to load the number into the dialer, and then edit the number before you dial. It would be time consuming to edit the contact first - add the calling code prefix, save the contact and then dial - only to have to change the contact details again the next time I want to use a different discount calling code, or revert to the standard international dialing prefix. There may be more than one discount code I'd like to choose from as well - so this isn't a global setting - what I really need is a way to edit the number before I dial without having to change the contact details.

Windows Mobile if you're out there - I want to love you, I want to use you - but I just can't until this is fixed.



| Comments [6] | | #  
Wednesday, June 25, 2008
Wednesday, June 25, 2008 5:56:33 PM (SE Asia Standard Time, UTC+07:00) (Enterprise)

I learn something new nearly every time I write code - whether in a small project or large.

I recently updated my online gallery component at http://www.58bits.com/otherblog/photos/home.aspx. One of my TODO: items was a rewrite of a VCR style pager I've used previously. What I wanted was a style like the one shown in the screen shot...pager similar to that used on many sites. I also wanted user friendly(ish), hackable URLs, with each URL truly representing a resource; resources that may have more than one representation. For example, what you see visually as a user visiting the site - is a page with either thumbnails or a preview on it. However if you're an RSS reader, or a slide-show plug-in, you'll be given an RSS/XML representation of the same resource.

So what did I inadvertently create by moving to the new pager style? A  RESTFul pager. By asking for pages using the HTTP GET verb (as opposed to my old VCR pager that relied on forms and POST - ok a bad move I know) - I now have URLs that look like this...

http://www.58bits.com/otherblog/photos/5cgg96ab3e6g/thumbnails/2/2x3/view.aspx

And I now have a good separation from the server implementation, and the client's perception of a resource via a cool URL, and one that won't change.

As an aside, I can also now do something intelligent with caching, telling the client whether the resource has been updated or not via ETags, last modified dates and HTTP 304 response codes, saving a ton of bandwidth while at the same time ensure that changes propagate.

I'm a newbie to REST as an architectural style and am currently reading a lot on the topic - but what I've found from my initial exploration is that if you've been programming the Web for a little while, you've been close to REST by default. Embracing the style to include other verbs (other than the ubiquitous GET) is not such a big step, and I'm looking forward to experimenting further.

Here's a link to an author that's produced a great presentation on RESTFul Web Services



| Comments [0] | | #  
Monday, June 23, 2008
Monday, June 23, 2008 3:58:33 PM (SE Asia Standard Time, UTC+07:00) (General)

Hong Kong airport is now officially my favorite airport in the world. The Airport Express train in and out of town is a breeze. The food court in departures is large and comfortable.

And best of all free airport-wide WiFi that really works. Bangkok and London could to take a page from HK's book of good service. With an airport like this - going to the airport is fun - you can shop, get some work done, relax and then be on your way.

Just me and my ThinkPad T61p after a great weekend in Hong Kong.

IMG_2135



| Comments [0] | | #  
Thursday, June 19, 2008
Thursday, June 19, 2008 6:38:50 AM (SE Asia Standard Time, UTC+07:00) ()

UPDATE: Sun Tests Social Networking Toolkit

If I could design the future of social networking it would look like this...

I'd have a platform... some kind of service or software platform, from within which I could blog, twitter, chat and link to the people I know. I'd be able to choose exactly what information I wished to publish and when, and whether that information was published to just my friends, or to the world.

I'd be able to host the platform anywhere I choose. I could pay for it, or it might be free. If I paid for it - I'd want total control over where and how any advertising was allowed from within or outside the platform.

Imagine taking the best of LinkedIn, a decent blogging engine, something twitterish, a good chat client, a good media sharing platform for photos and videos. Add a pinch of social bookmarking - and wrapping all of that up into a very cool platform that I can use to represent me and those I choose to interact with in the online world. A sort of Bittorrent-ish, Groove-ish application for society. Goodbye MSN Messenger, Yahoo Messenger and Skype, goodbye to all of the walled garden social networking sites - and hello to my own little neighborhood in cyberspace.

The end of walled gardens like Facebook and other social networking sites is actively being discussed. What's missing is the glue in standards and software to bring together an alternative. The big guys like Google, Microsoft, and Yahoo want to try and grab on to this and hold on to it for its obvious potential in targeted marketing and advertising revenue.

I hope that doesn't happen. I hope we're each able to grab on to it, to control it and to use it to build new communities and socially meaningful ways of communicating with the world.



| Comments [0] | | #  
Saturday, June 14, 2008
Saturday, June 14, 2008 9:16:05 PM (SE Asia Standard Time, UTC+07:00) (C# | Utilities)

I know Jeff Atwood is a fan of this, and I'm surprised it's not made it on to Scott Hanselman's 2007 Ultimate Developer and Power Users Tool List for Windows tools list yet.

RegexBuddy is a brilliant tool and a great way to learn regular expressions. The documentation and introduction to regex is worth the price of admission alone.

regexbuddy
  (click to enlarge)

The expression tree view in the lower window practically talks to you as you build up and test your expressions. The expression to the right will match any incoming Url to myabsolutepath/subdir that begins and ends with either:

myabsolutepath/subdir
myabsolutepath/subdir/

or

myabsolutepath/subdir/*.aspx
myabsolutepath/subdir/*.ashx

I love this application.



| Comments [0] | | #  
Saturday, June 14, 2008 8:58:47 PM (SE Asia Standard Time, UTC+07:00) (Other Tech)

I like Windows Vista - it's a cool and stable OS. But it's taken me a while to get it to boot fast, and stop thrashing my disks to death. Windows Search, automatically scheduled items like Disk Defragmenter and Windows Defender and the biggest culprit - Superfetch, all put a heavy load on boot time and run time disk activity.

I tend to keep things pretty well organised and never really needed a desktop search engine and so I disabled Windows Search (the search feature on the start menu will still find program menu items - which is incredibly useful). I don't mind waiting a second or two for an app to load either and usually leave my frequently used apps running anyway - and so don't really want SuperFetch creating the 300,000 plus I/O events it records at system startup (watch it using Process Monitor from SysInternals). I also keep all my data on a separate volume from the OS - and so will manual defrag the OS disk once every couple of months. And I use the Complete PC Back up feature of Vista Busines/Ultimate to image the OS volume - giving me my own restore points - so I turn off restore points as well (Acronis True Image would be another good choice).

Here's a great article that just about covers it all on how to tune-down your Vista setup so that boot times and disk activity return to normal - Beginners Guides: Stopping Vista From Thrashing Hard Disks to Death.

Lone blogger 1 - Windows Vista 0



| Comments [0] | | #