Paul’s jabber


Speed up your Windows navigation
October 19, 2008, 6:45 pm
Filed under: Computers, Software, Uncategorized

As most people that spend the majority of their lives staring at a windows box, I’ve gotten quite irritated by the repetitive tasks that I have to perform on a daily basis. Among others, the most prominent of these tasks is probably the browsing of files in both Windows Explorer and command prompt. So it got me thinking (and I’m sure I’m not the first – to think that is).

The easiest way to shorten the time you spend navigating, is to simply litter your desktop with shortcuts to various locations on your file system. However, the problem I have with this solution is that I’m not really a fan of the mouse or Britney Spears for that matter. Instead I’ve opted for the next best alternative, which I’m sure I’m not the first to think of, but it is a quick, easy and temporary solution that just works.

Basically, I’ve simply created a whole bunch of batch files, each with a popular command, such as to open Windows Explorer in a specific directory. These batch files, I’ve then grouped into one directory and added the directory to my path environment variable. Let me take you through an example:

If you’re a developer like I am, the most popular location on your file system is probably where you checkout your code from the repository. Chances are that the path to this repository check out is something like:

C:\some_useless_folder\another_useless_folder\repos\my_useless_app\

So instead of navigating to this folder every time in Windows Explorer, you could just do the following (I know this seems like a lot of work but that’s only because you don’t yet know what I’m talking about – that’s why you’re still reading after already having read the third paragraph):

1. Create a folder where you’ll keep all your batch files e.g.
C:\shortcuts\

2. In this folder create an empty batch file (just an empty text file with a .bat file extension) e.g.

C:\shortcuts\my_useless_app_e.bat

3. Open the above created “my_useless_app_e.bat” file and inside it enter the command to open Windows Explorer to the directory where you’ve got your app checked out e.g.
explorer “C:\some_useless_folder\another_useless_folder\repos\my_useless_app\”

4. You now have to add the directory containing your batch file to the path environment variable. I’m using Windows Vista (it’s not my fault, they gave it to me without asking), but in Windows XP it’s done in an almost identical way, so try and follow along:

4.1. Click the Start button, then right click “Computer” and then click “Properties”.

4.2. Click “Advanced system settings” (you see now we’re getting advanced).

4.3. On the dialog that opens up, click on the “Advanced” tab (now we’re getting even more advanced, hold on to your seat).

4.4. Click the “Environment Variables” button.

4.5. Under “System Variables” click the “New…” button. For “Variable name” enter “shortcuts” (can be an arbitrary name) and under “Variable value” enter the path to the directory where you created the batch file i.e. “C:\shortcuts\”. Click “OK”.

4.6. Under the list of “System variables” look for a variable called “Path”. Select it and click the “Edit” button.

4.7. Scroll to the end of the variable’s value and append the variable that we just created above i.e. just add “;%shortcuts%” (without the quotes) to the end of the value. WARNING: What ever you do, don’t remove any of the existing text in this variable’s value as you may find that many/most of your applications will no longer function correctly. Click OK to close this dialog box, then click OK again to close the “Environment Variables” dialog box and click OK one more time (last time I promise) to close the “System Properties” dialog box.

5. Lastly to test that your shortcut (command in batch file) works just open command prompt and type the name of the batch file that you created earlier e.g.

5.1. Hit the windows and the R keys together to open the “Run” dialog box.

5.2. Type “cmd” (without the quotes) to open command prompt.

5.3. Type the name of the batch file i.e. my_useless_app_e

The batch file should now run which should open Windows Explorer to the path:

C:\some_useless_folder\another_useless_folder\repos\my_useless_app\

If for some strange (or not so strange) reason this does not work, simply restart your computer – you see now I’ve even given you a Tech Support 101. Anyway, from now on, it’s smooth sailing every time you have a frequently used command, simply create a batch file containing the command in the “C:\shortcuts” directory and when ever you want to run the command, just open command prompt and type the name of the batch file … easy!.

