Wednesday, February 18, 2009

Remote debugging

Yesterday I had quite a bit of fun trying to get remote debugging of a web application working.

I did solve this problem a little (very short) while ago… but I forgot what I had done.

So after executing a couple (quite a few) iterations of a Modify, Compile, Deploy, TryToDebug, Uninstall loop I know what you have to do to get it working. At least if you are using a deployment project to put the files up on the server.

You have to add the debug output from any project that you want to debug into to the deployment project*.

You must make sure that those debug outputs are in the right directory in the File System configuration pane so that the TargetName will have the files going into the correct directory on the server**.

Then you can install and debug. The setup of the remote debugger is a bit complex too. Basically the way I got it to work was by adding my own domain user (I log into my machine by logging into the domain) to the Administrators group on the server, and then logged in (via mstsc /console) to the server as myself (so that user could reconnect back to my machine). Bingo.


* You can’t just copy them up to the server it seems. I don’t know what the difference is, but it just does not manage to find them. I have even tried loading the symbols from the modules window directly – if complains that the symbols are not for the same version of the dll. I have not seen what happens if you are not actually deploying with an msi – there could be trouble. It is just one of those cases where there is some mechanism there that is storing some information somewhere and when it works everything is rosy, but when it does not work it can be fairly opaque. I guess that is what comes from not technically knowing what you are doing, but we can’t all be experts on the internal workings of everything – there is just not time, and when most of the time it just automagically works there is not much point either.

** The target name for the debug output of some project types (e.g. ASP.Net Web Application) will be bin/AssemblyName.pdb so the output needs to be placed in the Web Application Folder (where they seem to go by default), whereas other types (e.g. Class Library) will just be AssemblyName.pdb so their output needs to be put into the bin folder – they won’t be there by default, they will be one level up in the Web Application Folder. If you do not get this right the debug symbols will fail to load. You can look at information about what is being loaded from where in the Modules window found in Debug > Windows > Modules when you are in debug mode.

Tuesday, February 17, 2009

Lotsa windows

I just had a weird occurrence… I was in gmail, clicked to archive a message, and it started to open a bunch of new windows with one certain address:
http://mail.google.com/mail/#..&remote_iframe_0@2&1&0&%7B%22s%22%3A%22resize_iframe%22%2C%22f%22%3A%22remote_iframe_0%22%2C%22c%22%3A0%2C%22a%22%3A%5B199%5D%2C%22t%22%3A%22r0rtgf-lsmnyy%22%7D

It got to about 20 or so before I managed to kill it with taskman.

Monday, February 16, 2009

Security.dll

I was getting a funky error when trying to call one of my WCF web service’s methods:

Unable to find an entry point named 'FreeCredentialsHandle' in DLL 'security.Dll'.

Fortunately my brain is working this morning and I remembered the last time I saw this kind of odd error. Looking in the bin directory of the web site, sure enough I see a dll called security.dll. Ruhroh… IIS kindly loads up any dlls that you ask it to, then when it tries to access the Microsoft Security.dll it seems to find your dll and routes calls into it. These entry points (normally) don’t exist hence the error.

The moral of the story is: Do not call your dll security.dll*.

I just went through the whole project and made sure that the outputs were called something useful like Company.Project.Thing.dll. You do need to restart the web server too so it will reload the (correct) Security.dll.


* Other bad names are probably things like System.dll, mscorlib.dll etc. A much better idea is to create a proper namespace for your code and make the assembly name something like the namespace – or even the whole namespace, why not? Knock yourself out.

Sunday, February 15, 2009

Reuse types in a Web Service

For some time I have trying, with no success, to get the Reuse types in referenced assemblies option to work after adding a web service reference to a project.

Finally I have found the answer: That option is not available for so called ‘legacy’ ASP.NET web services, only for WCF web services. So I just re-created my web service as a WCF service. My web service is a pretty simple one providing access to a .NET Remoting server hosted in a windows service. As such the code is pretty simple, and it was a matter of less than an hour to get it all going.

Just one small gotcha that I guess should be pretty obvious. The assembly with the types that you want to re-use must already be referenced in the project that you are adding the service reference to. I.e. it does not go and look for them. I don’t suppose it would have any way of doing that.

The only modification that I had to do was to the web service. It seems to work. I am a little surprised that I did not have to add the DataContractAttribute to the classes to use them… They are already marked Serializable and the members are XmlElements… perhaps that is why it works. I have not really tested it yet, just compiled the service and the client. I am thinking now that perhaps the data is not being passed at all. Will see tomorrow – when I am supposed to be working (rather than now, the weekend).


[Edit] I does work just fine. I wonder then what is the difference between using DataContract and just making them Serializable. I also wonder what is the benefit of using the ClientFactory rather than just using the Client object directly.


[Edit] There are, it seems, times when you do need to add the DataContractAttribute to your data classes. I just found that one class that I was using as a parameter caused an exception upon serialization:

There was an error while trying to serialize parameter http://tempuri.org/:Commands. The InnerException message was 'Type 'BSPG.Prism.Script.Table' with data contract name 'Table:http://schemas.datacontract.org/2004/07/BSPG.Prism.Script' is not expected. Add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

This class contains members whose type is also not a standard class. The class that was working only had members of standard types. Fortunately, it seems to work if you just decorate the top level class with the DataContractAttribute – no need to go and change each other class in there (this would have been quite a pain for me, as they are all generated classes). That said, it might turn out that it only works because after the first level they are all standard types… That is not necessarily true for all possible data though – this is a class hierarchy created by XSDObjectGen from a quite deeply nested DOM… We will see.

Saturday, February 14, 2009

Batteries

The battery meter on my laptop is playing up.

It seems to think the battery is always at 100%. The hours remaining displayed changed, and seems to be about correct, but the percentage is always at 100%. I am guessing that that is why it keeps shutting off with no warning. Hrm.

I had other stuff to post, but I am at 100% (18 minutes) so I butter go plug in.

Wednesday, February 11, 2009

Merging Help files

This may take several minutes...

Boy you are not kidding… Why does this always take so long? And why can’t you do it in the background? I don’t need the help right now, but I would like to do something else with my machine.

Changing the console font

You can add new fonts to the list available in the cmd.exe preferences screen.

First you want to find a good mono-spaced font like Consolas and install it.

Then you need to add a new String Value to the registry under HKLM\Software\Microsoft\WindowsNT\CurrentVersion\Console\TrueTypeFont called 00* with a value of the exact font name (eg Consolas)

Something needs to happen before the font can be used, I am not sure what, but a reboot achieves it (logoff does not), so a reboot is next.

Finally, you can pop open a command prompt and change the preferences to use the new font. You might need to do this a couple of times if you use different ways of getting up a command prompt: the run command, the shortcut in accessories, or a shell extension - because of the way the system applies the preferences according to window title and not the actual executable.


* the default TrueType font is specified by 0, so the next needs to be 00, if you want to add another you can add 000 etc.

AdSense JScript error

I don’t know wether it is just IE7 or what but I do seem to be getting a lot of JScript runtime errors on lots of different sites… I have opened a few in the debugger and found them to be, for the most part strangely, coming from within jQuery…

Now the AdSense stuff on this blog has started to have an error:

The bit where it barfs is:

<script>tick('1ad')</script>

with:

Object expected

so meh, not finding the tick function. I have not changed anything, but I am beginning to wonder if it is not something that I have done to this machine. Perhaps I am just paranoid, but I do seem pretty capable of some kind of voodoo against windows installations…


