TeamCity SpecFlow IntegrationJan11

Wednesday, 11 January 2012 by haemoglobin

For a recent project I introduced SpecFlow to automate acceptance tests in true BDD style which I have been rather pleased with. SpecFlow’s HTML output report is very good for reporting the current behaviour and state of the system to stakeholders – an example SpecFlow report can be seen here.

Using TeamCity as our Continuous Integration platform (highly recommended by the way, I’m a big fan of TeamCity and is free for smaller teams), what we wanted was to have the SpecFlow tests run by TeamCity after every check-in, and the SpecFlow output report displayed in an easily accessible tab of the build result.

In order to demonstrate how this can be done I’ve stripped it right back from the ground up using an example SpecFlow project which is available on GitHub.

These steps assume you have git installed, however the basic idea will work with any source control system.

  1. Download an install TeamCity, SpecFlow and NUnit.
  2. From a command prompt / git bash shell – navigate to where you want to clone/checkout the SpecFlow examples (e.g c:\git), and run:  
    git clone https://github.com/techtalk/SpecFlow-Examples.git
    This will create the directory c:\git\SpecFlow-Examples containing the repository’s source. Being a DVCS however, this directory is a git repository itself that we can point TeamCity directly at for our example.
  3. In BowlingKata\BowlingKata-Nunit add a new batch file RunSpecFlow.bat with the following contents:
    "C:\Program Files (x86)\NUnit 2.5.10\bin\net-2.0\nunit-console.exe" /labels /out=TestResult.txt /xml=TestResult.xml /framework=net-4.0 Bowling.Specflow\bin\Debug\Bowling.Specflow.dll 
    
    "C:\Program Files (x86)\TechTalk\SpecFlow\specflow.exe" nunitexecutionreport Bowling.Specflow\Bowling.SpecFlow.csproj
    
    IF NOT EXIST TestResult.xml GOTO FAIL
    IF NOT EXIST TestResult.html GOTO FAIL
    EXIT 
    
    :FAIL
    echo ##teamcity[buildStatus status='FAILURE']
    EXIT /B 1

    The first line will run the SpecFlow tests which in essence are standard NUnit tests under the hood. The reason we need to run it like this from the command line instead of using the TeamCity inbuilt NUnit runner is that we need to have TestResult.txt and TestResult.xml available to specflow.exe for it to generate the report in the next line.

    There are a couple of extra checks at the end to see if the output files exist otherwise fail the TeamCity build in case of catastrophic error running the commands. Step 10 will let TeamCity fail the build if any test fails.  

    Note that your installation locations to NUnit and SpecFlow may vary. In the real world, we actually included NUnit and SpecFlow as part of our repository so things would work on any build agent.
  4. Commit this new file to the repository with:
    git add RunSpecFlow.bat
    git commit –m “Added RunSpecFlow.bat”
  5. In TeamCity, add a new project “SpecFlow Integration Test”.
  6. Create a git VCS root called SpecFlow Examples with the Fetch URL of C:\git\SpecFlow-Examples or whatever you cloned the SpecFlow Examples repository to in step 2 above. All other settings can be left as the default.
    image
  7. In the VCS settings section, tick “Clean all files before build”.
    image
    The reason for this is due to the last lines in the batch file checking for the existence of the output files. If we don’t clean the agent first, the old test output files will still be hanging around from the time before (if running on the same build agent) so we won’t get a failure if the files failed to be created for some reason. It’s slightly slower having this option on, but in practice I’ve had less strange issues with build agents if I always start with a clean checkout.
  8. Create a configuration in the project called “Run SpecFlow Tests”. In the artifacts path, add the following:
    BowlingKata\BowlingKata-Nunit\TestResult.html=>.
    This will copy the SpecFlow output report into the artifacts for the build.
    image
  9. Add an MSBuild step to compile the BowlingKata\BowlingKata-Nunit\Bowling.sln solution using the .NET 4.0 MSBuild version.
    image
  10. Add a Command Line step using the working directory BowlingKata\BowlingKata-Nunit and our command executable RunSpecflow.bat
    image
  11. Add a Build Feature of type XML report processing with BowlingKata\BowlingKata-Nunit\TestResult.xml in the monitoring rules section. This will allow TeamCity to display the number of tests run (with pass/fail counts) and will fail the build if any tests fail. Without this, the build will always be green.
    image
  12. Navigate to TeamCity Administration (top right) –> Server Configuration –> Report Tabs
    Create a new Report Tab with:image

    This tells TeamCity that whenever it sees an artifact named TestResult.html at the root level of the output artifacts, add a new tab to the build output called SpecFlow Results, and display TestResult.html within it.
  13. Run the build!
    Have a look at the lovely output below (I purposely made a test fail to show how it would look): image
    image