But like I said earlier, this is only a temporary solution. The cleanest way would probably be to write my own app that holds popular commands. If someone knows of any apps that do this or other ways to improve your Windows navigation, please let me know.



Integrate Twitter with FaceBook status updates
October 17, 2008, 3:44 pm
Filed under: Software, Uncategorized

Initially when I started twittering I was kind of discouraged by the idea mainly because I don’t have many followers on Twitter, whereas In FaceBook, I have quite a number of friends that post status updates and hopefully read my own updates too.

Now, however, I’ve just come across a cool FaceBook app that integrates Twitter with FaceBook status updates:  http://apps.facebook.com/twitter/ 

This is just what I needed, easy to use and it just works, awesome!

Once installed, you can later disable the FaceBook twitter app from automatically updating your status updates by going to the FaceBook application settings page and unchecking the checkbox “Update my status without notifying me.” in the “Additional Permissions” tab of the app’s settings.



Red Five Labs’ Net60 v1.1 release – .NET Compact Framework for Symbian OS
September 8, 2008, 7:55 pm
Filed under: Software, Uncategorized

I’m currently a developer at Red Five Labs and I’m quite proud to say that we’ve managed to push yet another successfull partial release of Net60 out the door, which is now packed with whole bunch of new features. In a nutshell, Net60 allows executables that target the Microsoft .NET Compact Framework to run unchanged on mobile phones running the Symbian OS.



NetBeans IDE for Ruby on Rails
September 6, 2008, 9:05 pm
Filed under: Software, Uncategorized

I’ve just begun learning Ruby on Rails and like many others I started off with Instant Rails which includes a Ruby interpreter, Ruby on Rails, Apache and MySql in an all in one neatly wrapped up installer. There have been a few occasions when I have felt fortunate to be a Windows user and this was one of them i.e. I quickly browsed through the Rails installation guide for Mac and Linux users and … well … I recommend you leave your Saturday night/morning open, preferably between one and five am when you’re feeling a little like a zombie, simply in order to numb the pain … a shot of whiskey might help too.

Anyway, I generally lean towards using the command line as opposed to clicking away at some developer’s weak artistic attempt at creating something he/she is trying to pass off as a GUI. However, when it comes to actual coding I have to admit that I can’t do without an IDE and it is for this exact reason that I set out to find one for Rails. Learning a new language is challenging enough as it is without the added effort needed to remember all those darn commands in IRB (Interactive Ruby Console).

After having looked at several solutions I have finally found something that I am happy with and that is the NetBeans IDE 6.1, which now supports Ruby, as well as Ruby on Rails. It also comes with JRuby which is a Java implemented Ruby interpreter that allows two-way access between Java and Ruby code. More importantly according to the Wikipedia it also uses just-in-time compilation and ahead-of-time compilation. Alternatively, if you like, there is also an option to select your own Ruby interpreter to use within NetBeans instead. If you’re anything like me I’m sure you’ll agree that the best benefit of using an IDE is that you have IntelliSense with descriptions for all methods, types etc.

With that said, I hope you give Ruby a go (if you haven’t already). It should be alot of fun.



Unpacking and modifying a Symbian Installation Source (SIS) file.
September 5, 2008, 10:22 am
Filed under: Software, Uncategorized

I recently had to unpack and modify a Symbian Installation Source (SIS) file and I came across a neat little tool for doing just that; SISContents not only lets you unpack the SIS file, but also edit the package and view the pkg that was used in creating the SIS file.



Maintaining a VSPackage that’s targeting Visual Studio 2005 and Visual Studio 2008
August 29, 2008, 2:45 pm
Filed under: Software, Uncategorized

I recently had the task of migrating a Visual Studio 2005 VSPackage, (a custom project type to be more precise) to Visual Studio 2008. Obviously having the VSPackage functional in VS 2008 alone was not good enough, we needed it to work in VS 2005 too.