[Edit] S’not just me - there are some posts on the AdSense Help forum (which has a JScript error, haha) about this already (Recent Javascript Errors in Ads, Javascript errors, JavaScript error <script>tick('1ad')</script>) but no response from Google so far...


[Edit] Silently fixed by Google. I did not keep a copy of the offending source file from this morning, but looking at the same file generated just now, they seem to have totally removed the call to tick. That function by the way ends up injected into your main page and seems to be for storing timestamps for certain actions like the first load, the first time the page is scrolled, the load time of each ad etc.) Poor form really… perhaps an explanation will surface soon.

Tuesday, February 10, 2009

Multiple selection

I was watching someone the other day trying to select a number of different files from a directory to copy somewhere else. She had about four goes at it, control clicking on each file she wanted, skipping over the ones she didn’t, then accidentally clicking without holding control somewhere and undoing all of her selections, before she gave up and copied them one at a time.

Just now I was trying to move some gmail ‘suggested contacts’ to ‘my contacts’. I had never used that interface before, but I don’t like it. You select each contact by checking its checkbox, but for some odd reason they have made clicking on the name of the contact select the checkbox also – and unfortunately deselect all of the other ones! The nice thing, usually, about a list of checkboxes is that they avoid the accidental de-selection that is so easy with the control click way of doing things…

This all has just reminded me that it would be nice to have an explorer extension that made selecting multiple files more forgiving. Maybe by altering the selected state in a more robust way. You could do undo and redo of selection, you could do add to and subtract from selection, you could keep selections or save and re-load them… you could make it usable. As it is, it is just about inevitable that someone not hugely skilled with the mouse will loose all of their selections if they are trying to select a non-trivial number of files together.

SQLServer 2005

Having failed to install SQLServer 2008 – don’t ask, I grabbed the 2005 dvd and ‘installed’ it… But the server setup could not find any of the client msi files. I looked at the directory structure on the disk and where they used to have Server and Client directories, there are now Server and Tools. I am not sure if that is the problem but I went into the Tools directory and ran the setup there. It got some way through its install, but still could not find the msi for the native client, and the ‘workstation, books online and development tools’ installer would not run. So I went spelunking in the \Tools\Setup directory and ran a few msi files by hand and now it seems to be happy.

Yay, I have my SQL Server Management Studio!

The msi installers that actually managed to do something were: \Tools\Setup\sqlncli.msi and \Tools\Setup\SqlRun_Tools.msi though there may be other stuff missing… we will see.

TortoiseSVN right drag

I did not know this: http://tortoisesvn.net/most-forgotten-feature

SVN global ignore pattern

I have just been fiddling with my global ignore pattern so I thought I would post it here (more for my future self than anything else). This modification was triggered by my having fun trying to use the same repo from two different machines where the directory structure is not identical, so the *.suo files and *.user files can cause problems. I also noticed that there were a few other odd files in the repo that I don’t really want.

[Bb]in [Oo]bj Debug Release *.suo *.user _UpgradeReport_Files UpgradeLog.XML RECYCLER Thumbs.db Desktop.ini

So a little explanation:

  • [Bb]in [Oo]bj – directories containing build files generated by studio, seems like older versions of studio create the files in all lowercase where 2008 has an initial cap and as SVN is case sensitive you unfortunately need to deal with both
  • Debug Release – directories created when building a deployment project
  • *.suo *.user – user project setting and general studio user settings files
  • _UpgradeReport_Files_ – directory containing log files and stuff created when you migrate a project from an older version of studio
  • UpgradeLog.XML – the main project migration report file
  • RECYCLER – not sure if this is still needed, but I was finding this directory sometimes gets created, I guess it is for storing deleted files… was just searching for it in the repo local copy but could not find it, oh well
  • Thumbs.db Desktop.ini – files created when you do certain things in explorer, like look at a directory of images in thumbnail view

Monday, February 09, 2009

Office Live

I have a new install of Microsoft Office Word 2007 with the Office Live plug-in installed. The Office live splash screen comes up and I was having trouble configuring it – it could not seem to deal with my Live account that had a Gmail address… anyway, that is sorted now (though all my cookies are gone in the process), but the splash screen still comes up each time. I thought it was because the sign-in process was failing, but I am all set up now and it is still showing up every time I open word.

Fortunately I have found the solution on TechNet: Get Started with Office Live.

The workaround is to create a registry key called OfficeLive under the key HKEY_CURRENT_USER\Software\Microsoft.

Group policy

I hate that the group policies specified for our domain accounts have the Internet Explorer home page locked down, and the web proxy enabled. Those settings though are just registry entries, and as there is no inherent security on registry editing, you can just go back in and edit them after login.

After some time interval though I have noticed that there must be a gpupdate or something that resets the keys to the values defined by the policy. I just wrote a quick VBScript to ensure that my preferred settings are made after login.

Set shell = WScript.CreateObject("WScript.Shell")
 
shell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Start Page", "http://www.google.com.au", "REG_SZ"
shell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Default_Page_URL", "http://www.google.com.au", "REG_SZ"
shell.RegWrite "HKCU\Software\Microsoft\Internet Explorer\Main\Search Bar", "http://www.google.com.au", "REG_SZ"
shell.RegWrite "HKCU\Software\Microsoft\Windows\CurrentVersion\Internet Settings\ProxyEnable", 0, "REG_DWORD"

Most of the time when I pop open IE it is to go to Google. Plus the group policy had some stupid HP news site specified, and several times over the last week their first displayed news story was some model in a state of partial undress – difficult it is when the company policy enforces a breach of company policy…

Sunday, February 08, 2009

WLW Plug-in

I just finished working on a Windows Live Writer plug-in to allow insertion of snippets. You can define templates for snippets that you can then insert into the current document from the Insert list. The snippets can be anything basically, but I will be using it to insert HTML snippets of the right format to make error message blocks, command line blocks, basically all of the little bits of mark-up that I want to re-use all of the time.

To create a new template you access the options dialog via Tools > Options > Plug-ins where you select the Snippet plug-in and click Options.

You can insert the currently selected text or the clipboard contents into the template by specifying #content# or #clipboard# somewhere in the template. You can also take the content or the clipboard if the content is blank with #contentorclipboard# or the reverse with #clipboardorcontent#.

There is no documentation (other than the info here), no installer (you just need to copy the dll file to C:\Program Files\Windows Live\Writer\Plugins), and not too many features. So hopefully not too many bugs. There are a few things that I would like to work on: A context menu to select the #content# things; Pretty up the interface a bit; Add a different mode that can ask for user input to fill in the template; An installer.

I created a Google Code project for this one too, it is wlwsnippetplugin. I think that I have put the source up properly in the SVN repository… Regardless, the source is zipped there too, as is the SnippetPlugin.dll file that you can just grab and copy to the right directory.

Enjoy!

Mark-up cleanup

I have just spent some hours going through all of my old posts and editing them in WLW to get all the mark-up nice and neat and how Blogger and WLW likes it.

I have put everything in p tags, removed all of the display oriented tags (fonts, inline classes), and fixed up the code and error message and command text blocks that I had. I think I fixed most of the quote marks and apostrophes too - mainly because WLW does it automatically and they do look pretty neat.

I guess that is all a bit anal, but I do feel clean now.

Friday, February 06, 2009

Erm… ForEach

Why did I not see this before? I was pretty sure that I looked for a ForEach function before I went off looking for Map etc… but bugger me if there isn’t an extension method on IEnumerable(Of T) that does just exactly what I want.

It’s even called ForEach!