image

Of course, the next step is to just add a TeamCity trigger so all of this runs on every check-in to the repository.

I hope this shows how you can get SpecFlow integrated into TeamCity which I think is very effective, especially if your clients have access to your TeamCity server directly as a way of reporting progress or state of the system.

Categories:   Development Process
Actions:   E-mail | Permalink | Comments

GitHub Source Symbol IndexerJan9

Monday, 9 January 2012 by haemoglobin

Do you host your .NET library on GitHub?

Do you want to give developers who use your library the ability to step into your code while debugging, without them even needing to have git installed or your repository cloned on their machines?

Then the GitHub Source Indexer could be for you.

The GitHub Source Indexer is a powershell script that will recursively iterate over PDB files in the directory you specify, indexing the source symbol server links back to raw GitHub HTTP urls, which Visual Studio will load while debugging.

This powershell script was adapted from SourcePack (by Sebastian Solnica) which can be used if you have the full source on your machine and packed into a zip file. In his article, he also describes a lot of the science behind the source indexing of PDB files which is useful reading. Much of the source of the script is reused from SourcePack (also hosted on codeplex here) so credits and thanks to Sebastian.

There is another tool SourceServer-GitExtensions but will require Git and the repository to be installed locally (we also had trouble getting this tool working).

The first requirement before running the script is to have the Debugging Tools for Windows installed which is part of the Windows SDK which can be downloaded from here: http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=8279

As part of the installation, ensure the Debugging Tools for Windows option is selected as part of the install (install or deselect other options as you desire):

Untitled

Once complete, add C:\Program Files\Debugging Tools for Windows (x64)\srcsrv (or wherever it installed itself on your machine) into your PATH environment variable.

The essential steps of using the script are as follows – all from the command prompt:

  1. Find out what paths are currently indexed in the pdb file:
    srctool –r YourLibrary.pdb
    The output should have a original file path for every source file used in the compilation, lets assume the following for the example:
    C:\git\TestRepository\YourLibrary\LibraryClass.cs
  2. We want this to link to a GitHub URL such as:
    http://github.com/[username]/[RepositoryName]/raw/[branchtagname]/YourLibrary/LibraryClass.cs
    Confirm this URL matches the same version of the source that was used when the PDB file was created. An real example URL can be seen here: https://github.com/Haemoglobin/TestRepository/raw/release1.0/ExampleLibrary/LibraryClass.cs
    This is what the Visual Studio debugger will download into the IDE and step into.
  3. Take note of the beginning of the path in the first step, which will tell the script what to strip out to replace with the GitHub URL, i.e C:\git\TestRepository
  4. Run the powershell script as follows:
    powershell .\github-sourceindexer.ps1 -symbolsFolder "C:\git\TestRepository\YourLibrary" -userId "Username" -repository "RepositoryName" -branch "branchtagname" -sourcesRoot "C:\git\TestRepository" –verbose
    Where:
    • -symbolsFolder: Directory to recurse to source index all PDB files.
    • -userId: Your GitHub username.
    • -repository: Your project’s GitHub repository name.
    • -branch: The name of the branch or tag that matches the correct versions of the source files as when the PDB file was created. 
    • -sourcesRoot: The path that we will be stripping out from the beginning of the original file paths found in step 3 above to replace with the GitHub URL. 
    • -verbose: A optional powershell flag to have the script output more output information to the console
    • Note: Watch out for escaping backslashes! For example use "C:\git\TestRepository" not "C:\git\TestRepository\" as the latter will escape the ending quote of the powershell parameter.
  5. Run the following against the PDB file to confirm the GitHub source indexing information was written:
    pdbstr –r –p:ExampleLibrary.pdb –s:srcsrv
    Which will look something like the following:
    SRCSRV: ini ------------------------------------------------
    VERSION=1
    INDEXVERSION=2
    VERCTL=Archive
    DATETIME=01/09/2012 11:58:22
    SRCSRV: variables ------------------------------------------
    SRCSRVVERCTRL=http
    HTTP_ALIAS=
    http://github.com
    HTTP_EXTRACT_TARGET=%HTTP_ALIAS%/%var2%/%var3%/raw/%var4%/%var5%
    SRCSRVTRG=%http_extract_target%
    SRCSRVCMD=
    SRCSRV: source files ---------------------------------------
    C:\git\TestRepository\YourLibrary\LibraryClass.cs*Haemoglobin*TestRepository*
    master*YourLibrary/LibraryClass.cs
    SRCSRV: end ------------------------------------------------