After googling around I found a very interesting and helpful post about making a VSPackage run in both VS 2005 and VS 2008:

http://weblogs.asp.net/soever/archive/2008/06/04/use-vs2008-to-create-a-vspackage-that-runs-in-vs2008-and-vs2005.aspx

In the above scenario the package would basically be built against the VS 2005 SDK’s MPF (Managed Package Framework), but would then be registered under different Visual Studio registry hives i.e. 8.0/8.0Exp (VS 2005) and 9.0/9.0Exp (VS 2008). I then encountered a problem with the retrieval of the MSBuild path from the registry. This occurs within the ProjectBase source code in the Microsoft.VisualStudio.Package.Utilities.GetMsBuildPath(…) method. The Utilities class of the VS 2008 SDK , which contains this method, can be found in the following location;

%VSSDK90Install%\VisualStudioIntegration\Common\Source\CSharp\Project\Utilities.cs

You’ll find the VS 2005 SDK version of the Utilities class in the same location, but obviously under your VS 2005 SDK install path instead. You might have noticed that the VS 2005 SDK version of the GetMsBuild(…) method searches for the MSBuild path in only a single place in its VS hive:

Software\Microsoft\VisualStudio\8.0\MSBuild\MSBuildBinPath.

This registry value however does not exist in the VS 2008 registry hive (9.0) and therefore an exception is thrown when we try and run the VSPackage in VS 2008. If on the other hand you look at the VS 2008 SDK version of the GetMsBuildPath(…) method, you’ll notice that it attempts to find the MSBuildBinPath registry value in the same location as above and if it can’t it then tries to find it under the MSBuild registry hive:

Software\Microsoft\MSBuild\ToolsVersions\3.5\MSBuildToolsPath.

Now, you may say that the obvious solution would be to simply integrate the VS 2008 SDK’s code in the VS 2005 SDK’s code thereby making the VS 2005 SDK look for the MSBuild path in two locations in the registry. Have I tried it? Yes. Does it work? Yes. Is it a clean and elegant solution? I don’t think so. Not to mention that we would then have to maintain this customized code, meaning that every developer that may work on this project in the future would have to customize his/her copy of the VS 2005 SDK.

In order to implement a more elegant and maintainable (in my opinion) solution, I’ve opted to create separate assemblies for VS 2005 and VS 2008. Since all of the modifications needed to migrate a VSPackage from VS 2005 to VS 2008 are contained within the solution (.sln) and project templates (.csproj) of my projects, we can simply have separate solutions and projects opening the same code, but targeting different VS SDK MPF’s and registry hives. I converted the VS 2005 VSPackage to a VS 2008 VSpackage using the following tutorial.

http://msdn.microsoft.com/en-us/library/cc512930.aspx

Each developer working on the VSPackage can now simply check out the source code and open either the VS 2005 or VS 2008 solution depending on which IDE he/she is using.

Additionally for our WIX deployment we now simply have different .wxs deploy fragment files to register the VSPackage under the correct VS hive depending on what IDE the end user has installed. Have a look at the following article for deploying a VSPackage, which among others includes an implementation using WIX:

http://msdn.microsoft.com/en-us/library/bb458038.aspx

If anyone has any other ways of doing it, please let me know.



Echo a message to a text file from command prompt
August 23, 2008, 6:56 pm
Filed under: Computers, Software, Uncategorized

I just found a nice quick way of creating and writing to a text file straight from command prompt. This will save you the agony of having to open Windows Explorer, create a txt file, open it with notepad, write your story and save it … whew (wipe forehead). So this is how we’ll do it:

The first command creates a txt file “MyCoolTextFile.txt” containing the text “Hello world!!”. The second command however, I’m sure you’ll find even more exciting as it displays the contents of the file we’ve just created. And what do you know, the contents is “Hello world!!!” just as we typed it in the first command. There are of course other ways of doing it, but I won’t be telling you how … uhm … because quite frankly I don’t have the energy nor the time to type up and test all the various methods.