List<thing> myList = new List<thing>();
myList.ForEach(item => item.DoSomething());

[Edit] Okay, I feel a little better now… I know why I didn’t see it before - ForEach is defined on List(Of T) and not, unfortunately, on IEnumerable(Of T) which is where I was looking for it. Perhaps next week in a spare moment I might get to try my hand at writing it.

Select method problems…

An issue that I have run into using Select as Map HOF.

The Select function is only evaluated when the returned Enumerable(Of T) is evaluated. That means that the code that I posted (which I did not test until now…) does not really do anything. I guess that means that the foreach method is probably the way to go for calling a function for each item in a list.

Thinking about this, and re-reading some information about the Map function, I come to the realisation that it is perhaps my understanding of what Map is supposed to do that is incorrect. It does say that map is for transforming the items. Perhaps what I want is another, slightly different HOF that is for operating on a list of items, i.e. calling a function for each of them, rather than for building a second list. Oh I don’t know, I will keep looking.

Windows Live Writer first paragraph problem

I was having trouble with WLW messing up the mark-up for the first paragraph when I start a new blog entry.

Once I had typed the first paragraph then pressed enter, rather than starting a new paragraph tag after the first, it inserted a new one in the first one before the text. After that the paragraphs come up in pretty much the right order, but the nesting is all wrong and not at all what you would want.

Here is an example of the mess that it manages:

<p>
  <p>Second paragraph.</p>
 
  <p></p>
Third paragraph.
 
  <p>First paragraph.</p></p>

What you want really is this:

<p>First paragraph.</p>
 
<p></p>
 
<p>Second paragraph.</p>
 
<p></p>
 
<p>Third paragraph.</p>

I have finally worked out what was causing this. It was the fact that I was clicking in the edit area before typing! So if you edit the title, you need to NOT click in the post body area, you can just hit Enter after you are done with the title and it seems to work.

Unfortunately, clicking will have bad effects on the mark-up whenever you do it in a blank area… You need to be clicking in an existing paragraph or else it seems to get a bit stuffed up. I am still trying to work out exactly which action causes which problems and hot to possibly avoid them. One is to paste in the html for a paragraph with some text in it rather than clicking at the end of a post to add a new paragraph. This is a beta product though so I guess one is meant to deal with quirkiness.

Another related note: you really have to hit Enter at the end of a paragraph, even the last one. If you don’t you can end up with:

<p>Paragraph 1.</p>
 
<p></p>
Paragraph 2.
 

I like WLW. I am sure there is not much more to go before it is kind to your mark-up. The sad thing is that this kind of stuff is probably not that important to a lot of people.

Thursday, February 05, 2009

foreach to LINQ to HOF progression

Three stages of a real world example.

protected virtual string ReplaceFunctions(string messageTemplate) {
    string messageBody = messageTemplate;
    Regex ex = new Regex(@"\$(?<name>[^\$]+)\$");
    MatchCollection functions = ex.Matches(messageTemplate);
 
    foreach(Match function in functions) {
        if(function.Groups["name"].Success) {
            messageBody = messageBody.Replace(string.Format("${0}$", function.Groups["name"].Value), "");
        }
    }
    return messageBody;
}

protected virtual string ReplaceFunctions(string messageTemplate) {
    string messageBody = messageTemplate;
    Regex ex = new Regex(@"\$(?<name>[^\$]+)\$");
    MatchCollection functions = ex.Matches(messageTemplate);
 
    foreach(var function in (from Match f in functions where f.Groups["name"].Success select f)) {
        messageBody = messageBody.Replace(string.Format("${0}$", function.Groups["name"].Value), "");
    }
 
    return messageBody;
}

protected virtual string ReplaceFunctions(string messageTemplate) {
    string messageBody = messageTemplate;
    Regex ex = new Regex(@"\$(?<name>[^\$]+)\$");
    MatchCollection functions = ex.Matches(messageTemplate);
 
    functions.OfType<Match>().Where(function => function.Groups["name"].Success).Select(function => messageBody.Replace(string.Format("${0}$", function.Groups["name"].Value), ""));
    
    return messageBody;
}

C# Map HOF goodness

The Map higher order function is provided in C# as the Select extension method.

So to cover the last step that I was going on about this morning, i.e. to transform this:

foreach(var field in (from field in TheForm.Fields where field.Disabled select field)) {
    field.DoSomething();
}

We can use method syntax (fluent) rather than query syntax to give the one liner:

TheForm.Fields.Where(field => field.Disabled).Select(field => field.DoSomething());

Neato!

Incidentally though, this seems to only work when DoSomething returns a non void. For example, if you try to compile:

TheForm.Fields.Where(field => field.Disabled).Select(field => Console.WriteLine(field.Name));

You will get an error:

The type arguments for method 'System.Linq.Enumerable.Select<TSource,TResult>(System.Collections.Generic.IEnumerable<TSource>, System.Func<TSource,TResult>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

This is pretty easy to fix though by changing the expression lambda to a statement lambda:

TheForm.Fields.Where(field => field.Disabled).Select(field => { Console.WriteLine(field.Name); return true; });

Windows Live Writer and Blogger formatting

I think I have it worked out.

There is a Blogger setting that stuffs up edits done with Live Writer. Settings > Formatting > Convert line breaks needs to be set to No. Then you don’t seem to get the double line spacing.

The trick with WLW seems to be to let it put in paragraph tags and to never ever edit the post in blogger. Or at least to never switch between the blogger html editor and the compose editor – that really screws things up.

In the end, WLW is still in beta so there are issues. Undo does not do what I would expect. You can’t just type away and press enter to get a new paragraph… Seems like for the first paragraph you have to hit enter then the down arrow otherwise the insertion point is above the first paragraph container. Odd.

I will just resign myself to being careful with the editor, then being prepared to fix the mark-up by hand.

The CodeSnippet pug-in works best if you do not embed the styles but copy them to your template to be re-used. That is how I wanted to do it anyway. Here is a little code snippet:

// Check for required fields
foreach(var f in from f in TheForm.Fields
                 where f.RequiredForEmail
                 select f) {
    prop = requestType.GetProperty(f.Name);
    if(prop == null || prop.GetValue(data, null).IsBlank()) {
        Ok = false;
        break;
    }
}

Query pattern problem

I have been getting this error with some LINQ expressions:

Could not find an implementation of the query pattern for source type 'System.Text.RegularExpressions.MatchCollection'. 'Where' not found. Consider explicitly specifying the type of the range variable 'v'

You get this error because MatchCollection implements only IEnumerable and not IEnumerable(Of T) All you need to do is change:

from v in ex.Matches(template)

to:

from Match v in ex.Matches(template)

I.e. do what it says and specify the type of the range variable.

CodeSnippet plug-in

Dammit. Those code snippets look so nice in Live Writer… grr. They get all sorts of horrible linebreaks and the formatting does not work at all. Work dammit!

Explorer:

Live Writer:

Grumble.

LINQ expression syntax

I have been recently starting to use LINQ expression syntax a little more. One refactoring that I have been doing is changing things like:

foreach(SomeItem item in items) {
    if(item.SomeProperty == someValue) {
        item.DoSomething();
    }
}

into the slightly nicer:

foreach(var item in (from i in items
                     where i.SomeProperty == someValue
                     select i)) {
    item.DoSomething();
}

… My only hesitation is the nastiness of the syntax (if you try to get it inline with no extra variable definitions – yes I know the extra parentheses are not required, but I find var item in from i in items to be very unreadable, plus I am often adding method syntax to these things at a later stage)… Some syntactic sugar might be nice to get:

foreach(var item from items                                      
                 where item.SomeProperty == someValue                 
                 select item) {
    item.DoSomething();
}

There is probably also a higher order function way to do this for simple cases of just calling one function on each match, but most of the time the code is not as simple as a single method call. Ideally I would love to do something like:

(from i in items where i.SomeProperty == someValue select i).Map(DoSomething);

P.S. Do not like the new Windows Live Writer editor. I just want an editor that makes it easy to create nice neat mark-up! Why is it so difficult to NOT put in paragraphs and other containers that I don’t need? And why can’t I see them in edit mode? And why do I drop out of the edit container and then have the backspace key delete the whole container?

Friday, January 30, 2009

WindowsUpdate

Installing Studio and stuff on my new desktop (laptop is almost officially dead) I was having a problem with Microsoft Update...

The website has encountered a problem and cannot display the page you are trying to view. The options provided below might help you solve the problem.

The error code is 0x8007000B. Looking in the WindowsUpdate.log shows:

WARNING: DownloadFileInternal failed for http://download.windowsupdate.com/v8/windowsupdate/b/selfupdate/WSUS3/x86/Other/wsus3setup.cab: error 0x8007000b

So I tried to download that file in ie and get:

Access to http://download.windowsupdate.com/v8/windowsupdate/b/selfupdate/WSUS3/x86/Other/wsus3setup.cab has been blocked by WebMarshal

Ah ha!

(P.S. I don't remember the blogger editor being this bad... the format of this post is terrible right now.)

[Edit] Formatting maybe fixed...

Thursday, January 29, 2009

Lambda expressions

I just used a lambda expression for the first time. They are neat!

Friday, January 02, 2009

Gunner gunner

I was going to write about some things that I am going to do this year... but I think that kind of thing might be part of the problem... Gonna neva duzzit. So I'm not gonna right nuffink.

I will say though that I have changed something. As in already, it is done. Not going to be done, not only started, but done. I changed the template. They all pretty much suck though so I am going to... no wait. Scratch that. Let's leave it at they suck.

I realise that I have now screwed up the code snippet thingy but too bad. I just wanted a change. What do I need to look for in a template?

  • Quote callouts must look nice
  • Code samples
  • Picture and Video posts must look nice
  • Simple, block oriented
  • Should use my own images not generic ones

Wednesday, August 27, 2008

Why do we not have...

A spell checker that can be run on an entire studio solution, that checks all strings, all mark-up, basically any plain text for spelling errors.

The Code Analysis stuff can now check identifiers which is nice, but why are we still lacking a feature that has been in Word forever.

Wednesday, August 20, 2008

Debugger side effects FTW

Trying to (quickly) get my generated form site working in Firefox...

The first problem was that getElementById was returning null when the client side validation function was firing. A quick look at the source and I see that the Name attribute is set but not the Id on the control that I a looking for. IE "copes" by looking at the Name if the Id is not there, Firefox though "follows the standard". Ok, so why is ASP.Net not generating an Id?

Due to time constraints I tried setting the Id when I create the control, but though it looks fine in the source and the validation works, now I don't get any data in the Text member after postback? Huh? I guess that ASP does not like it when it does not generate the Id, probably have to munge the ViewState to store my Id... No thanks.

So I am just playing in the debugger, trying to see what is populated after adding the control, maybe I can set the Id to be the same as the genereated Name... I add a watch for Control.ID, it's null, then I add a Watch for Control.ClientID, its "ctrl09", now if I just set the contr... wait a second, what?... the watch item for Control.ID just got updated with a value.

Accessing Control.ClientID causes Control.ID to be populated.

I look in the source, sure enough, for the control that I frigged with, the Id is defined. I add this after adding the control to the page:

   1: f.Control.ID = f.Control.ClientID;

And we still let ASP choose the value of the ClientId and hence the Name, but trick it into populating the Id also. (Which I really think that it should anyway...) The assignment is really only for clarity, as this works just as well:

   1: string MicrosoftIsTehSuck = f.Control.ClientID;

Which at least puts a little smile on my face...

Saturday, August 16, 2008

Windows Live Writer

I finally got it set up. A big Fuck(*) You Very Much goes out to whomever wrote the automatic configuration part. Use the damn default web browser to go get your pages, not Internet Explorer! Why would you hard code it to use Explorer? My explorer is configured to only work when I am connected to the VPN and hen only for internal addresses! I had to go change the proxy configuration (after I worked out why it wouldn't work)... Now I just wonder if other parts of Live Writer do this and get upset every time I reboot and reset the proxy configuration? Stupid.

Anyway, looks nice enough.

Where do the drafts go? ... Only local looks like for Blogger, the publish draft is greyed out.

Apparently, by installing a little code snippet (... painless) one can post neat looking code samples:

   1: <controls:PathDuplicator>
   2:     <controls:PathDuplicator.ItemStyle>
   3:         <Style TargetType="controls:Item">
   4:             <Setter Property="Template">
   5:                 <Setter.Value>
   6:                     <ControlTemplate TargetType="controls:Item">
   7:                         <Grid x:Name="RootElement" Height="100" HorizontalAlignment="Left" VerticalAlignment="Top" Width="100" RenderTransformOrigin="0.8,0.8">
   8:                             <Path Margin="18,9.36900043487549,37.2080001831055,27.5090007781982" Data="M50,14 C42.942787,12.875842 37.481071,3.0378544 31,16 C29.399416,19.201166 27,22.378658 27,26 C27,31.253759 25.183334,31 34,31 C35.521332,26.436005 38.284637,24.241812 43,21 C49.555965,16.492775 47.970417,15.455626 55,26 C63.315838,38.473759 64.010223,47.474442 57,65 C55.737644,68.155891 49.410244,76.01281 43,68 C37.249264,60.811581 38.936535,57.9706 36,50 C34.534855,46.023182 28.36919,45.217796 23,51 C17.748837,56.655098 20.123365,57.791729 18,65" Fill="#00FFFFFF" Stretch="Fill" Stroke="#FF000000"  RenderTransformOrigin="0.8,0.8"/>
   9:                         </Grid>
  10:                     </ControlTemplate>
  11:                 </Setter.Value>
  12:             </Setter>
  13:         </Style>
  14:     </controls:PathDuplicator.ItemStyle>
  15: </controls:PathDuplicator>

Hrm. How does one modify the styleses? I guess if I go put them in the configuration of the blog that is easy enough. Would be nice to see the actual styles in the plugin though. Nevermind! Also, the view HTML thingy in the plugin does not show the correct html if you select not to embed the styles, it still shows only the html with the styles embedded. Also also, why not define the styles inline as actual styles rather than setting the style property of each element... just saying.

After stylish modification:

   1: public override void OnApplyTemplate() {
   2:     base.OnApplyTemplate();
   3:  
   4:     RootElement = (Panel)GetTemplateChild("RootElement");
   5:  
   6:     // Just make some transformation adjustments
   7:     for(int i = 0; i < 10; i++) {
   8:         Item item = new Item();
   9:  
  10:         #region Silly Stuff
  11:         item.Style = ItemStyle;
  12:         item.Angle = 10 * i;
  13:         #endregion
  14:  
  15:         RootElement.Children.Add(item);
  16:     }
  17: }

Well, wow. Now if only I could get Studio to do alternate line colouring... Can you do that? :) I guess I would also like to see the plugin support more of the Studio display items. But it looks pretty close to how it looks with my settings.

I guess I just need to find out when it uses each of the styles... and go create the styles for each type of code snippet...

Joy!

(*) Fuck is not in the dictionary... well now it fucking(**) is!

(**) So is that :)

