TechDays 2012: speaking & visiting

14. February 2012 23:37

This year at DevDays, I will be doing a presentation on building microsites using Orchard CMS and running them on Windows Azure. How is that for a lot of product names and concepts in one sentence? Orchard CMS is an open source content management system that is backed by Microsoft. It is built using contemporary .NET features and is highly extensible, as you will find out if you visit my session. Besides me, there will be a lot of Avanade colleagues presenting as well: Geert van der Cruijsen, Jesse Houwing, Mirjam van Olst and many more.

 

A quick list of some of the sessions I am looking forward to:

 

  • 11:05 - 12:20: a couple of options. "Rocking the enterprise with the Kinect" might be interesting since we have a couple of interns at Avanade that are doing great stuff with Kinect... but the intro to WinRT by Bart de Smet might be cool too: Bart is a very very smart guy, his sessions are always insightful.
  • 13:30 - 14:45: Deep dive into Metro, even though the Gu is on stage at the same time. Seen the "how to get up & running with Azure" often enough, I suppose.
  • 15:05 - 16:20: This time, going to the MVC4 session by the Gu. I mean: he is here, in the Netherlands, must see at least one session.
  • 16:30 - 17:45: A lot to choose from. The session on the SharePoint Developer Dashboard by Gustavo Velez should be cool (listed as a level 400 but from experience I can tell you it will feel like a 700... at least). The session by Steve Sanderson on single page apps should be interesting too, though.

 

After that: Geeknight. Must go & see Rob Miles if only for entertainment value, other than that I will go with whatever I feel like. On Day 2:

 

  • 09:15 - 10:30: I will probably go and see Astrid Hackenberg talk about multi tenant Azure apps. On the other hand, I might opt for unknown territory and go and see Beth Massi on the advanced bits of Lightswitch.
  • 10:50 - 12:05: I have not made up my mind yet, might actually go and try out some of my own code demo's during this slot.
  • 13:15 - 14:30: Steve Sanderson on async web apps and MVC4 might be good, but Geert's session on push tiles in Phone 7 should be nice too.
  • 14:50 - 16:05: Looking forward to seeing things I did know you could do with Windows Azure in the session by Nick Harris.
  • 16:15 - 17:30: my own session on Orchard, Azure and microsites. Should probably go there.

 

There is a TechDays NL app in the Windows Phone 7 marketplace; grab it to browse al the available sessions and mark your personal favorites. If you happen to be bringing another device to the event, visit http://m.techdays.nl/ for the session information.

Autohotkey Autoinclude

14. October 2011 23:17

If you like Autohotkey, you probably have a lot of scripts you use or want to try out. Additionally, you will probably want to use those scripts on more than one machine, but potentially, you do not want to have all those scripts running on all machines. In my case, I only use Outlook on my work laptop, so all the Outlook hotkeys only need to be active on that machine, while at the same time I want to leverage Live Mesh (part of Windows Live Essentials) to sync all my scripts across machines. The combination of trying out scripts and selectively activating them makes keeping everything in one script a tedious task.

Enter Autoinclude. This is a very smart AHK script written by Scott Rippey that was published on Lifehacker some time ago. Follow the link for all the details, but what it basically does is conditionally generating a single AHK script from a set of folders containing scripts, and executing that single script. The only thing that you need to change in the AHK scripts that get included, is that you must add a comment on the first line with ";auto-execute" if you want to have auto-executing code in your particular script.

 

Setting up Autoinclude

You can read the Lifehacker post linked above to understand Autoinclude, so I will limit myself to a step-by-step instruction on how to set it up. This is what you do:

  1. In a folder that is synced by Live Mesh (or Dropbox or whatever else you prefer), set up a root folder for all your to-be-included scripts.
  2. On each machine, you need to create a specific Autoinclude AHK script. What makes it specific for each machine is the list of folders inside the root folder that you want to have included (see code below).
  3. Set up a Windows startup task that points to this Autoinclude script (easiest method: add a shortcut to the Startup folder in you Start menu)

Done! Whenever your startup task activates, the Autoinclude script will generate a new script that includes everything you told it to include, and execute it. This is the section of Autoinclude.ahk where you set your folders:

 

StartUp = C:\Users\tijmenvdk\_SkyDrive\scripts\prod\Autoinclude
IncludeFolders = 
(comments ltrim
	%StartUp%\#includes
	%StartUp%\All
	%StartUp%\Laptop
)

 

Reloading your script tree from Launchy

To make editing and adding/removing scripts easier, you can add a shortcut to Launchy that points at your Autoinclude script and name it "reload script tree" (or similar). Better yet, add it to your Launchy-shortcut-generating-script with this line:

 

