Friday, August 29, 2008
Friday, August 29, 2008 11:01:03 PM (SE Asia Standard Time, UTC+07:00) (Utilities)

barcamp_imageWell - on the off chance that I get enough votes at BarCamp in the morning... here's my presentation for BarCamp Bangkok 2.

A while back - and thanks mainly to an open source project created by Alexander Groß (a Now Playing Plugin for Windows Live Writer) I discovered the Windows Installer XML (WiX) project.  WiX is pretty cool. It's an XML script based compiler and linker that creates .MSI install packages. Because it's script and command-line driven - it fits well into automated build and deployment systems (using build tools like NAnt or MSBuild).

I've generally kept all my utility and helper classes in a separate solution, separated into namespaces for Strings, Data, Web, Math, Image helpers etc... all static classes (slowly being updated with extension method versions as well).

So for my demo at BarCamp - I've created a SampleUtils solution - with NAnt and WiX and a fairly well organized solution that shows how this can all be put together.

The solution layout looks like this... solution(screen shot to the right).

Again - if I get the chance. I'll do a quick run through of the NAnt build file (I've annotated the targets). And then a quick look at the WiX scripts. Demo the build process and then deploy the library using the installer - followed by a Console app that uses the library to make a few calls... (at least that's the plan).

Here are links to the source package for the demo (all lib and tools included so it will build as soon as you run build-release.bat) as well as the slide deck.

UtilitiesSolution.zip (5.43MB)
BarCamp2_SlideDeck.zip (61KB).

And here are the links at the end of the slide deck...

http://nant.sourceforge.net/
http://wix.sourceforge.net/index.html
http://msdn.microsoft.com/en-us/library/aa367449(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa368047(VS.85).aspx
http://confluence.public.thoughtworks.org/display/CCNET/Welcome+to+CruiseControl.NET
http://en.wikipedia.org/wiki/Daily_build

Wish me luck... :-)

 



| Comments [2] | | #  
Tuesday, August 26, 2008
Tuesday, August 26, 2008 12:27:42 PM (SE Asia Standard Time, UTC+07:00) (Utilities)

I spotted this post on Scott Watermasysk's site the other day. I've been looking for something like PureText for ages.

I almost never want to take the source formatting of text I copy from documents, or the web and almost always want the pasted text to assume the format of the target document. In Office - with some complicated maneuvering you can use Paste Special... and choose unformatted text - but it's a real hassle and gets in the way of quick document assembly.

I smile now every time I hear the PureText sound as I happily past plain text into whatever I'm working on, from wherever I've copied. :-) Nice one Steve Miller and thanks a bunch...



| Comments [0] | | #  
Monday, August 18, 2008
Monday, August 18, 2008 9:16:17 AM (SE Asia Standard Time, UTC+07:00) (SQL Server | Utilities)

A recent tweet led me to an Alt.Net Canada video - which was discussing the build process, build skill-sets and the complexity of maintaining a large build scripts. In the middle of the video - a guy with a ThoughtWorks t-shirt on mentioned a toolset that amongst other things, helps with database change management (from development, to testing, to release). The project is called Tarantino Database change management and it looks really good. I LOVE the solution statement... 

  • Each developer using their own local database to do their development work.
  • Each environment using it's own database. i.e. Development, Testing, Staging, Production
  • Each developer maintains his changes locally. When the database changes are ready to commit along side the application source code, the developer follows these steps:
    • Create a change script that wraps all of the database changes into a single transactional change script. A Tool like Red Gate SQL Compare makes this a 30 second operation.
    • Save the change script in to a folder in your source tree call Update.
    • Commit the change script along with the source code that corresponds to the change.
  • The continuous integration server detects changes to the source control repository than it:
    • It builds the application code.
    • It executes the applications unit tests.
    • Executes the database create task to create a new database with all of the changes that are in source control.
    • Executes the projects integration (data access) tests.
    • Marks the builds a success when all the tests pass.
  • Each developer runs the build script locally after receiving new schema changes scripts from the source code repository.
  • The testers, developers, change management managers execute the script using the Database Update (windows form) tool to run the database scripts against the Dev, Test, and staging environments when the environments receive their next update of the source code. 

