Tools I use

July 28th, 2009

Below are the tools, sites and stuff I use.  I plan to update it as it goes.

Correction: I planned but haven’t.

Also: I have a shorter and similarly not-propertly-updated list as a article here.

7-zip
http://www.7-zip.org/
Even though I have a Winzip license I haven’t bothered installing it for several years.  I guess Microsoft killed Winzip through having simple zip support out of the box and for all other needs there are 7-zip.
Open source.
Winzip deserves an extra mentioning though due to their license: your payment is also valid for all updates.  Many many other software companies have something to learn there.

Agent ransack
http://www.mythicsoft.com/agentransack/
The built in searching software in Windows XP and forward sucks big time.  To its defense I must say that it searches Microsoft office documents.  But since it doesn’t search all folders it is rendered useless for a developer like me.  Agent ransack searches fast, very fast, and has a simple regex tool to refine searches. One can limit files and folders searched in and search in system files too.

Update:
The built in search in Vista is weird. It might work for office people, you know the kind that really can’t tell the difference between windows, word, internet explorer and internet. This search was probably updated for Win7 and very much so for Win8. But Agent ransack still has its use for really doing searches in files with regex and stuff.

Autohotkey
http://www.autohotkey.com/
This open source solution is handy for global shortcuts.  I use it to set the size of windows to cover half the left, right, top or bottom.  I also send my windows between my monitors with a similar keystroke.  It has a wierd scripting language and some bugs regarding how big monitors and windows are.

Update:
Sending the windows around between two or more monitors is done win Vista and later with window-arrow keys.

Connectionstrings.com
http://connectionstrings.com/

In Windows one have to have a connection string to connect to a database.  These come in all colours and tastes.  This site has a comprehensive list.  Gratis.

Dpack
http://www.usysware.com/dpack/
It is an addin to Visual Studio.  Gratis.  A must-have if you develop in Visual studio.
The most used shortcuts, for me, are alt-u to open files and alt-m to go to a method.  With this there is no more searching for files in the solution explorer or scrolling up and down looking for the right method.

Update:
Open source.
I still use it since Visual studio 2013 still hasn’t caught up. Not even with Resharper.

Filezilla
http://filezilla-project.org/
Filezilla is a free FTP server and client.  I only use the client.  I cannot say if it is the best of its crop or has some whiz-bang stuff that oushines the competition but it is free and fairly simple to use.

Keepass
http://keepass.info/
I have lots of passwords and so do most of us.  Instead of having the same password for most places or a system of passwords, use unique ones; then you don’t have to worry about people getting your hotmail because they got hold of the passwords for a small site somewhere and successfullly try it on hotmail too.
I have the same database synchronized with my Windows mobile phone; this requires an older version of the software unfortunately, but I keep the passwords with me without the need of a computer.
It is open source so you can inspect the source code at will.

Media-convert.com
http://media-convert.com/
A gratis site for converting all sorts of formats, not only video and sound.

MyGeneration
http://www.mygenerationsoftware.com/
I am a sucker for not writing code I don’t have to.  Automatic code generation is the way to go.
Open source.

Update:
T4 is a tough competitor.

Notepad2
http://www.flos-freeware.ch/notepad2.html
http://code.kliu.org/misc/notepad2/
I don’t think Notepad2 is the best editor out there.  Not even close really.  But it makes it easy to exchange your Notepad.exe with the vastly superior and open source Notepad2.  Notetab does the same pre WinXP and possibly many other editors too but this is the only I have tried (post win2k) and I use it.

Update:
I have since switched to Notepad++. Before that I used Notetab.

NUnit
http://nunit.org/index.php
Automatic testing is considered good.  I might be too much to test everything but the important things and the difficult things are worth while to test automatically.
Open source.

NUnitEx
http://code.google.com/p/nunitex/
This open source extension lib to NUnit makes it more fluent to write assertions.  The best return of investment is when writing tests for exception throwing.

Opera
http://www.opera.com/
This is my primary web browser and has been since before 2000.  For certain development things Firefox is better and one must have Internet explorer around for about one site a year but for the other 8759 hours Opera is to prefer.Web browsers are a pain to user with the keyboard.  Opera lets you navigate between the controls with shift-arrows; so much easier debugging when one doesn’t have to grab for the mouse all the time.
Gratis.

Opera mobile
http://www.opera.com/mobile/
Arguably the best mobile browser for fat mobile phones.  It is gratis.
For smaller phones I would use Opera mini that renders the web page in a farm and then sends just the result.  It doesn’t work with javascript heavy sites though.
There is an application, Skyfire, that I believe works like Opera mini. Don’t mix up Opera mobile and Opera mini.

