Author Archive

Been there, done that….

July 30th, 2008

Latest comic:

The Warnings Behind Using Linux

Directories vs Folders

July 30th, 2008

Just a random passing thought…..

In Windows, we call them folders but on *nix we call them directories.

However the catch is in DOS, we also used to call them directories. Somewhere along the way (presumably the switch from Windows 3.1(1) to Windows95) the nomenclature was changed for this entity and it was renamed from a directory to a folder.

Funnily enough, i’ve never actually caught myself using the wrong nomenclature until now….I’ve always referred to them as directories when in Linux or in the DOS-shell, and referred to them as folders when working with the incumbent.

how strange.

Parallelism In SQL Queries Causing Deadlocks

July 28th, 2008

This is really just a stub post, and should force me to come back and add more detail to the topic.

In a nutshell, be careful if you have parallelism turned ON for your multi-core SQL server as SQL’s internal worker threads can seemingly jam themselves into a deadlock scenario when executing a parallelised (sp?) query.

to disable parallelism, use the OPTION (MAXDOP 1) query hint.

SELECT col1, col2, col3
FROM table1 t1 INNER JOIN table 2 t2 on t1.id = t2.id
WHERE SomeCondition = SomeValue
OPTION (MAXDOP 1)

This will force SQL Server to run the query with a max parallelism of 1 (ie: single thread). Good-bye locks!

Some references:
Query Hint (T-SQL)
Appropriate Uses of Parallelism in SQL Server
Detecting and Ending Deadlocks
Deadlock Troubleshooting (Part 1)

HttpException (0×80004005): Server Too Busy

July 28th, 2008

Recent problems with a client website have required me to re-discover a whole lot of performance tid-bits which i’d either long forgot or just plan never knew.

In trying to stress-test the SQL server forming the backend of the website, we ended up exceeding the web-server’s capabilities and it would die with a not-so-nice error citing “HttpException (0×80004005): Server Too Busy” and a call-stack dump internal to the framework.

I was lucky enough to find an article on the MSDN which explains a work-around for the ASP.NET web-application request queue limit.

<httpRuntime appRequestQueueLimit=”5000″>

Just add this element in your <system.web /> web.config element (and change the value 5000 to whatever you deem appropriate)

Deadlocked transactions and Junctions

July 22nd, 2008

Wow lots has happened in the last 4 hours. Where do i start?

  • In order to diagnose a locking/blocking issue on SQL server, start with an sp_who2 to give you the list of active PIDS, and the PIDS blocking requests. Then execute DBCC INPUTBUFFER(<BLOCKING PID>) to find the offending SQL
  • In order to free space on a critical HDD, you can move the data over to a new location on the same machine and create a junction (a symoblic link for the *nix folk). New feature of NTFS 3.0 and IMO not used anywhere near as heavily as it should. Most underrated feature in Windows.
  • It’s hard to come across a good music compilation, but by God someone has managed to do it

LOLCode is real!

July 7th, 2008

Noone believed me when I introduced them to the Shakespearean programming language, or the whitespace programming language.

Well now believe me when I say that LOLCode is a true language! It allows you harness the power of a thousand teenage script-kiddies, and emanate elegant code such as :

HAI
CAN HAS STDIO?
I HAS A VAR
GIMMEH VAR
IZ VAR BIGGER THAN 10?
YARLY
BTW this is true
VISIBLE “BIG NUMBER!”
NOWAI
BTW this is false
VISIBLE “LITTLE NUMBER!”
KTHX
KTHXBYE

FINALLY we can get back to real programming…..

Rhino vs Moq

June 26th, 2008

All i can start with at this stage is wow…..

I went through by feeds this morning and innocently picked up an article introducing mocking using Moq. I’ve read a little about it, followed the fact that it’s gathered quite a following, and figured it best I give it a spin to see for myself.

And then I followed the links in that article….
And then I read the links in that article…..
And i was shocked to learn about the bad blood between the very two opposing camps, which i’d never realised….

Incidentally, I started off trying to learn more about Moq, and now i’m reading up about TypeMock Isloator…all in a day’s work i suppose ;)

Switching an IIS website home directory from the command line

June 18th, 2008

The title says it all.

The problem was simple – we have a legacy .NET 1.1 website project, and have several branches for each environment it’s currently running in. In order to test bug fixes for a branched version, I always find myself needing to go into IIS management console and switch the website to the directory of the branch. A reasonably easy step, but always cumbersome because it takes focus off solving the problem at hand.

What i wanted was to create a batch script i could execute, and IT would be clever enough to update the IIS website to the correct directory.

Searching for command-line management tools for IIS turned up a lot of results, but none of them mention anything about modifying an existing website. They all have functionality to query/add/delete a website from the IIS metabase, but nothing to modify an existing one.

After a bit more digging, i was lucky enough to find this article explaining how to modify an IIS website path using Active Directory Service Interfaces (ADSI). It’s a small C# code snippet, but was enough for me to write a console-app to do exactly what I needed.

The only thing that the utility did not mention was that it relies on the input id being the IIS metabase website id, and not the name of the website. But determining the id of the website from the name was a trivial call to the iisweb.vbs script, and then a regex to pull out the ID from the output

%SystemRoot%System32iisweb.vbs /query “My Website”

Once the app was written, I knocked up a quick batch script to perform the switch (with a little refresher on my ms-dos syntax):

@echo off
echo Switching My Website to directory %CD%

echo First lets stop IIS (unnecessary, but being defensive here)
iisreset /stop

.toolsswitchiisswitchiis.exe “My Website” “%CD%MyWebDir”

echo Restarting IIS…..
iisreset /start

pause

