Archive for the ‘Miscellaneous’ Category

US vs French vs Swedish vs 1337 keyboard layout aka 1773 keyboard

December 29th, 2009

A keyboard layout aimed at programmers for Windows and OSX.

It swaps numbers and characters in the top row so one doesn’t have to press shift for every parenthesis.

TL;DR

Most programming languages I have tried work better with a US keyboard layout than a Swedish.  For instance my current language, C#, is riddled with {s and [s and these are a pain to use.  One has to press the right Alt-button (labeled alt-gr) and then 7 or 8 respectively.  Try this, it really twists your hand.

The US keyboard has {, [, ], } to the right of P and it works much better than the Swedish keyboard.

But then we have (, ), =, & and the rest above the number keys.  Most languages use plenty of parenthesises and even though you don’t have to twist your hand it is still awkward to use two keys (and hands with a “proper” finger setting) to write these common characters.  The French keyboard has solved this by flipping the number keys/shift setting.  Press the key to get an ! and shift-key to get 1.  If one write lots of number there is always the proper number keyboard to the right.

So the French keyboard is better for some other characters.

Then we have the Swedish characters å,ä and ö.  Even though I usually hack in English I write text, outputs and user information in Swedish so these cannot be left out.

Thinking that there was no reason to have a second rate keyboard layout I fired up MSKLC from Microsoft and hacked together the 1337 keyboard layout.  I have used it for a couple of years now in WinXP, Vista and Win7.

For almost all use other than programming I keep the Swedish layout so I have set leftshift-leftalt for a fast keyboard layout toggle.

Lastly: I do use touch typing and I recommend learning this for all serious software developers.  I also have noticed that I have very little problem with switching keyboard layout, the fingers need a second to adjust and are then hitting the right key.

(For problems 1337 reverting to US see here.)

>Visual studio net database edition does not handle data

July 13th, 2009

>

The title is not totally correct; it does handle data. But it cannot do version management on your database if you have data in it properly.

Like this:
A year into the project you/the customer realize that a Customer can be split into InternalCustomer and ExternalCustomer and a decision is made to make Customer the base class and the other two children.  An accordingly correct decision is made to create two new tables in the database and have them have their corresponding fields.

Technically, or database script wise, this means
1) create two new tables
2) select data from the Customer table into the two child tables <- oops
3) drop some fields in the Customer table

Visual studio database edition can handle 1) and 3) but there is no way to tell it to run a custom script in between.

This unfortunately makes the product useless for me.

Which open source license to choose

February 20th, 2009

At the time of wrintig there are like 78 open source licenses to choose from. The original creator of the open source license idea has an argument that 3 or 4 should do.

So if you ever think of choosing a license for you work the linke below might a good place to start.

http://itmanagement.earthweb.com/osrc/article.php/3803101/Bruce-Perens-How-Many-Open-Source-Licenses-Do-You-Need.htm 

Update: A similar article is here.

>Annotate in TFS

February 4th, 2009

>

There is a somewhat hidden feature in Visual Studio TFS edition (or whatever it is called) for checking who changed a row.  It is called Annotate and can be reached through the context menu.  After some number crunching it gives you a semi graphic view of which row was edited by who.

Further Annotate can be done on other rows but not the same row again; I don’t know why.

>Change control name in Visual Studio

December 11th, 2008

>

VSNet remembers which attribute use used lastly so just start typing, there is no need to click.

Like so:
You layout a WinForm in Visual Studio.  Either when you are finished or as you layout the controls you name them.  There is no need to click and mark the Name attribute in the Atribute panel; VSNet remembers which attribute you typed last.

Example: Drop a label on the form.  Click the Name attribute.  Write the name.  Drop another label on the form.  Just start typing the new name without clicking anywhere.  What you type goes right into the right property.

Might save some time.

>Change window in Visual Studio

November 17th, 2008

>

Change window in Visual Studio 2008 through the shortcut ctrl-tab.  It goes through the windows in recent order so you get back to where you where.

If you want to get back to where you where in the same window use ctrl-minus.  Go forward again with ctrl-plus.
Note: for older versions of Visual Studio you have to have the US keyboard layout, the swedish does not work with ctrl-minus.

To show the open windows either use the Window menu (alt-w-w) or the “small window menu” dropdown ctrl-alt-down.

Open source – which licens to choose

November 1st, 2008

When you have decided that open sourcing your code would be a good idea the next question follows; which license?

Claes Mogren wrote a short and good description about some licenses and the thoughts behind them: http://informationhunger.blogspot.com/2008/10/open-source-license-primer.html

Update other articles are here and here.

>WPF and shortcuts

November 1st, 2008

>

Forcing the user to sprout a third arm to use a mouse is considered bad programming.

All menus should have shortcuts.  To be frank almost all controls should have shortcuts.  To use a few seconds to add shortcuts to the controls as they are made is considered good.

Shortcuts in WPF is done by prefixing with underscore, like E_xit and _Open. (WinForm is done by prefixing with ampersand, like E&xit.  Web applications should have this too and there it is called Accesskey.

Then to add the nice “Ctrl-O” text beside Open and “Ctrl-S” beside Save is trickier in WPF.  By no special order these are the pages I had to read to understand CommandBinding and RoutedUICommand:
http://anuraj.wordpress.com/2008/06/23/shortcuts-keys-in-wpf-menu/
http://en.csharp-online.net/WPF_Concepts—Built-In_Commands
http://colbycavin.spaces.live.com/blog/cns!5FFDF795EBC7BEDF!129.entry

>Retrieve the plain text from the RTF control in WPF

July 18th, 2008

>The rich text control in WPF is way more versatile than the Win32 one.
Versatility often means more complex and more complex means that the simpler things are sometimes lost. Like for instance retrieving the plain text from a RTF control.

It is not hard to do but I didn’t find any good example through google so here is an example of how to retrieve the plain text from a WPF rich text control:
    TextRange textrange = new TextRange(
        rtfControl.Document.ContentStart, rtfControl.Document.ContentEnd);
    string plainText = textrange.Text;

HTH

>Writing code or conducting it

July 7th, 2008

>

A friend of mine said something wise. A programmer’s job could be to conduct the code instead of writing it. Think of it like components that all handle their part very well and plays well together. The conductor is there to facilitate and point in the right direction. I believe he is on to something.