About 7 years ago - (and still to this day), one of the most useful on-the-spot mentoring exercises I've ever had, was in database change management. A co-worker showed me the process they'd come up with at their previous employer for giving each developer a local database to develop against, using local work files to maintain their changes (SQL scripts) and then a consolidated SQL release script for combining individual changes, all numbered and versioned against the DB which was matched (and backed-up) against the release version of the application (and all under source control).

I've worked this way every since and I've always been able to track schema changes against releases. That said - not too long ago I was in an office where I was actually accused of 'working dangerously' because I refused to use the 'shared' dev database that all the other devs were using. Ok - so if NOT breaking other developers' build environments, and being able to track and even rollback on schema changes  is a dangerous practice - then feel free to call me Danger Man.

Looking forward to taking a closer look at the Tarantino bits...



| Comments [0] | | #  
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] | | #  
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] | | #  
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] | | #  
Tuesday, May 27, 2008
Tuesday, May 27, 2008 2:31:26 PM (SE Asia Standard Time, UTC+07:00) (ASP.Net | Utilities)

Wow - Google and searchers were all over the "URI templates and hackable search engine friendly URLs" line in my short WPF post below, which means there's a lot of interest in URI templates.

I found this post on Creating a Template based URI very helpful. You DON'T have to be building a WCF service to use these. You MUST however include a reference to the System.ServiceModel.Web assembly in your project before you can use the System.UriTemplate type.

Scott Hanselman's presentation at MIX08 on MVC was also very helpful as well as it clarified many things (not to mention being hugely entertaining).

The URI Templates of .Net 3.5 don't have anything to do with REST - they're just a utility class that helps to bind and match templates and parameters to and from URIs. When combined with a URL rewriter they make it easy to present hackable URLs the world.  As Scott said in his presentation - the URLs in a browser window are effectively part of the UI - and so should be treated accordingly when possible.

So... mystore.com/clothing/shirts would be cool, as opposed to mystore.com/products.aspx?type=clothing&category=shirts



| Comments [0] | | #  
Saturday, May 24, 2008
Saturday, May 24, 2008 6:33:26 PM (SE Asia Standard Time, UTC+07:00) (Utilities)
While sprucing up my blog - I started looking for a code snippet plugin for Windows Live Writer - and Leo Vildosola's Code Snippet Plugin for WLW still appears to be a good choice. Like a lot of developers I use a 'dark theme' for Visual Studio and so I'm not sure that using the copy as HTML plugin from Colin Coller would work.
 

Here's an example of the WLW Code Snippet Plugin in action...

   1: /// <summary>
   2: /// Hash utility - pass the hash algorithm name as a string i.e. SHA256, SHA1, MD5 etc.
   3: /// </summary>
   4: /// <param name="input"></param>
   5: /// <param name="algorithm"></param>
   6: /// /// <param name="upperCase"></param>
   7: /// <returns>Hashed String</returns>
   8: public static string HashIt(string input, string algorithm, bool upperCase)
   9: {
  10:  
  11:     if (string.IsNullOrEmpty(input))
  12:         throw new ArgumentNullException("input");
  13:     
  14:     if(string.IsNullOrEmpty(algorithm))
  15:         throw new ArgumentNullException("algorithm");                        
  16:     
  17:     byte[] result = ((HashAlgorithm)CryptoConfig.CreateFromName(algorithm)).ComputeHash(Encoding.UTF8.GetBytes(input));
  18:  
  19:     StringBuilder myHexHash = new StringBuilder(64); //Maximum length required for SHA2-256, SHA1 or MD5
  20:  
  21:     string formatter = string.Empty;
  22:  
  23:     if (upperCase)
  24:         formatter = "{0:X2}";
  25:     else
  26:         formatter = "{0:x2}";
  27:  
  28:     for (int i = 0; i < result.Length; i++)
  29:     {
  30:         myHexHash.AppendFormat(formatter, result[i]);
  31:     }
  32:  
  33:     return myHexHash.ToString();
  34: }