In case people are interested, i’ve zipped and attached the project (assembly and code). It’s not robust, and it could be better, but its a tool for a specific job. YMMV.

Download SwitchIIS

Attached Files:

  • Download SwitchIIS

    SwitchIIS is a CLI utility to update the home directory of a specified IIS website. Best used in a batch-script, with a sprinkle of cinnamon.

Converting an ASP.NET Website to Web-Application

June 10th, 2008

I’ve had to do this so many times in the past, i ended up creating my own instructions and gotchas

Today I stumbled across an article on the MSDN explaining step-by-step how to convert a website project to a web-application project and am keeping record of it….One thing i didn’t know was that you can run the “Convert To Web Application” option to generate partials and code-behinds.

noted.

Mounting NAS drive under Ubuntu

June 9th, 2008

I’ve been battling this one for a long time….Finally got it solved…..(sort of)……

Last year, I bought a cheap $70 NAS external drive case to use as network storage…The poor man’s SAN, if you will.

Since I bought it, however, i have been unable to mount the drive under the linux console so that i can access it’s contents in bash script. Accessing the drive from Gnome file browser, works fine, however.

I tried and exhausted all options:

  1. Using smbmount (although deprecated) would mount the drive, but the contents of any subsequent directory listing would be garbled and look like corrupt text

    ———- 1 root 16 114P 1940-10-24 12:26 ?
    ———- 1 root 16 114P 1940-10-24 12:26 ?~?????
    ———- 1 686040 32 115P 1940-10-24 12:26 9.jpgj
    ———- 1 root 16 114P 1940-10-24 12:26 and star cityg

  2. Using mount.cifs would not even get that far – it would just mount error out with:

    mount error 20 = Not a directory

And then i stumbled across a newsgroup post which had the answer:

modprobe cifs
echo 0 > /proc/fs/cifs/LinuxExtensionsEnabled
mount /mountPoint

According to this link apparently the NAS drive doesn’t support the smb extensions supported by my client’s kernel, so disabling them allows me to mount the drive successfully…

i don’t know what the Linux extensions actually are, but i’m guessing that they have something to do with codepages and the interpretation of content, because now when i try and browse the mounted directory under Gnome’s file browser, it comes out all garbled…no problem….i can still browse the network share directly through gnome so no need to browse the share….

Just another day in front my computer…..

EDIT:
On the upside, i’m now able to mount the network drive on my linux server, and share the network mount using samba on the server. This is a long and nasty workaround to the problem that Vista can’t access the NAS server without patching the NAS device itself.

Uninstall IE7 and go back to IE6

June 6th, 2008

Because IE6 still has a 30% market share , it’s important to test your website on IE6.

Sadly, installing IE7 removes any hope of safely being able to do so….There are compatibility issues with apps like IE6Standalone etc which don’t make them 100% reliable. In my case, Windows auto-update was kind enough to upgrade my specific IE6 virtual machine to use IE7. *rolls eyes*

To uninstall IE7, and revert back to IE6:

  1. click Start -> Run.
  2. Type: %windir%ie7spuninstspuninst.exe into the text box, then click OK.

It’s pretty quick to run, but requires a restart.

First Chance Exceptions in .NET

May 30th, 2008

short post…..

In some cases, the .NET framework will throw an exception internally, and then (using it’s own exception handling routines) re-throw something else based on that exception. if you’re getting an exception thrown from the Framework which you don’t really understand, and can’t work out what is causing the problem, try turning on the First Chance Exception for the .NET CLR in VS (Debug –> Exceptions).

This allows VS to catch any CLR exceptions when they are thrown, and will give you more insight into what’s the root cause of the problem.

Also, make sure you turn it off when you’re done otherwise you could end up constantly chasing your tail catching unnecessary exceptions ;)

Read books at work, and noone will ever know!

May 29th, 2008

http://www.readatwork.com/

A website built to encourage people to read during work. Really clever! It creates a “fake” desktop and you can sit there reading books without anyone suspecting a thing!

Test your web design in different browsers

May 26th, 2008

After seeing the fully CSS Homer Simpson, i wanted to see what he looked like under all browsers.

i found http://www.browsershots.org a while back and lost the link – blogging it here so i don’t lose it again.

Essentially this website has a virtual machine farm running a plethora of operating systems and an even larger plethora of browsers. You can get an idea of how your site looks under each of these OS/Browser combinations just by submitting a URL.

matter of fact, my results are coming up now…….

  • IE 8: Renders Homer, but his neck drops below the bottom of the bounding box
  • IE 6: Renders perfect
  • IE 5.01: Renders perfect
  • IE 5.5: Renders perfect
  • FF 1.5: Renders perfect

…and then i get this message “Browsershots is temporarily unavailable. The database needs a full vacuum. We hope to be back soon. If all goes well, this should take less than two hours.”…..Meh. i’ve seen enough to know that IE8 is still definitely beta software ;)

Microsoft Source Code Analysis for C#

May 26th, 2008

Also known as a CodeSniffer, this tool analyses your source code and outputs statistics of whether the code fails key standards which should be followed across your entire codebase.

    Source Analysis is similar in many ways to Microsoft Code Analysis (specifically FxCop), but there are some important distinctions. FxCop performs its analysis on compiled binaries, while Source Analysis analyzes the source code directly. For this reason, Code Analysis focuses more on the design of the code, while Source Analysis focuses on layout, readability and documentation. Most of that information is stripped away during the compilation process, and thus cannot be analyzed by FxCop.

Sweet. I’m going to try and push it into one of our local projects here :)

[UPDATE]
….bugger. Looks like it is reliant on VS2005/.NET 2.0

why am i still stuck on this lousy 1.1 project? :(