You can now distribute this PDB file along with your library’s DLL, and the developer will be able to step into your source library code to assist their debugging session. Alternatively to distributing the PDB file with your library, you could also make it available through a symbol server (which I may save for another blog post).

There are a couple of things that the developer will need to setup in Visual Studio however before they can step into the GitHub source your PDB files reference:

  1. Make sure the symbol cache directory is set to a writable location (if not running Visual Studio as administrator ensure that the non-elevated user also has permissions to write here):
    image
  2. Ensure source server support is enabled and Enable Just My Code is unticked:

DebuggingGeneral
That’s it!

To test this locally, copy and reference your library’s dll/pdb pair from another project, but make sure you rename your original library folder you compiled from. This is because the original file path is not actually removed in the source indexing process, so if it is still there Visual Studio will load the original path as opposed to downloading from GitHub.

Reference the library, write some code against it and add a breakpoint before the library call. Use F11 to step into the library code, and if the file correctly downloads from GitHub it should load from your symbol server cache directory, similar to below:

image

Good luck!

[Update: If you use Resharper, you will also be able to step into the library code on GitHub at development time as you are navigating around the code, so you don’t even need to be in a debugger session for this to happen. Nice!]

Categories:   Development
Actions:   E-mail | Permalink | Comments

Patterns for Accessing App.config SettingsJan6

Friday, 6 January 2012 by haemoglobin

Here are some patterns I have used for accessing App.config settings which I’ve found to be quite clean. If you introduce an interface over top of the class you will also be able to stub it out for unit testing.

Consider the following application settings:

<appSettings>
  <add key="DelaySeconds" value="15"/>
  <add key="EndDate" value="2013-02-01 6:30pm"/>
</appSettings>

In code, timers usually require millisecond values over seconds so we do a conversion here using the Lazy object showing how any calculations can be done once and when required. We can then access these with the class below:

public class AppSettings
{
    private readonly Lazy<int> _delayMilliseconds;
    
    public AppSettings()
    {
        _delayMilliseconds = new Lazy<int>(() => GetMilliseconds("DelaySeconds"), true);
    }

    public int DelayMilliseconds
    {
        get { return _delayMilliseconds.Value; }
    }

    private int GetMilliseconds(string configSettingName)
    {
        var seconds = GetSetting<double>(configSettingName);
        return Convert.ToInt32(seconds * 1000);
    }

    public T GetSetting<T>(string key)
    {
        string value = ConfigurationManager.AppSettings[key];
        if (value != null)
        {
            try
            {
                var converter = TypeDescriptor.GetConverter(typeof(T));
                return (T)converter.ConvertFrom(value);
            }
            catch(Exception ex)
            {
                var logError = string.Format("Unable to convert configuration value for {0} to type {1}", key, typeof(T).Name); 
                Console.WriteLine(logError);
                Console.WriteLine(ex.ToString());
            }
        }

        return default(T);
    }
}

You can either wrap each setting in its own property or access it directly based on the string key as below:

var appSettings = new AppSettings(); 
Console.WriteLine(appSettings.DelayMilliseconds); 
Console.WriteLine(appSettings.GetSetting<DateTime>("EndDate"));

The output being as below:

15000
01/02/2013 18:30:00
Categories:   Development
Actions:   E-mail | Permalink | Comments

Backup Firefox Bookmarks with DropboxDec31

Saturday, 31 December 2011 by haemoglobin

This technique will make use of the mklink command that is available with Vista and Windows 7 which will essentially just link to a folder outside of your Dropbox directory so that Dropbox will include it in its backup routine. There are downloadable tools available for XP however if you are on that.

  • In the Firefox navigation bar, type about:config and press enter (accept the warning message).
  • Search for browser.bookmarks.autoExportHTML and change this value to true. This will create a bookmarks.html file containing your bookmarks in your Firefox profile directory every time you close Firefox.
  • Open a command prompt in Administrator mode (in Windows 7 you can do this by hitting the windows key, typing cmd, then ctrl-shift-enter, then Alt-Y to accept the elevation prompt).
  • Navigate to your drop box directory with cd [Dropbox directory path].
  • Find out where your Firefox profile is located by opening Firefox and finding Help->Troubleshooting Information in the menu. Beside where it says Profile Directory, click the button Open Containing Folder.
  • Copy this folder location (you can do this by typing Alt-D then Ctl-C).
  • Back in your command prompt, where “FirefoxProfile” is the name of the folder you are creating in your Dropbox directory (change this if you wish), type:
    • mklink /D FirefoxProfile then right click and choose paste to insert your Firefox profile location and push enter.
    • You should have something that looks like the following:

image

Your bookmarks along with your entire Firefox profile will be backed up to Dropbox automatically whenever you close Firefox.

If you don’t already have Dropbox, I highly recommend getting it – if you sign up with the following link: http://db.tt/qZpeNIFp you will get an additional 250MB of storage space than the normal 2GB.

Further Reading

At the beginning of doing this, I really only wanted to backup the single bookmarks.html file that Firefox produces when you turn the autoExportHTML option on by creating a hard link to this using the mklink /H option. This would work great normally – however, the way Firefox handles the bookmarks.html file is it will delete it and recreate it again when Firefox closes. This causes the hard link to be disassociated and you end up with a stale copy of the bookmarks.html file in your Dropbox folder that never updates. I then thought that I might as well be backing up my entire Firefox profile anyway.

Also, it’s not compulsory to turn on the autoExportHTML option as your bookmarks will still be in your profile – but I think it’s nice having that there for a rainy day – plus it will also allow Launchy if you use it (which I spoke a bit about here) to index your bookmarks by turning on the following option in the Weby plugin:

image

Categories:   Technology
Actions:   E-mail | Permalink | Comments

Windows Quick Launch for Remember the MilkDec16

Friday, 16 December 2011 by haemoglobin

Lately I am using Remember the Milk (RTM) more and more to keep track of all my tasks, and I am looking forward to writing a blog post about what I think is a great way of using it day to day – I will continue fine tuning the process first however.

For now I thought I would share how to set things up for rapid task entry. Remember the Milk has a nice stripped down entry page you can access to add tasks, the URL to this can be found here: http://www.rememberthemilk.com/services/ext/addtask.rtm

It would be nice though to have this appear as a small popup in the middle of your screen, launched through a keyboard shortcut such as CTL-ALT-T to pop the following window up:

RTM

I found the best way to do this is to make use of the Chrome Application feature as I talked about in my last post, associate a keyboard shortcut to it through the windows shortcut and optionally do some trickery to get the window size right.

Just follow the steps below:

  1. Browse to http://www.rememberthemilk.com/services/ext/addtask.rtm in Chrome and create a Chrome application shortcut by clicking on the wrench->Tools-"Create application shortcuts".
  2. On the next screen, choose where you want the shortcuts to be placed.
  3. Find a new shortcut created, right click->Properties, assign a keyboard shortcut such as CTL-ALT-T as in the screen shot below:

    RTMProp

And you are done.

Note that if on Vista, the keyboard shortcut key will not work if you set it on the quick launch bar shortcut.

Optional Window Size Adjustment

At the moment Chrome does not seem to remember window positions of chrome applications so I have opted to follow the approach of Eddie in his article here to size the window appropriately.

Essentially you are changing the –app part in your target field in the shortcut from:
C:\Users\HamishG\AppData\Local\Google\Chrome\Application\chrome.exe --app="http://www.rememberthemilk.com/services/ext/addtask.rtm"

To something like this:
C:\Users\HamishG\AppData\Local\Google\Chrome\Application\chrome.exe --app="C:\Users\HamishG\Desktop\Dropbox\RTMAdd.htm"

Where RTMAdd.htm is a file with the following contents - I have extended the javascript logic a bit however so the window will always centre on the screen no matter the resolution:
    <html> 
    <head> 
    <script language="JavaScript"> 
    var width=500;
    var height=300;
    window.resizeTo(width,height);
    window.moveTo((window.screen.width/2)-(width/2),(window.screen.height/2)-(height/2)); 
    window.location = "
http://www.rememberthemilk.com/services/ext/addtask.rtm";
    </script> 
    </head> 
    <body> 
    <h1>Please enable javascript.</h1> 
    </body> 
    </html>  

Hope this is useful,
Hamish

Categories:   Productivity
Actions:   E-mail | Permalink | Comments

Productivity Tip 4: Chrome Application ShortcutsNov27