| Comments [0] | | #  
Sunday, April 29, 2007
Sunday, April 29, 2007 4:38:34 PM (SE Asia Standard Time, UTC+07:00) (Utilities)

For a while now I've been backing up my important data to a removable 80GB USB drive (two actually - one for on-site storage and one for off-site).  I've been using a utility called SmartSync Pro which I've routinely recommended to friends who want to back up their files to a removable drive.

I finally got round to creating some proper batch files today using Robocopy to perform my backups. Robocopy copy ships with Vista and it's a cool file copy utility. For maintaining an in-sync external drive it's great because by default it will only copy files that have timestamp or filesize changes - so that covers new or updated files. It also has a purge option (/PURGE) that when combined with the empty directory option (/E) will remove any orphaned files from the external drive (both of these options can be combined with the /MIR switch which mirrors the destination drive).

I also needed to stop SQL Server and related services so that database files would be backed up as well  - NET STOP <service_name> for each service is included in the batch file along with a NET START <service_name> after the backup has completed.

The last batch file I created simply clones my regular backup drive to a second removable drive for off-site storage.

Several of the comments and variable declarations in the attached batch files were created by another author (the log file format setting in particular) - a sample I found on the net, and for the life of me I can't find the link back to the original files to give credit to (apologies in advance if you happen to come across this post).

I still use the Vista System Backup - creating a Windows Complete Backup - to backup my OS as an image - but I find Robocopy much more flexible (and fast) for backing up data that will be available on removable media - especially when combined with an on and off-site media strategy.

BatchFiles.zip



| Comments [0] | | #  
Monday, January 15, 2007
Monday, January 15, 2007 2:45:11 PM (SE Asia Standard Time, UTC+07:00) (Utilities)

I’ve been a loyal follower of Norton Ghost for many years. I’ve used it regularly in the past to copy, clone, and restore drive images. I’ve always used a dedicated drive image tool to create my own system restore points. The last DOS version of Ghost running from my boot CD with USB support to store the image was the zenith of Ghost usage for me I think. Feature bloat and a really terrible recovery CD in the latest version forced me to begin a search for an alternative.

Powerquest’s Drive Image Pro is long gone thanks to their acquisition however - happily I found exactly what I was looking for at Acronis True Image. Thank you Acronis. What an excellent piece of software. For starters the imaging tool is cool – well designed, easy to use and FAST. I can do a full image of my OS disk in about 15 minutes (a 14GB image file from 28GB of data). But the really amazing part is their recover CD. It takes only a couple of minutes to prepare, boots VERY fast, and runs True Image nicely – allowing me to browse for the backup image wherever it’s located, on another disk, or on my USB drive. The Ghost recovery CD takes nearly 10 minutes to boot – using a PE version of Windows (I think). The simplicity of True Image combined with their excellent recovery CD was the killer blow to Ghost, and I’m now an Acronis True Image convert.

For interest – I use True Image to create recovery images of my OS partition (my C: drive) and another very cool tool called SmartSync Pro to sync my data volume (my D: drive) with an external USB drive. I run backups (syncs) to the USB drive every day and also keep a fortnightly drive on rotation, locked in a safe at a friends office for off-site storage. The Robocopy console app is also a good way to kick-start the backup of a data volume and can also be used to mirror or sync data – but I liked the UI in SmartSync Pro enough to pay the asking 35.00 USD for the product.

Between the two – Acronis True Image 10 and SmartSync Pro, I’m pretty much covered on the system backup and data recovery front.



| Comments [0] | | #