Visual Studio 2005 custom project type error: “The object already has a CCW associated with it. Parameter name: o”
August 4, 2008, 7:27 pm
Filed under: Software, Uncategorized

I have a custom Visual Studio project type which I am working on and quite recently I had a small issue which was self-inflicted i.e. not by Microsoft. I just thought I’d write out my experience for anyone who may have come across the same issue.

The issue was that I could not create/add the custom project more than once in an instance of Visual Studio. An exception would be thrown in the MPF (Managed Package Framework) when calling Marshal.CreateAggregatedObject(aggregateProjectIUnknown, newProject) inside the following method:

Microsoft.VisualStudio.Shell.Flavor.FlavoredProjectFactoryBase. PreCreateForOuter(IntPtr outerProjectIUnknown, out IntPtr projectIUnknown)

The exception message was: “The object already has a CCW associated with it. Parameter name: o” After googling around, I came across one other mention of this problem: http://forums.msdn.microsoft.com/en-US/vsx/thread/7f92445c-2d37-4f59-945f-7322a57bc53a/. Basically, as far as I understand our ProjectFactory creates a managed object of type ProjectContainerNode to represent our custom project. Thereafter when the above method Marshal.CreateAggregatedObject gets called it attempts to create a CCW (Com Callable Wrapper) for the managed object. This worked fine the first time, but the second time around when attempting to create/add another custom project it would throw the above exception.

The issue seemed to be in the ProjectFactory where we wrote the code to only create a new instance of the ProjectContainerNode if it was null. However, only a single instance of the ProjectFactory exists for each Visual Studio instance and therfore the ProjectContainerNode would never be null again after the first time the custom project was created. Therefore instead of a new project node being created, the MPF would be given the existing ProjectContainer node to which it had already created a CCW. The solution was to simply create a new instance of the ProjectContainerNode every time in my ProjectFactory.



Visual Studio extensibility learning resources
June 20, 2008, 9:15 am
Filed under: Software, Uncategorized

Recently I set out to play with the Visual Studio SDK in order to create a custom project type and custom msbuild task and I must say that it’s quite a learning curve. To further contribute to the agony I also had a bit of hard time finding any learning resources. So if your experience has been anything like mine and you’ve spent countless hours googling around then give the following sites a try:

Lastly, as I’m sure you’ll notice, there are a few samples supplied with the Visual Studio SDK.



Adding tasks to the Task List in Visual Studio 2005
June 11, 2008, 5:27 pm
Filed under: Software

I’ve recently come across a very exciting feature in Visual Studio, which I thought the whole world should be famiiar with, or at least every .NET Developer using Visual Studio. As many other programmers may do, when I want to call a method that I haven’t implemented yet, I normally just stub that method and throw a NotImplementedException in its body. Although this may be a nice way of being reminded of a method not having been implemented, the problem is that on many occasions the testers would be the ones receiving the exception when they run the code.

In an effort to reduce the risk of that happening and more importantly to have a centralized view of all the tasks left for you to do in your code, you can use Visual Studio’s Task List.  Whenever you feel that a portion of code deserves revisiting, you simply add a comment and precede it by one of the default keywords:

//TODO I still need to implement this method.

//HACK I have to rewrite this method as it is plain ugly.

//UNDONE This code needs to be uncommented.

Now open your Task List in Visual Studio: View > Task List. Select “Comments” in the combo box at the of the Task List window and you should see the comments that you’ve sprinkled all across your code. You can, if you wish, add your own custom keywords from: Tools > Options > Environment > Task List.

You could if you like develop your own Visual Studio tool, using the Visual Studio SDK, to manage the Task List. This is how I got to find out about the Task List in the first place, but that’s beyond the scope of this post.