Sunday, 27 November 2011 by haemoglobin

I generally use Firefox as my default web browser mainly because the plugins still seem to have much more polish, and it’s speed is catching up to Chrome after every release, however one useful thing Chrome has that doesn’t seem to exist in Firefox yet is the “Create application shortcuts” feature.

A web application, as opposed to a web site, is rich in client side functionality and keyboard shortcuts, much like a desktop application. Gmail is a good example of this, or your online to-do list application such as Remember the Milk. Since these are like desktop applications, they should really exist on your PC like any other application would with their own icon in the task bar, on your desktop and start menu etc.

You end up with something that resembles the following:

image

The 2nd and 3rd icons there on my desktop open a new stripped down chrome window with remember the milk and gmail inside, as opposed to a tab lost in amongst all the other web pages you happen to have open within your browser session. I know you can “pin as app tab” in both Firefox and Chrome but there is a benefit to be able to hit WindowsKey-3 wherever you happen to be on your PC to bring up your Gmail – or the ability to alt tab to it just like any other application.

The following steps create the application shortcut from Chrome:

  • Browse to the web application
  • Click the wrench icon in the top right
  • Choose Tools then “Create application shortcuts”

image

You then have the following options, choose what you wish:

image

And you are done. I’ve tried all sorts of hackery to get something similar going with Firefox (with shortcuts to firefox.exe and the url to load etc) but didn’t have much luck with the web application always grouping into the same Taskbar group icon in Windows 7 – even after trying to set the application id appropriately on the shortcut etc.

I am however quite happy that using Chrome I can have my favourite web applications fire open independently from my taskbar – and chrome being fast is also a good candidate for the job.

p.s I had a slight issue with the chrome applications not remembering the size of the window when I launched it next as it was always appearing in a strange location and a funny size. You may not need to do the same, but I fixed this by changing the properties on the shortcut to always open as Maximized.

image image

Cheers,
Hamish

Categories:   Productivity
Actions:   E-mail | Permalink | Comments

Productivity Tip 3: Mouseless Browsing and Password ManagementNov8

Tuesday, 8 November 2011 by haemoglobin

A couple of Firefox plugins that I have been playing with recently which I think are worth mentioning:

Mouseless Browsing

The more you get used to the keyboard, the more reaching for the mouse seems like a burden. Browsing the web tends to be quite a mouse happy activity, but there are times when you are in the keyboard “groove” and you don’t want to leave it. The mouseless browsing addin for Firefox (there are similar ones for Chrome) allows you to navigate the web just using the keyboard.

This Firefox plugin can be obtained from the following link https://addons.mozilla.org/en-US/firefox/addon/mouseless-browsing/

Once installed, you can configure a hotkey to display a special code beside each link on the page you are looking at, that you can type the id to navigate to that link.

An example screen shot of what I am talking about is as below:

image

After installing, I have modified the extension with the following settings. This is just my personal preference, the plugin itself is very customisable.

Display Ids only on demand

The webpage tends to look ugly when the ids are displayed so I prefer not to have these visible all the time:

image

Use standard characters instead of numeric

Like the mouse, I find the numeric keyboard too far away from where my hands are, so I’ve defined the ids to be standard alphabet characters instead:

image

Redefine Toggle visibility and Postfix keys

Since I don’t have the ids visible by default, I use Ctl-J to bring them up (only because of it’s natural touch typing finger position).

Turning off the numeric ids in the second step unfortunately means you can’t use modifiers anymore for opening in new tabs or windows. You can however have Postfix keys which I have setup to be the convenient keys J and N:

image

Example

Now when viewing a webpage I can use Ctl-J to bring up the ids which will all be standard letter combinations.

In the screenshot above of my site I would type ‘B’ to go to the archive section - I could also follow this by J or N if I want to open in a new tab or window respectively.

I don’t use this plugin all the time for browsing as sometimes I am just feeling mousy, but it is a handy alternative for sure !

Password Management – LastPass

As we all know, it isn’t recommended to have the same password for everything – but if you are going to have a new password for everything, how on earth do you remember them all? I have been using LastPass for a good year now and it has been great.

With LastPass, all you need to remember is the one master password, and then it will keep track of all the other passwords for you so you don’t have to remember them plus keeping them all different from each other.

When you sign up for a new website, last pass will suggest an auto generated password for you. It will then register your username and password for the site when you go to login so you don’t need to type these in for the next visit (you can specify that you always need to type your master password if you like before autocompleting the login). Their business model is a small amount per month to make use of their smart phone apps to access your passwords etc, otherwise it’s free!