Update:
Other mobile browsers has caught up.
A couple of years ago I did a comparison and couldn’t spot a winner.
As of today I believe Firefox mobile is the only one that supports Ghostery so right now it is used as much as Opera.

Pastebin.com
http://pastebin.com/
If you ever have tried sending a snippet over email or especially chat you know bad how the layout gets scrambled.  Enter Pastebin.
Paste the code into Pastebin and send the unique URL.  It even has history so when chatting you can update the code and resend.
Gratis.
There are competitors but I havn’t found any as good.

PDFCreator
http://sourceforge.net/projects/pdfcreator/
To create PDF documents I use an open source solution.  It installs itself as a printer so it is usable for everything from everywhere.  For reading I use OpenOffice instead of the competitor-for-the-worst-software-written-ever program from Adobe themselves.

PowerCommand for Visual Studio 2008
http://code.msdn.microsoft.com/PowerCommands
Gratis.  Source code available but I don’t know if there are any strings attached.
It has Copy reference and Open folder and Open command prompt.  No more tedious searching for references or walking all over the hard drive to find the correct folder.

Spam gourmet
http://www.spamgourmet.com/
An online solution for one time email addresses.  Good for avoiding spam.  It is gratis but it sometimes takes a while for the emails to pass through.Approximately the same result can be gained by having a spare email account for this but Spam gourmet comes with a number-of-possible-sendings solution that might be handy.

VLC
http://www.videolan.org/vlc/
There are many media players.  VLC is one of them.  I use it since it takes most formats.
It went version 1 in 2009.
Open source.There is another well known application, Media player classic, that does approximately the same.  To be honest, I use both.

Winmerge
http://winmerge.org/
This is an open source diff tool.  It has a nice keyboard navigation, something that the diff program that comes with Visual studio has totally messed up.  None of these two have any knowledge about classes and methods so if you swap two methods it is recognized as add and delete instead of the move it really is.
Somewhere I found a program that can diff 3 files at once but the URL is since long forgotten.

NUnitEx

July 22nd, 2009

NUnitEx is an extension to NUnit.  It makes the assertions more of a flow to write.

Instead of writing

string myString = MyMethod();
Assert.AreEqual( "selfelected", myString );

one writes

string myString = MyMethod();
myString.Should().Be.EqualTo( "selfelected" );

A good thing with the former approach is that the coloured syntax makes it easier to distinquish method calls from assertions.

But when one tests exception throwing nunitex is the way to go.

Originally one had to write one method per call that threw an exception.  Even as a happy typist I think it was too much.  Nunitex easily handles exception throwing calls almost as ordinary calls.

See the example code at http://code.google.com/p/nunitex/ for yourself.

>Go to definition VBNet to C#

July 13th, 2009

>

In visual studio a very handy context menu item is the Go to definition item.  Position you caret on a metod call, open the context menu and choose “Go to definition”.  The caret is then positioned on the method.  Press ctrl-minus to go back again.

You cannot do this when a VBNet project calls a method i a C# dll.  The trick here is to instead choose Find all references and choose the correct result row.

Xml comment check

July 13th, 2009

In C#/VBNet there is a nifty thing called Xml comments.  I always use it to explain my methods and classes.  A good thing about Xml comments is that they pop up as intellisense.  Press ctrl-J in Visual studio at your method call and your comments are shown.  The comments survive project boundaries so your well crafted comments in the business layer pop up at the presentation method calls to aid the GUI programmers.

The comments don’t travel C#->VBNet though.

In VBNet you get squiggly lines when the method call and the Xml comment don’t match.  In C# you have to go through the Analyze->Run code analysis to get the differences.

There are more comments on commenting here and here.

Visual studio database edition – how to think to get started

July 13th, 2009

Visual studio database edition is part of the “normal” Visual studio.  One cannot be totally sure of this since Microsofts licences are as comprehensible as scientology.

I made two tries at it before I got it to work.  Then it failed me anyway, but that is another posting.

The way to think is to think about the database as source code.  You make changes, compare them to the checked in/commited code and let the machine do its magic merge and check in the result.

Note: it does not handle databases with data in them but truncates everything.  My presently preferred solution is 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.

>Slow sqlserver express

June 5th, 2009

>

I got informed of something somewhat strange the other day.  Microsoft SQLServer Express runs (connects) faster if you have a query window to the database already.

Like this:

Have a freshly booted machine with only Visual studio running and your web application of choice.  The time for a refresh of you web page might take 5 seconds.

Now start Management Studio and open a query window.  Let it stay open.
Refresh your page and you are down to a second.

The figures might of course change but they are what I have on a dual core 2GHz 4MB machine for a project of size X and database of size Y.

—-