[Edit] Not joy! Unjoy! What is with the 3 line spacing in the code samples?! Grumble... In fact, what is with the massive amounts of extra space all over the place. Grr.

[Edit] Fixed spacing. WLW editing still a bit dodgy, but it is easily fixable in the source edit view. Can't way that I could recommend it to anyone that does not know html – i.e. 90% of people who want to blog and would love a real WYSIMYG editor... Mind you those kind of people probably would not really care about how their markup looks - which incidentally makes it all the more vital to help them produce good markup.

Friday, August 15, 2008

Magic mystery fields

[Just found this draft post that I was waiting to post for some reason... it is from the middle of last year. Almost just a rant but I typed it up so I may as well post it.]

Liaising with customers, particularly ones who are managers of their company - highly experienced in their own field, though not in IT - can sometime suck.

I constantly find myself having to explain in detail why something cannot work that exact way or why something is a problem that needs to be worked through. Their opinion seems often to be that I don't want to do it or that I say it can't be done because I don't know how. Usually it seems to stem from the problem of what is easy for humans, or obvious to us on paper is not something that the computer can do or represents some information that the system does not have.

An example from today: Employees have 4 digit employee numbers, their cards have a single digit issue number that is used after their first replacement. When they lose their card again and get a new one the issue number increments. So employee 1234's first card is 1234, their second is 12341, third is 12342 etc. (Whoever thought this kind of arrangement was a good idea needs their fingers broken.)

There are two problems that I tried to broach today (right now, before they break the system). There will soon be the need for 5 digit employee numbers (we are up to like 8500), there seem to be some people with more than 9 cards (21, 51!). The system (of course, as it stands) cannot tell the difference between employee 10001 and the second card of employee number 1000 (also 10001). The second card of employee 10001 (100011) and the 12th card of employee 1000 etc.

Trying to explain that the system cannot just take off the last 2 numbers when the person has had more than 10 cards and take of the last 1 number otherwise, did get a little frustrating. Basically when there are 2 dynamic length fields in a composite id, without any other information it is not possible to reliably extract them.

Friday, July 11, 2008

AjaxControlLibrary

So it takes a little dicking around to do it, but you can use the DropShadowExtender with the ModalPopupExtender.

I had a little problem getting it to work some time ago, then when I noticed the DropShadow attribute on the popup class I thought that there must have been a problem with using them together so I just used the internal drop shadow. Well, after finding a couple of other issues with the DropShadow attribute, and finding no way to specify opacity or rounded corners, I went back to trying the two extenders together. The solution makes sense in the end I guess. You just need to put the drop shadow on an element inside the one that has the popup, not on the same panel.

An example should be fairly clear:

<asp:Panel ID="pExecuteProgress" runat="server" style="display:none;">
    <asp:Panel ID="pExecuteProgressContent" runat="server" CssClass="ExecuteProgress">
        <div>Processing...</div>
        <div><img alt="..." src="images/status_anim.gif" /></div>
    </asp:Panel>
    <cc1:DropShadowExtender ID="DropShadowExtender1" runat="server" TargetControlID="pExecuteProgressContent" TrackPosition="true" Opacity="0.3" Width="8" />
</asp:Panel>
<cc1:ModalPopupExtender ID="mpeExecuteProgress" runat="server" PopupControlID="pExecuteProgress" TargetControlID="pExecuteProgress" BehaviorID="ExecuteProgress" BackgroundCssClass="ModalBackground">
</cc1:ModalPopupExtender>
A couple of notes about this example:
  • I have specified the same control for the TargetControlID - it has to be non null, but I am showing this popup only via JS
  • The display:none on the outer panel is to prevent the flashing of the control on page load that you can sometimes get

Just for interest sake, here are the two css classes mentioned:

.ExecuteProgress {
  border: 1px solid #000000;
  background-color: #FFFFFF;
  padding: 30px 80px 30px 80px;
  font-family: Arial;
  font-size: large;
  color: #3366FF;
}
 
.ModalBackground {
  background-color: #C0C0C0;
  filter: alpha(opacity=70);
  opacity: 0.7;
}

I gotta find a better way to post code... I just used an online encoder to HTMLEncode the text, then it is just in a <pre> *sigh*

[Edit] Code posting fixed.

Sunday, May 18, 2008

One bad apple?

It's funny, just about every website you go to sign up on that wants your email address gives you those TWO boxes to fill in. Email and Verify Email. I don't who started this, or why everyone thinks they should follow, but I wish it would stop.

I understand where this malady came from: it was some smart web monkey seeing the Password and Validate Password combo and adopting it. But I don't think they quite understood why this mechanism is needed in that case. Just to be explicit - it is only needed because you can't read what you just typed in in the Password box. For the email address, I can re-read that just fine thanks.

Besides, I figure if you can't either type in your correct email address, or read that is not correct and correct it, then you failed my minimum user requirements. There is a certain limit to how far you need to go holding people's hands.

Wednesday, March 19, 2008

TortoiseSVN

The global ignore pattern that I am using at the moment is:

*bin *obj RECYCLER thumbs.db *Debug *Release

Which is probably fine for a single developer. When working in a team you would probably want to block *.suo also.

Wednesday, November 28, 2007

The tale of Mister Splashy Pants

Online polling is broken.

With sites like digg and reddit and many others, the ease with which a group of people can sway the vote is demonstrated time and again. The problem is differentiating “real” voters from “funny” voters. It is just too easy for someone to give a voting link to a large number of people who are not really interested in the outcome of the poll, who will totally unbalance the results.

Perhaps what online polls need is to use some of the mechanics of regular political voting systems. An electoral roll with a defined closing date that is before polling commences. No need to keep voter information long term, just long enough to have the people interested in a certain poll indicate their participation, and ensure that there are no band-wagon jumpers at the last minute. An online news site post saying “Quick, register to vote on the name of the Greenpeace whale - there is sure to be a funny option: we will let you know which option we think is the funniest in a few days!” is not likely to attract the same level of attention.

Wednesday, November 07, 2007

‘S not my job.

“It's not my responsibility to fix that” or “I did not think I had the authority to ask for a certain action” You have to ask yourself a question. Am I happy with my current position in the hierarchy? If you want advancement, more responsibility, one way to get it is to assume it. Take on new roles and new responsibilities and they will become yours. That or you will be put in your place. (It may be time to move on.)

There is nothing more frustrating than someone who continually counters your requests with one of the two phrases at the top there. When I hear it some from someone's mouth what I really hear is “I am quite happy just plodding along in my job and I never want a raise again.” If I hear it come out of my own mouth... (It may be time to move on!)

Don't wait to be given responsibility. Don't wait for the person who should be doing something to do it - make it happen. It makes you look dynamic. Perhaps you will overstep the bounds of your current position, but that may just make someone realise that you don't belong there.

Thursday, September 20, 2007

I smells somethin'

Programmer 1: “What the... That code is horrible. Who did that?”

Programmer 2: “Erm... Yeah that was me. I know it's crap.”

Programmer 1: “Crap? This code gives crap a bad name. This code goes right by crap and out the other...”

Programmer 2: “Yeah, yeah okay, that'll do, I know, but I wrote that shit like 3 years ago.”

Programmer 1: “Uhuh. Umm... This code over here is just as bad... You wrote this shit yesterday!”

Everyone knows that the worst code you have ever seen is the code that you wrote 6 months ago. However you are supposed to learn from your mistakes*.