The passwords are all stored on the server so you can access these anywhere you have an internet connection, but they are encrypted with your master password so no-one else including LastPass employees will be able to decipher your passwords, and all communication to LastPass is over SSL for security.

It really has streamlined my online experience - Recommend !

Categories:   Productivity
Actions:   E-mail | Permalink | Comments

Productivity Tip 2: Window and File ManagementOct16

Sunday, 16 October 2011 by haemoglobin

This is a continuation from my post Productivity Tip 1: Application Launch . When you start documenting it, it’s amazing how many little things you come to realise you are doing day to day, and it tends to end up looking quite convoluted. I will try to keep things from now on more simple!

Window Management

If you are using Windows 7 – please learn the great commands for shifting and positioning windows. (Note that whenever I use the word Win, I mean the windows key on the bottom left of your keyboard).

These are:

  • Win-Down: Minimise. 
  • Win-Left: Dock window to left half of your screen.
  • Win-Right: Dock window to right half of your screen.
  • Win-D: Minimise everything to show desktop.

If you have a second screen:

  • Shift-Win-Right: Move window to your right screen.
  • Shift-Win-Left: Move window to your left screen.

If you are not running Windows 7, you can have all the commands above plus more by installing Winsplit Revolution (note you can remap the default shortcuts to the windows 7 ones above so the transition when you upgrade will be smooth).