I haven’t checked if the same thing happens with another script editor like for instance AnySQLMaestro but guess it does.  I guess it has to do with connections – as long as there is a connection to SQLExpress, it doesn’t close.  If so, it corresponds with the product’s raison d’être, a database for applications.

—-

I have noticed a correspondence between debug-start-delay and quality of code.  I say that every second wasted waiting on debug start makes the developer unwilling to test more thoroughly and leads to more bugs in the product.

—-

Another trick to make web debug start faster here.

categories: database, tip | no comments »

Timer and GUI

April 17th, 2009

One cannot use the System.Timers.Timer to update the GUI, instead one gets a cross-thread exception. The GUI can’t be updated from another thread.

A nice trick to solve this is to use a method that is sensitive for if the call comes from another thread than the GUI is running on.

   private delegate void SetTextDelegate(Label label, string text);

   private void SetText(Label label, string text)
   {
       if (this.InvokeRequired)
       {
           IAsyncResult res = BeginInvoke(new SetTextDelegate(SetText), label, text);
           EndInvoke(res);
       }
       label.Text = text;
   }

Honor those who should.

categories: code, tip | no comments »

Attach to a process even faster

April 11th, 2009

In an earlier article (or here) I mentioned a time saver for web projects where I recommended attaching to the process instead of restarting every time.

Today I invested time in creating a macro for attaching to the Nunit process.  It was easy.

– Instead of learning all commands just record a new macro (menu->tools->macro->record temporarymacro) and connect to the process of choice.

– Then open the macro explorer (menu->tools->menu->macro explorer) which opens a toolbox.  There is a (new) module called RecordingModule.  Open this.

A new IDE opens with something like:

  Sub AttachToNUnitProcess()      ' MsgBox("AttachToNUnitProcess.Start")      Try          Dim dbg2 As EnvDTE80.Debugger2 = DTE.Debugger          Dim trans As EnvDTE80.Transport = dbg2.Transports.Item("Default")          Dim dbgeng(1) As EnvDTE80.Engine          dbgeng(0) = trans.Engines.Item("Managed") ' Can be "Native".          Dim proc2 As EnvDTE80.Process2 = dbg2.GetProcesses(trans, "MDG-VILTERSTEN").Item("nunit.exe")          proc2.Attach2(dbgeng)      Catch ex As System.Exception          MsgBox(ex.Message)      End Try      ' MsgBox("AttachToNUnitProcess.Slut")  End Sub

– Testrun your macro in Visualstudio just to make sure it runs properly.

– In the macro editor, create a new Module and copy the code you just created.  Rename module and method.  Save.

– Back in Visualstudio, Macro explorer, your new module should be visible.  “Should” – one might have to restart Visualstudio or the toolbox or something.  It should be runnable directly from the Macro explorer toolbox.

– Create a new menu (menu->tools->customize …) and attach your macro.  You find it under “Categories/Macros”, just drag it to your new menu or the menu bar.

Now attaching to a process is just a click or keystroke away.

Some more info is found here: http://msdn.microsoft.com/en-us/library/hdf2d1z8(VS.80).aspx.

Update: I debugged a web app for a while yesterday and Wow! – what a difference between 3 clicks and 1 click, or 3 keystrokes and 1 keystroke.  Besides being simpler it also connected faster when the GUI didn’t have to render and didn’t have to wait for me.  Why haven’t I done this years ago?  What else is there I should have done years ago?

Update: I created a new menu and items for every macro I use.  So Fast to use!
There is something that bothers me though.  Some menus dissappear after I restart VSNet, I don’t know why.

The macros are easy to start also without having created a menu for them.  Just alt-F8 and then arrow keys to find the right macro and start it with return.

Update: If I only use 1 macro I can use “run last macro” with shift-ctrl-P.  I am using it right now because I am too lazy to create a new menu and stuff.

Macro for attaching to a process

April 11th, 2009

When debugging aspnet solutions a lot of time is wasted on restarting the debugged application.  A real time saver is to connect to the process to avoid restarting.

This is done like so:

– When a new bug is found don’t stop the web browser, instead detach from the process (menu->detach->detach all).
– Update the code to correct the bug.
– Set a breakpoint.
– Connect (menu->attach to process->[find the process, it is called something like iis or aspnet]->attach) to the process.
– Reload the web browser.

There are some caveats.  Like when using Webform the viewstate is tightly connected to the controls on the form so it is not always possible to connect.

But for the most times this is a great time saver.

—-

When you have done this a couple of times even this takes long time.  So fire up the macro recorder and do the recipe above.  Then run the temporary macro.  Running the macro is way faster than doing it manually.  I guess it is all the GUI stuff that takes time.
Or store the macro in VS and create a button and/or a shortcut.

—-

Update: use shift-ctrl-P to run last macro.  Nice if one is too lazy to create a menu.