* That way you get to make new and interesting ones each time.

Wednesday, September 19, 2007

So don't press that button!

It was (probably) Murphy who said (something like) if there are two ways to do something and one of them with have disastrous consequences, the probability that someone will do it that way is 1. Thus, all good programmers ensure that pressing the wrong button at the wrong time will not cause things to blow up. Lumped in here are things like checking input, clicking in the wrong spot, pressing the delete key at the wrong moment. For these things and more we can ignore, correct or confirm inputs. Good. But you can't be pissed off when you click the wrong, but valid from the context, button and that functionality completes successfully.

For instance, there is functionality A and functionality B that both act on the current input. These functionalities are both executed thousands of times per day, there is no way to tell from context (previous operations) which one is more likely, and there is no time to have a confirmation. So when you have operators that click B when they mean A (and not notice - it is not like you can't cancel you B and put in an A) you have a training issue. There is nothing the system can do about it! That is not the worst of it though. What I really love is the service calls and bug requests saying that the reports for the operations on a certain terminal are “all screwed up, there are B's where there should not be.” So I take the 10 minutes that it takes to verify that there were no problems with the processing and what I find amounts to “That place where there was a B is because the operator pressed B.”

“Why is my transaction cancelled?” Because the operator cancelled it.

“Why did the upstairs bell ring?” Because the person pressed the top button.

“Why is there a charge of $0.01 on my credit card?” Uhh, because the cashier ran a transaction for 1 cent on your card?

Tuesday, July 31, 2007

ClickOnce - or: how to instafuck your whole installed base with one click of the mouse!

Fuck me that was fucked.

We are rolling out a new version of a program which is updated via ClickOnce. We currently (luckily) have about 12 of 80 machines installed - the rest are using the old, manually updated software. I am actually pretty glad that we had today's problem today and not in a couple of days time when the whole thing was rolled out - _that_ would have been a major shit fight.

This morning I got a request for changes. Nothing huge. Thought it would be a nice demonstration for the live update feature of the new system. 10 minutes to code. Took my time testing, 1 hour. Published the changes onto the beta site, let the test machines auto-update. Cool. I sign off on the mods, the client give the go-ahead for live. I publish on the live server. Sweet. Now I keep a test machine connected up to the live publication just so I can have a last minute test to make sure all is well. I go and run the client on that machine. The auto-update barfs. Crap. I go to look in the program group for the program. The machine freezes. Crap crap. I reboot and try again. No go. Now I am starting to get a little worried. I connect up to one of the client's live machines which is not being used at the moment and let the auto-update run. Barf. Crap crap crap. Machine freezes. Fuck. I try to uninstall the program, the item does not disappear from the control panel. I try again. Freeze. Reboot. Uninstall. Okay. Now I reinstall the new version, and it works. However the calls have started to come into the call centre... “We logged out and logged in again and it did its auto-update and now the computer is broken”. Fuuuck. So the technicians get to work some overtime uninstalling the broken update then reinstalling it from scratch, and I get to do some overtime to work out why the fuck it did not work.

After a 30 or so re-deployments in different configurations I find out that some kind soul has installed Windows Installer 3.1 on my testbed. I add it as a prerequisite so it gets installed first - now the auto-update works. So that is why my initial deployment test did not fail - there seems to be some kind of problem with the default version of Windows Installer, and I didn't see it because the testbed already was using a later version. I go check in with the technicians and we run a test on a machine that was not yet fucked up - installed Windows Installer 3.1, then let the auto-update run - no problemo. Fuck. I wanna break someone's fingers!

So after an hour of downtime for > 10% of the system I know what we have to do - re-do the install from scratch with Windows Installer 3.1 as a prerequisite. We have to start again because it has to be installed as Administrator. I am not going to be popular with the technicians...

I used to like ClickOnce. But now I am not so sure. It is very difficult to integrate into a responsible deployment strategy. When the whole system is deployed that way, how can you test a new update? I have never seen a case where the re-install (rather than the auto-update) does not work, so you can't just say that if the clean install works the auto-update will work. So imagine that all the machines are deployed from the live site - the auto-update is kind of all or nothing, you can't point a few machines at a different server to make sure the update works. I guess you could copy the live site to a test site, install from there, then update the test site and let an update go through. There is also no rollback. Once you let the update go, it's gone baby.

Just goes to show you - must have test machine that is identical to the live. Well, I'm off to padlock up the test machine... where did I put those thumbscrews?

Saturday, July 07, 2007

Wake up!

For a while now I have had an alarm clock that can wake you up to a CD. I used it a bit to wake up to music, but I had always thought that I could do better than that and create a playlist specifically for waking up. Mostly I had to have the volume up loud enough to ensure that I woke up eventually, meaning that it was too loud at the start, jarring me awake - which I wanted to avoid.

Some things that I have noted about waking up. Waking up to the beep beep alarm is not nice, but it is certain to make you leave the bed. Waking up to white noise it better, but it is possible to sleep through. Waking up to nice music is the best, but again sleeping through is a distinct possibility. When I am not super tired, I will generally wake up at the sound of the CD spinning up, or the light pop sound the amplifier makes when turning on.

So what I have thought might be nice is a kind of ramping up in the volume and wakeability of the noise. I was thinking something like: Low volume environmental sounds, white noise like, waves, wind. Most time I would wake up to this, perhaps drifting in and out of sleep, remembering dreams, getting ready to get up. Low volume relaxing music. This will make me up if I miss the first sounds, I may even get up now if I was fully awoken by the first phase. Medium volume energetic music. This signals the time to rise. Could be possible to sleep until now, if so this will wake me. Loud music that it is basically not possible to sleep through, techno, metal, something like that. The three remaining are the backup plan. I basically don't see getting to this point very often. Medium to loud white noise tones. Loud beeping. David calls in dead.

So what remains now is choice of musics. I am thinking one of the tracks from the glasshouse CD for the environmental sounds. Either one of the early movements from a Bach cannon and fugue or something from hallucinogen for the relaxing. Good wake up music... indy rock, thinking female vocal, rising crescendo... have to think about this one for the medium volume energetic. Loud music backup. So many choices... PWEI, Rage, anything a bit violent and raucous.

Should play with the audio levels on the MP3s that I create for this so that the volume ramps up nicely. May not even have to worry about the final stages, just put another loud sound on with the levels really tweaked in the MP3.

(Might also be interesting to make the playlist, then merge it all into one track so that I can do different ones with different music and use them on shuffle so I don't get sick of the same music every morning...)

Friday, July 06, 2007

Just do it

I feel like productivity people (the GTD crowd, that sleep guy, zenhabits) explaining how to lose bad habits, how to have a morning routine, how to organise your life is much the same as some happy person telling a depressed person to “just feel happy”.

I read somewhere today that when introducing a new habit into your lifestyle, “the first step is getting yourself to do it”. Fuck no buddy - the WHOLE THING is getting myself to do it. Do you not understand that what I have trouble getting myself to do is ‘getting myself to do things’?

Why so glum little girl? “I'm depressed”. Well cheer up, you'll feel much better if you just smile and be happy. Being happy is the first step on the road to not being depressed.

*Barf*

Friday, June 22, 2007

Not my problem (I wish)

It can suck sometimes to be left working on a project after the original project manager has left the company. All their mistakes and oversights become your property - even the ones that are invisible until the fan is at full speed and the excrement is in flight.

Customer: “We tried to use the system today with the PC disconnected from the network and it does not work.”

Me: “No I don't suppose that it would. It needs to connect via the network to its [hardware device] at all times.”

C: “Well what about each year when we sell things outside of the store with no network?”

Me: “I don't know.”

C: “Why didn't you think of this before?”

Me: (Because it's not my job? How the fuck should I know? Maybe you should ask the guy who is not here anymore. Maybe you should ask why we don't have a project manager at all?) “We will certainly have to look into that.”

C: “You realise we need this to work by [the day two days from now] don't you?”

Wednesday, June 20, 2007

Output filter!

A corollary to the input filtering rule:

Couch your demands in terms that will make your actual desires apparent to the person whose assistance you are soliciting, rather than explicitly telling them what to do.

Let them work with you to solve the problem. Explain what effects you would like to see rather than how they should act. Let them figure that out for themselves.

One, they are probably better qualified than you to judge what they really need to do - assuming that you are involving them because it is their area of expertise.

Two, people are more likely to want to do something if (they think) it was their own idea to do so. Rather than looking at your demand and defensively trying to avoid change, the impetus for the action comes from within and they will likely feel empowered in its performance.

A, B, C

What part of “it has to done in the order A then B then C” do you not understand?

First you do A. Then later you can do B. Finally, when A and B are done, you may do C.

“Okay so, I have not done A yet, but B is done. Can I just do A now then C?”

Nooo! You have to do A first, then B then C.

Input filtering

One important difference between working with a boss and working without one is how you think about what you are asked to do.

Normally when you get a demand from you boss it comes with an express or implied priority, you slip it into your schedule, do it, and report back. Sometimes you may have some say in modifying the priority, sometimes you may question the validity of the task, but mostly you just do it.

Working now without any direct boss, just vague priorities from on high, this sequence of “receive work unit”, “execute” is often counterproductive. I knew that some filtering would be required, but I did fully understand the extent to which one must think about what people are asking for, why they might think they want that, hence what they really want, weigh that with who they are, and decide what I should give them. People seldom take the time to explain why they want something, and often what they want is not the right thing.

I need to focus on getting them to explain the problem they are trying to solve rather than let them specify which actions they think I should take. From there I can understand what really needs to be done (perhaps nothing) and help them to understand how this new action actually solves their problem. Only then can we decide on who will do what and when.

It is the same as with any problem solving. It is important to start with the definition of the problem - particularly when you are asking the help or advice of someone else. It is important not to colour their thinking with your supposed framework for the solution.

Friday, June 01, 2007

Hungarian notation

This (useful) notation prefixes each variable with a label or tag indicating the kind of information that is being stored - what is its purpose.

KIND. Not type. Please, either go and read the original (Simonyi) specification of Hungarian or just don't use it.

Calling your variables bSomething or iNumber or lpszBlahBlah is worse than useless.

Monday, May 28, 2007

Creationism

The universe is complex.

Far too complex to have been produced by random processes from nothing.

It is just not possible for more-complex things to evolve from less-complex things.

There must have been a creator.

The complex universe was created by a creator.

[logical continuation...]

The creator must therefore have been more complex than the universe.

The creator is very complex.

Far, far too complex to have come from nothing...

...

Friday, May 25, 2007

ReSharper - Awesome, Expensive, Slow

ReSharper (R#) is great. The refactorings and code completions and cleanups and warnings are truly awesome. I now really want all the code that I work on to pass with few or no warnings. But I am going to have to uninstall it for two fairly mundane (i.e., should be easy to fix) reasons:

  1. It totally has screwed up all of the keyboard shortcuts. Even after flipping back to all VS 2005 shortcuts there are some things that don't work, and worse, there are many nice features of R# that are no longer available at the touch of a button.
  2. God damn it's slow! Not on a new file, or a small file. But on big old files that have lots (200 or more it seems) warnings. Each time you make an edit to the file it re-analyses it which takes a looong time. (7000 line file, 280 warnings, 15 seconds)

These should both be reasonably easy to fix:

  1. Don't frig with the shortcuts! Give me a list of functions for which you would like to add shortcuts and I will assign them. Maybe this is doable by the end user - I'm sure that I could eventually get my old studio shortcuts working again, but I am not paying US$250 for a tool only to spend hours repairing the damage it has done.
  2. Let me disable the automatic analysis of the current file. Maybe in that nice little coloured box at the top of the colour bar there that had a hand icon but does not seem to actually DO anything.

I have used R# for a couple of days now, and I love it! You have a convert people! But I CAN'T use it like it is.

Wednesday, May 23, 2007

Web 2.0 style guide

Orange! Light green! Dark blue! Light blue!

Very faint diagonal or way off-centre circular gradients.

Dark text on light same coloured background.

Dotted (light coloured) borders (and horizontal rules).

Shiny glass or gel (jelly!) looking buttons (that are not usually buttons) and text.

Text sitting on a shiny table and all manner of other (3d) surface effects.

Big bold headlines. Often multiple down or diagonally across the page.

Smaller (gray) body text with lots of white padding.

Many pointed stars.

Cute icons.

No underlined links.

Digg this, post on reddit, blog this, tag on del.icio.us, etc., etc., etc. buttons.

I'm not saying that any of this is good or bad, just what I have been noticing.

Implementing IExceptionHandler

When using the Enterprise Library Exception Handling Block, there are (at least) two things that you have to do to get your custom handler to work that I missed when I looked at the docs. Specify CustomHandlerData as the ConfigurationElementType for the handler class:

[ConfigurationElementType(typeof(CustomHandlerData))]
public class WatchdogHandler : IExceptionHandler {
...

Provide a constructor that takes a NameValueCollection:

public WatchdogHandler(NameValueCollection attributes) { }

Final note.

I have had weird problems with the Enterprise Library Configuration tool. When I first created the handler class it would not load the assembly in the tool. It said that no class that implemented IExceptionHandler could be found. When I fixed the problems with my class it still would not load. Frustrated, I created another handler class from scratch (no other classes in the assembly, no other bits of code lurking around to cause problems) and that one loaded. Then, magically, the other class loaded as well!? Perhaps it was after all the closing and re-opening of the tool that it started to work, but I am not convinced.

Thursday, May 17, 2007

Phrases which flip my “no-longer debateable” switch

For the bible tells me so.

If you have nothing to hide, what is the problem?

I'm not a racist but...

It's just a theory.

Others that just make my sigh and shake my head:

Anything that is described as having an infinite number of configurations or settings.

That [insert mechanical device here] totally breaks all the laws of physics.

Wednesday, May 02, 2007

Item: Ninjas, two score. Check.

Is there any problem that could not be solved by 40 Ninjas? Didn't think so.

Ninjas: not just for breakfast anymore.

Tuesday, May 01, 2007

No, that's not it, try again.

If there is only one valid entry for some field in an interface, why don't you just put it in for me?

I was using this form created by someone here today, it is a form for our overtime: “Please enter the date for last Saturday” Uh... okay. I guess that was the 22nd of April. 04 22 Bzzt! No sorry that is not the correct date. Please Enter the date for last Saturday. Oh yeah, it is the 21st. Bzzt, that date is too far in the past. Are you serious? The only date that I can enter is 28th April? Bingo.

Well bugger me. If you will only accept one value, and you know what that value is, why don't you just put that in there!? And why can't I enter a date from a past week? It is not an automated system, this gets sent to our HR department for manual human entry into another system. She asked me to resubmit my form from 2 weeks ago. Sheesh. I can see why you would want to make sure that someone selected a Saturday (the start of our billing week), but why force a single Saturday? The people in HR know what they are doing, I am not going to be able to slip in old forms just by putting in an old date, if they are not expecting them they are not going to process them.

If there is really no date selection, don't ask me to select one.

Friday, April 20, 2007

Make ‘em mandatory!

There is a town in the states called Kennesaw with what might be called the opposite of gun control laws. Each household is required to own and maintain a gun. Must be a real shoot-em-up town right? People gettin’ popped left and right? Check out the article.

When you think about it, the proposition “If we make guns illegal there will be less gun crime” is pretty nonsensical. I would suggest the simplified relation “Gun crime is proportional to the difference between the number of armed bad guys and the number of armed good guys”. From this it seems likely that decreasing the number of guns the bad guys have would be good, just as increasing the number of guns the good guys have should have a reducing effect on the level of gun crime. This subtraction however is problematic: it is difficult to actively reduce the number of bad guns. Installing gun control laws causes the good guys who have guns to turn them in and the bad guys to snigger. Arming the populace may well put guns in the hands of the bad guys, but I would argue that on balance more good guns are created than bad - criminals don't feel they need gun licences, don't register their guns, don't pay retail, don't install gun safes, don't enrol in official how to shoot safely courses. Gun control laws have the opposite to the intended effect.

If you make gun ownership criminal, only criminals will own guns.

Wednesday, April 18, 2007

Are you packing?

I would like to live in a world without guns. I would like to live in a world without violence of any sort. If people were never even verbally abusive to one another I would consider that we were on our way to the perfect society. If someone threatens your security with violence, I believe the first response should be to try to defuse the situation, to remove yourself and those dear to you from danger into safety. Only as a last resort would I consider meeting violence with violence. But to not take that last step. To turn the other cheek as it were - well I leave that to other folk. For me, if you threaten me and you leave me no other recourse than to violence, then violence you will get.

I am starting to believe that in some societies this necessarily extends to a willingness to counter gun violence with guns. I have often thought, and heard said by others, that the death toll in shooting rampages would be very much diminished[1] by some of the people involved (witnesses, victims) having guns (heroes). I think that is a very difficult argument to dismiss outright.

I recently watched a video by Penn & Teller on the bullshit that is gun control. Their argument is very America centric (citing constitutional amendments), but I think the arguments within translate nonetheless. Then yesterday there was the shooting at Virginia Tech. I wonder how far a lone gunman would progress into his spree if some significant portion of the populace were armed. I wonder how many criminals, who now find themselves in the wonderful position of being likely the only person with guns in a couple of minute radius, would reconsider all manner of crimes. Overnight there was also a shooting by a security guard of a man in Sydney. Two men approached him with a drawn gun, likely not expecting any resistance. He shot them and they fled. Criminals use guns to have a power advantage. By reducing the power of the populace (removing their guns) you let criminals easily tip the balance in their favour - carry a handgun. An armed populace (maybe as few as 2% carrying weapons) could greatly reduce a lone criminal's expectation of being ‘the most powerful’ in a certain situation merely by carrying a gun.

I am not saying that everyone should or needs to have a gun. But those considered stable enough, those who can show they can do so safely, those who wish to take on the responsibility of using a gun if the situation requires, why not?

Gun control folks are always carrying on about needing to ban guns. “If only we could remove all the guns we would be safe”. Well think about this: Virginia Tech was a gun free zone. For the 30 minutes or so between 9am and 9.30am there was only one person in the area who had a gun, and I think we all know now what he decided to do with it. I just wonder what may have happened if some of the teachers, the RA, the seniors, the janitors were armed. I wonder even what would have been different about that morning if the gunman had even the slightest doubts that perhaps he would meet with people in that place that were armed and prepared to defend themselves and others.

I don't think ideas that appear logically sound ought to be dismissed outright by ‘zero tolerance’ style arguments.

[1] There was a shooting at another school in Virginia, not so many years ago. Though there was a different outcome at the Appalachian School of Law. Two students at the scene were armed. They subdued the gunman after he took his first victims.

Friday, April 06, 2007

*Sniff*

You know how when sometimes you are just sitting there and you smell this smell and like, you smell it and you can't work out whether it's toast or dog shit... Yeah, I hate that.

Moo

The communist utopia can be build from a socialist regime by force in much the same way that a glass of milk can be build from a cow by cutting it in half. (Sounded better before I wrote it down...)

Thursday, April 05, 2007

Turn up the suck

I need to work out why the company I work for sucks.

We all want to know why our product sucks. I guess I could benefit from knowing why (you think) I suck.

Seth Godin's new book The Dip (under the lens here) seems just the ticket. I have not had much trouble in the past knowing when to quit. My problem has been more quitting when it is time to... (I just want to know how they get the little guy on the cover to walk along like that)

[Edit: I totally read “help you see what's causing your organization (or you) to suck” rather than “to get stuck”. Seth: Please tell us why we suck too! But in the end, one could say that people and companies and enterprises and relationships get stuck precisely because they suck.]

Swap Mouse

So I swap sides with the mouse a lot. I have to say I mostly use my left hand (even though I am a righty), but I swap often enough to have looked for a utility to easily swap the buttons.

I downloaded a couple of them and found them to be horrible. Some had graphical interfaces. One wanted to install and run at startup. One wanted to leave its little icon on the notification area. Geez Louise. All I want is a utility that I can double click that will swap the damn buttons around then go away. Silently if possible. So I made one.

It is all of two or three lines of code. (Well, okay, you know what I mean, three that I had to write myself). It is about 20KB, does not install, does its job quietly, and has a cool looking icon (well maybe not, but I had fun making it).

I used this as an opportunity to check out Google Code at the same time. So I have created a project called swapmouse, the executable is there now, the source will be linked up when I get home. Here is a link to the bare executable for SwapMouse for your convenience. Just put it in a directory under Program Files or somewhere (I usually make a Program Files\Utilities just for storing nice little programs that don't need to be installed) and make a shortcut to it. Enjoy.

Wednesday, April 04, 2007

404



    Error 4.04 - Date Not Found     Please try again at a later date. Maybe the 5th.


Tuesday, April 03, 2007

Last.FM gadget

This past weekend I have been working on a windows vista gadget for last.FM

Most of Saturday was spent fooling around with javascript for the first time in a long while. Trying to find syntax errors using notepad. Ugh. I finally relented and downloaded visual web designer. Next time I play with it I will hook up the script debugger. The rest of the time was spent parsing the XML and text responses that the last.fm 'APIs' respond with. It is a shame that the whole thing is not done in XML - the np.php (now playing) for example just responds with name value pairs in text. Not so nice. Plus it seems to me that the whole shebang is a little iffy at times. Just not responding to requests.

I will have a bit more of a look at the last.fm source tomorrow, for now I have only really looked at the myLastFm source code... Perhaps going back to the original source would be better. I want to know for instance whether the 'real' client polls the np.php for track updates (say every 5 seconds) or if it has some other way. I had envisioned getting the remaining track time and then waiting until around about the time the track should finish and then requesting new track info. But time remaining field seems to have been left out of the response (the myLastFm client looks for it too).

So for now I have working:

  • Basic gadget functionality (icons, page sizing, basic css and js)
  • Username and password configuration.
  • Password hashing.
  • Recently played tracks fly-out.
  • Now playing info (artist, album + cover art, track).

I think actual login (send username and password hash, receive sessionid and stream address) is close to working - just that when I was testing it last night the whole last.fm site stopped working, now np.php was not returning etc. Later it worked again, but I was past the stage of wanting to code - Guild Wars...