"%app_makelink%" /q "%folder_launchylinks%reload script tree.lnk"      "C:\Users\tijmenvdk\Programs\AutoHotkey\Autoinclude.ahk" "" "" "" "7"

 

Just to give you an idea of what my scripts root folder looks like:

 

 

As you can see, I have added a simple naming convention: the script name includes the assigned hotkey, where applicable. This makes it very easy to find a particular script. "LoA" stands for "Launch or Activate", something I will explain in a later post.

Introducing autohotkey

1. October 2011 23:22

Often when people look over my shoulder (or are watching a presentation I am giving), they ask how I get my computer to perform specific tasks without ever touching my mouse. I could write on a long-winded post on being the master of your own tools and all that, but the answer is actually quite simple: I use AutoHotkey. Their tagline says it all: Automation. Hotkeys. Scripting.

Using Autohotkey (or AHK for insiders), you can automate virtually anything by sending keypresses and mouse clicks. You can create hotkeys, auto-expanding strings (convertion "burl" into "http://tijmenvdk.nl/" for instance), create an entire GUI if you want to, and easily compile scripts into portable executables.

To give you an idea of the things I do with Autohotkey:

  • Left-control plus right-control to function as Alt+tab
  • Re-map default Windows shortcuts (Windows+F to run Everything instead of Windows Search, Windows+E to run Free Commander instead of Windows Explorer, etc.)
  • Control special keys on a specific keyboard (for instance, F13 to F19 on my Mac keyboards, but also media keys on my laptop)
  • Remap F1 to F2 inside Excel (seriously, how often have you pressed F1 [help] when all you wanted to do is edit a cell [F2]?)
  • Use a shortcut key to paste text without formatting
  • Toggle the active window to always stay on top (or turn it transparent... or both)
  • Use a shortcut to immediately Google the text you have selected
  • Get CTRL+E back in Firefox to activate the search box

The list goes on. Quick example: to do bullet 4, all you need is this:

 

#IfWinActive ahk_class XLMAIN
	f1::Send {f2}
#IfWinActive

 

To turn the active window translucent when you hold CTRL+ALT+spacebar:

 

^!Space::WinSet, Transparent, 125, A
^!Space UP::WinSet, Transparent, OFF, A

 

Generating shortcuts for Launchy

17. September 2011 22:47

If you have read my previous post on Launchy, you know I prefer Launchy as a means to start programs using the keyboard only using the Windows start menu, either by mouse or by entering a search string. By default, Launchy indexes your start menu, but you can easily add other locations by going to the options screen. On the catalog tab, you can add as many search locations as you like. If you want, you can even have Launchy index your document folders to quickly open your documents.

However, setting up Launchy on each new computer can get a bit tedious, especially if you start adding custom shortcuts, like preferred bookmarks or other shortcuts that are a bit more elaborate/specific than what you would find in your start menu. So, I have written a little script that generates the necessary shortcuts in a folder of my choosing. On a new computer, all I have to do is run the generate script, add a folder to the Launchy catalog, and re-index the catalog.

 

The generate script