Just to iterate from my last post, getting your favourite apps up from pinned items in your task bar is done fastest using the Win-[# location in taskbar] shortcut. Keep pressing the number while holding the windows key to iterate through items that have grouped onto the same taskbar location. 

Alt Tab Replacement – VistaSwitcher

The Alt-Tab window switcher in Windows 7 is much better and have improved a lot since XP.

However, I am still preferring to use VistaSwitcher. The main benefit I get from using VistaSwticher is a larger window preview, and also being able to clean up and close my open windows directly from there.

To do this:

  • Alt-Tab
  • Up and down arrows to navigate
  • Press ‘s’ when over an item you want to close, to select it.
  • Press ‘x’ to close these items (note that the item you are currently over will also close)

If you have two screens, make sure that in the VistaSwitcher settings you choose a particular monitor for it to always display on for consistency, as by default it will show up on the monitor where the currently active application is sat and is just confusing.

File Management

QTTabBar

There is one major problem with windows and doing work that requires access to a multitude of folders across your machine.
You end up with something that looks like this:

image

This in my opinion is pretty hopeless for productivity.

Folders should be tabbed, just like your web browser is and any other application that opens multiple items.

Enter QTTabBar – this free open source explorer enhancement will insure that you will only ever have one explorer instance open and have lovely neat tabs for your open folders instead.

After installing, the first thing you should do is go to View->Toolbars and untick the space greedy QTTab Standard Buttons.

Now, right click the area beside the tabs to choose options:

Under “Window”:

  • Tick “Capture new Explorer processes”
  • Untick “Do not capture window as a new tab when opened from outside”

The options above will ensure you will only ever have the one explorer window no matter how you go about opening folders on your PC (the right click ‘Open folder in Windows Explorer’ option of Visual Studio for example).

Under “Tab

  • I like to have “Show tab switcher by Ctl+Tab” unticked.

Under “Shortcut Keys

  • Untick “Open current folder in new window”

The above keyboard mapping conflicts with Windows 7 create new folder shortcut.

You can now:

  • Ctl-Tab through tabs
  • Ctl-W to close tabs
  • Shift-Enter to open selected folder in a new tab

Also note the following handy Windows 7 explorer shortcuts:

  • Ctl-Shift-N – create new folder.
  • Alt-Up – navigate up one level.
  • F2 – rename (of course!)
  • Alt-D – puts the cursor in the address bar.

I then recommend pinning explorer to your taskbar for easy access using the Win-# shortcut mentioned above.

Alt-F4 Replacement with AutoHotKey

For hardcores only – I find Alt-F4 the most awkward keyboard combination for something that I need to do quite regularly (remember though that many windows respond to Esc for closing, especially modal type windows). This awkwardness of course must go.

I have instead mapped the very easy keyboard shortcut Win-Q to Alt-F4 using AutoHotKey.

Once installed, browse to the Startup folder in your start menu, right click and choose Open.

Create a text file in here with the extension .ahk and the following contents:

  • #q::   Send, !{F4}

Double click the file to start the script (this should also start when windows starts).

Other interesting lines I have in my AutoHotKey file:

  • #w::    Send, ^{F4}     (maps Win-W to Ctrl-F4 for apps that don’t follow the Ctl-W custom for closing tabs – not quite as cool as Win-Q however)
  • ^+4::Send,{ASC 0163}    (this types a ‘£’ symbol with the keyboard combination Ctl-Shift-4, useful if you are on a US keyboard).


This will do for now!
Hope this helps,
Hamish

Categories:   Productivity
Actions:   E-mail | Permalink | Comments

Syncing to Multiple Google Calendars on the iPad 2May29

Sunday, 29 May 2011 by haemoglobin

I am now the owner of an iPad 2 and loving it. I am using to catch up on lots of reading during the time I have available in the tube (underground) here in London, mainly using the offline reading apps Read It Later and synced offline RSS feeds using Byline.

One frustration I was having however with the iPad two was not being able to sync with the multiple calendars I have setup in my google calendar– i.e going to m.google.com/sync would not show the iPad device where you could choose the calendars to sync.

Through a bit of googling I found out how to get this going. First of all, it seems you may need to setup your Gmail connection with Microsoft Exchange instead of the Gmail option on the iPad settings. I not you can set this up by going to:

  1. Settings –> Mail, Contacts, Calendars –> Add Account > Choose Microsoft Exchange –> Use your full GMail address as your username –>  m.google.com as the server name when asked.

You can rename this account to something better like Gmail. I then deleted the one I had setup previously with the Gmail option instead of Microsoft Exchange.

After that,

  1. Browse to m.google.com/calendar from your iPad, click “Visit Now” to see the mobile google calendar version.
  2. Click settings in the bottom right and choose the calendars you are interested in and click save.
  3. Your iPad should now appear in the list of devices when you browse to m.google.com/sync (finally!)
  4. Choose your iPad in the list and select the calendars you wish to sync.
  5. Now in your calendar app on the iPad, click the calendars button up the top left.
  6. Tick the calendars you wish to display.

Hope this works for you as it has for me !

Hamish

Categories:   Technology
Actions:   E-mail | Permalink | Comments

Productivity Tip 1: Application LaunchMar15

Tuesday, 15 March 2011 by haemoglobin

I have recently moved to London and squeezing every last second of time out of the day is more and more important as it is very busy here. I have been working on a new version of my workflow that is more suited to my lifestyle here (compared with back in NZ), which I hope to blog about soon (as a teaser though, I have moved from MyLifeOrganized to Remember the Milk).

Lately I have been learning techniques to approach common tasks very quickly – the keyboard generally being the fastest way to do this.

My plan is to blog about techniques I’m using that are very beneficial as a core part of my day. The productivity tips though will be biased to what I do however, .NET development on Microsoft Windows Vista / Windows 7 so may not be applicable to everyone – but there may be some more general tricks in there, such as this post.

Below I’ll talk about one of the most common things you do while working at your computer which is launching applications (and then switching between them in a follow up blog post). If you get fast at this you will save plenty of time.

Application Launch

There are a few different techniques to efficiently launch applications, each one serves a slightly different purpose and I tend to flip between them. You may also have a preference for one particular style over the other.

Windows Start Menuimage

Starting with the obvious one, the start menu in Vista/Win7 is a big improvement over what windows XP has:

  • Open it by hitting the windows key then:
    • Type straight away for the application you are looking for, or
    • Press the down arrow to navigate to an application (maybe one you have pinned to the top).
  • Hit enter and you are away.

Of course typing cmd in here is a great way to get to the command prompt quickly.

Vista Quick Launch / Windows 7 Taskbar

image

!cid_C566A07E38BE4017966F07C56890EF80@HamishPC

In Vista, add an application to your quick launch bar, or in Windows 7, pin an application to your taskbar (by right clicking the application shortcut and choosing the option).

You can now open these applications by using Windows-Key and then the Number corresponding to it’s position in the list.

For instance, in my setup above I can do a google search by doing the following:

  • Hit “windows key –> 1” which opens the chrome application above since it’s position is first. By default, Chrome puts the cursor into the url bar when it launches – Ctl-T may be needed to create a new tab first.
  • Type in the google search and hit enter.
  • Chrome then searches google by default.
  • The up and down arrow keys can then be used within the google search results.
  • Hit enter to open the result you want, or ctl-enter to open in a new tab.
  • Ctl-Page Down/Page Up to cycle between tabs.
  • Ctl-W to close tabs again.

This process would be similar in Firefox except you would first need to use Ctl-k to get the cursor initially into the search box.

Another application I have pinned to my Windows 7 taskbar is called Jumplist-Launcher. This is good for a sort of overflow of applications that you don’t want to all have pinned individually, but still want them available from the taskbar itself. If you want, the jumplist-launcher’s jumplist can be opened using the Alt-Win-Number shortcut (number being the position the jumplist laucher app is pinned on the taskbar).

You will find many more core windows keyboard shortcuts and tricks on my Windows Tricks page.

Launchy

image_thumb51_thumb

Launchy is a tool that I am starting to use more an more recently instead of the options above and can be fired open from anywhere using alt-space.
It’s very fast and brilliant for firing off any complex command that you might find yourself doing a lot during the day.

In it’s most basic form, it essentially does the same as the start menu. So if you only use it for opening applications it probably isn’t worth having something extra for.

However, it gets much more powerful than this very quickly through the use of it’s plugins.  The first plugin that is most useful is the Weby plugin.

Some useful default entries in the Weby plugin:

These don’t mean much on their own, but the %1 part is where the Launchy parameter gets fed in.

The way you use the Google Weby entry for example to do a google search you would:

  • Alt-enter to launch Launchy.
  • Type “google” (this can be reduced to just ‘g’ over time after this bubbles to the top of the results based on usage).
  • Hit tab, this puts Launchy into google parameter mode. (Note you can hit tab again to enter a second parameter which would be picked up by %2 if it appeared in the entries above).
  • Type in your Google search, hit enter.
  • Your default browser will fire up to Google with your search term entered. You can then navigate google using the keyboard as described before.

image_thumb5_thumb

The Dictionary entry lets you search the definition for a word using “d->tab->wordtolookup->enter”, as well as the Maps entry to fire up a location based on a postcode for example you have just copied from somewhere else “m->tab->placename/postcode->enter” . I also recommend WordWeb however which is a quick offline dictionary that can use the ctl-alt-w shortcut on any highlighted word.

You may want to then add some of your own Weby entries that take you straight to that website that you visit often, possibly using parameters also if you need. I have set this up to Google calendar, London transport (tfl), a link to the remember the milk task entry page (http://www.rememberthemilk.com/services/ext/addtask.rtm) and one to google translate that takes in the phrase to translate as the parameter, this is below for your interest:

Google translate in this case will automatically detect your source language and convert to english. Fastest way I think for a translation, “alt-space->translate->como esta->enter”.

The Runner plugin is another that I use which makes Launchy very powerful, and can be used to run arbitrary programs and scripts. It’s setup is similar to the Weby plugin, except you point to an executable (.exe, .bat) on your computer, and then specify the arguments.

I have the following setup:

  • Shortcuts to launch favourite folders by simply listing them in the runner app (anything you have in Runner will open in the default app, i.e explorer in this case).
  • Shortcuts to launch certain websites in IE (some require this!) by specifying iexplore.exe as the program, and the url of the website as the argument. Another option for this scenario though is to use the IETab firefox plugin or equivalent.
  • Shortcuts to development batch files to execute common tasks such as svn update / commit, database recreate. You can also put these batch files somewhere defined in the Launchy catalog, these are directories that are listed in Launchy to be indexed (you will need to add the *.cmd file type however).
    • If you use TortoiseSvn, you can fire open it’s UI for these tasks with a .cmd file containing the following script (commit below can be substituted by other tortoise Svn commands such as revert and update):
      • set path=%path%;C:\Program Files (x86)\Subversion\bin\tortoiseproc.exe /command:commit /path:"E:\svn\ProjectFolder\src"

Conclusion

In general, if you use an application a lot, find out what the keyboard shortcuts are for it, it will make your life easier. For example keyboard shotcuts for Gmail, Google Calendar and Google Reader or your favourite email client.

If you find yourself doing the same thing over and over and it just feels awkward every time you do it, take time out to find a better way as it will pay off quickly.

More productivity tips to come! Next up is application switching and window management. 

Categories:   Productivity
Actions:   E-mail | Permalink | Comments

Powered by BlogEngine.NET 1.6.1.0 | Design by styleshout | Enhanced by GravityCube.net | 1.4.5 Changes by zembian.com | Adapted by HamishGraham.NET
(c) 2010 Hamish Graham. Banner Image (c) Chris Gin