To generate .lnk (shortcut) files, I use xxmklink.exe. You could also use shortcut.exe (from the Windows development toolkit), but xxmklink has a few more options. There are a couple of folders in play here, most of which are synced between computers using Windows Live Mesh, part of Windows Live Essentials. There are:

  • folder_scriptroot: this is where all the scripts that are used are located
  • folder_scriptresources: home of all the resources that are used by scripts (among which is xxmklink.exe, but it also houses template files and any other file your script might depend upon
  • folder_launchylinks: location where the Launchy shortcuts will be created

The generate script (a batch file) uses the %COMPUTER_NAME% environment variable to set different values for these variables. You can see an example of this in the demo script at the end of this post.

 

Useful links

A couple of suggestions for the links you can add to your generate script:

  • Remote desktop connections to various machines you want to connect to (sample in the demo script)
  • Shortcuts to specific batch files (or other scripts) you use
  • Links to locations on your machine or network (possibly extended with Windows Explorer command line switches)
  • Links to autohotkey files

And the list goes on. I have about 15-25 links generated this way, depending on the machine.

 

Demo script

A short demo script looks like this:

 

@echo off

setlocal

if %COMPUTERNAME%==CARRIE goto laptop
if %COMPUTERNAME%==TOUCHY goto tablet

echo Computer %COMPUTERNAME% not found!
goto end

:laptop
set folder_skydrive=C:\Users\tijmenvdk\_SkyDrive\
set folder_launchylinks=C:\Users\tijmenvdk\Programs\Launchy\
goto continue

:tablet
set folder_skydrive=C:\Users\me\_SkyDrive\
set folder_launchylinks=c:\users\me\programs\Launchy\
goto continue

:continue
set folder_scriptroot=%folder_skydrive%scripts\prod\
set folder_scriptresources=%folder_scriptroot%resources\
set app_makelink=%folder_scriptresources%xxmklink.exe


"%app_makelink%" /q "%folder_launchylinks%dolores remote desktop.lnk"  "%windir%\system32\mstsc.exe" "/v:dolores /admin /w:1024 /h:768" "" "" "1"
"%app_makelink%" /q "%folder_launchylinks%newmessage.lnk"              "C:\Program Files (x86)\Microsoft Office\Office14\OUTLOOK.EXE" "/c ipm.note" "" "" "7"

:end
endlocal
pause

Launchy keyboard launcher

13. August 2011 22:35

Even with search integrated into the Windows 7 start menu, I still find myself using Launchy to start programs and launch shortcuts all the time. The primary reason for me is that it remembers what you launched with a particular text the next time you type it. What this means: if I use Launchy to start "SharePoint Workspaces" with the input "sp", it will put that hit at the top of the list the next time I type "sp". The start menu search will always put "SpeedFan" and "Split/Second" first. Besides performance, this for me is the primary selling point of Launchy over standard Windows functionality.

Another great feature is that you can add arguments to commands by pressing TAB. For instance: if I type "int", Launchy will match this to Internet Explorer. By pressing TAB, you can immediately add a URL that you want to open in this browser. So, grab it from http://www.launchy.net/, install and enjoy!

RDP over wireless does not work

26. July 2011 09:37

I often use remote desktop to connect to my Windows 7 work laptop, to take advantage of my multi-monitor workstation without having to connect a lot of wires to my laptop. I recently upgraded my wireless access point, going from 54 Mbps to 450 Mbps (at least theoretically). Before this upgrade, I always used a wired LAN connection to RDP to my laptop, but with the new speed I figured I could try it over wireless.

Guess what? It did not work. Connectivity was there, it would even initiate the remote desktop connection, but it would either hang at the Windows 7 "welcome" message or the RDP session would go black almost immediately, terminating after ~30 seconds. Googling around, I found the solution: it has to do wth the fact that by default, Windows creates wireless connections on a per-user basis. Whenever you connect through RDP, the per-user connection gets dropped and re-connected, resulting in an RDP session that will never happen. So, what you need to do is re-create your wireless connection and explicitly share it between all users on your laptop. This setting cannot be changed after the connection has been configured.

So, what you need to do:

 

  1. Ensure the wireless network profile type is set to use "all-user" profiles
  2. Remove your wireless connection from Windows
  3. Manually re-create it

 

For the first step, do the following:

 

  • Open the "manage wireless networks" window (link on the left side in networking center)
  • Click the "profile types" button in the buttonbar
  • Select the "all users" option
  • Click Save

 

Next step is to remove your current connection. If necessary, open the connection properties first and write down SSID name and security details you might need. Also, on the first tab of the property page, you can confirm the fact that your wireless connection is set up for just you. After removing the connection, manually add your wireless connection by clicking "Add" and selecting the first option to manually add a network profile. Fill out SSID and security details and make sure you set the connection to start automatically. That's it!

Using a Mac keyboard on Windows

26. May 2011 11:37

I love the Apple keyboard. To me, the low profile with very low physical resistance to the key presses makes it the ideal developer keyboard. People ask me on a regular basis what I had to do to make it work on my Windows 7 computer, so let me summarize it in 3 levels.

 

Basic – getting it to work

Plug it in, it works. It has a standard USB connector (even though the included extension cord does not).

 

Intermediate – mapping Windows & Alt keys

I am a touch typist and I actually use the Windows keys (and Alt) on my keyboard all the time. Unfortunately, the Mac keyboard swaps the Alt and Command around. To re-map the keys, you can hack the registry or get someone to make a tool for that. Luckily, someone did: enter SharpKeys. Use SharpKeys to change the keys (see the screenshot below).

 

Advanced – quickly switch between keyboard layouts

There is (at least) one problem with using SharpKeys: if you use it on your laptop, the actual keys on your laptop get swapped as well, to the point that you have to press Ctrl+Win+Delete instead of Ctrl+Alt+Delete. If you use your laptop without keyboard attached some of the time, you can use this AutoHotkey script. Features:

  • Remaps Win and Alt keys
  • At startup, the script is disabled. You can enable/disable the script using Ctrl+Shift+CapsLock.

Note that this script is not flawless: sometimes, when using the Windows keys for other shortcuts (like Win+D to show desktop) the active window is sometimes “forgotten”, leaving you in another window than you might expect. It mostly works fine, though.

 

#SingleInstance force

AutoSuspend()

; context sensitive switches: not for remote desktop
#IfWinNotActive ahk_class TscShellContainerClass

LWin::LAlt
LAlt::LWin
RAlt::AppsKey
RWin::RAlt

#IfWinNotActive

+^CapsLock::
    Suspend Permit
   Suspend Toggle
Return

AutoSuspend()
{
    Suspend On
}

DevDays 2011: lots of Azure sessions (besides mine)

8. April 2011 12:44

DevDays 2011 speakerDevDays 2011 is just around the corner. Most of the agenda and speakers are known, and there is a lot of content to look forward to. I will be doing a session on implementing CQRS (command/query responsibility segregation) on Windows Azure. CQRS is an architectural pattern that completely separates commands (writes) from queries (reads), with the intent of improving scaleability and optimizing for both reads and writes.

 

During both days, when I am not in sessions or at the Avanade stand, I will be sure to visit the Ask the Experts stands and of course the WAZUG (Windows Azure User Group) stand. Come meet me there for interesting discussions on Azure, architecture or other random topics that might come up.

 

Since I get to go both the 28th and 29th, I look forward to visiting lots of interesting sessions. The first day:

 

  • 9:15-1045: the keynote, obviously. Scott Hanselman, Rob Miles, what more could you ask for? Should at the very least be entertaining.
  • 11:05-12:20: Entity Framework in practice by Pieter de Bruin. Entity Framework really grew up for framework 4 and even more so in the latest 4.1 release.
  • 13:30-14:45: difficult one. Might go to the Windows Azure AppFabric session by Clemens Vasters, but the This costs what? Azure session by Scott Seely is also interesting (and possibly more applicable in my day-to-day job at the moment).
  • 15:05-16:20: again a bit hard to choose, this time because there is not a lot of content that appeals to my personal interest. Having said that, seeing Scott Hanselman do his thing in the NuGet in Depth session is always entertaining & a guarantee to learn at least something new, so I will probably go there.
  • 16:30-17:45: the moment of truth: my CQRS session. My guess is this is where I will be.

 

On Geek night I will probably go to whatever I feel like at the moment. Great sessions by Scott Hanselman, Rob Miles and many others will provide a lot of info (and fun!).

 

Friday 29th again brings a wealth of interesting sessions:

 

 

So, all in all, it looks like it is going to be another great event. I look forward to meeting you there! Drop me a comment of find me on twitter (@tijmenvdk) to let me know where you are going.

Report data source list empty in web project

7. April 2011 15:59

I came across something weird today: I am working on an ASP.NET MVC 3 project that includes reporting. The data for the reports is loaded into custom viewmodels (simple POCO classes) by service classes. Where those service classes get their data is unknown inside the reports, which is as it should be from a separation of concerns standpoint.

The customer viewmodel class and customer service class below can serve as a simple example if you want to try this out yourself:

 

public class CustomerRepository
	{
		public List<Customer> GetCustomers()
		{
			var result = new List<Customer>
			             	{
			             		new Customer() {Id = 1, Name = "Frodo" },
			             		new Customer() {Id = 2, Name = "Merry" },
			             		new Customer() {Id = 3, Name = "Pippin" }
			             	};
			return result;
		}
	}

	public class Customer
	{
		public int Id { get; set;  }
		public string Name { get; set; }
	}

Next step is to add a report to your project. Right-click the content folder, click "add", "new item", go to reporting and pick the reporting wizard.

 

 

Notice that the Data Source dropdown is... empty.

 

The fix

I am sure the following is a bug somewhere, but here is how you fix this. Cancel the wizard and add a .aspx webform to your project (I only tried adding it to the root):

 

 

And yes, I know a web form has no place in an MVC project.

After this, re-run the reporting wizard, and you are greeted by the following:

 

 

All of a sudden, the list of available data sources is populated. As an aside, if the data sources are there but the fields list is empty, chances are that you did not add getters and setters to your viewmodel. Apparantly, reports do not like to be populated with public fields.

Article on CQRS published

4. April 2011 10:52

My article on implementing CQRS (command/query responsibility segregation) has been published in the Dutch .NET magazine. You can find the article (in Dutch) here. As mentioned before, I will also be presenting about this topic at DevDays 2011.