Sunday, December 28, 2008

Visual Studio 2k8 ideas

Ideas for a plug-in for Visual Studio 2k8 - if anyone is interested in OSS'ing this then let me know!


1. Click on a variable and convert it to a with block (probably needs to work on the selection)
2. Organise imports - like the C# one - and can remove anything that is no longer needed
4. Rename that works through to an aspx/ascx page and therefore the .designer files as well
5. Go to declaration on a control takes you to the HTML source
6. Navigate from the code to the HTML designer view

Lutz Roeder's Reflector suggestions

Ideas for Lutz Roeder's reflector which I'll get around to sending to him at some point:

* Use of the new "If" function rather than "Iif" if VB

* When variable names use reserved words they should be wrapped in []

* When dividing integers the integer divide operator should be used

* In places code generated takes the form of
New XYZ isn't valid - needs to be put into a variable
But that doesn't recreate the correct reversal of code

* use of new construct and set method doesn't seem to work properly - missing the " with " operator

* use of AscW and ChrW rather than char constructor and type conversion

* x = y = 1 construct not translated correctly

* friend property get's incorrectly become get_XXX functions

* catch xyz As Object isn't valid syntax

Sunday, July 27, 2008

Implementing the Office Binary Formats

Microsoft released the Office binary format specification earlier in the year and I'm going through a fair few thousand pages of spec building .Net libraries to read and write the files at the byte level.

Below is an errata which I'll keep up-to-date during the process.


OfficeDrawing97-2007BinaryFormatSpecification.pdf

Various types aren't correct

STD is used as a default but never described
MSOCOLORNONE is used as a default but never described


P44 refers to MSOSRH, MSOPRH, MSOPV and MSOPRV which aren't documented anywhere

P49 says line left style twice but should probably say Line Row Style

P51 wzSigSetupProvId claims to be property 192 but is 1922

P52 refers to msopctSizeNone and msopctPosNone and MSOSRH which aren't defined anywhere

No documentation is provided for the additional line styles' extended color information

Tuesday, May 27, 2008

SQL Server CE 3.5 SELECT TOP

Another gotcha but this time in the dialect that SQL Compact Edition 3.5 uses.

Version 3.5 introduced a couple of new features to make it's SQL more compatible with that of SQL Server and one of those is TOP.

Simple you'd think but oh on - they've decided to use a different dialect for the same command.

In SQL server you write:

SELECT TOP 10 [name] FROM [people] ORDER BY [name]

In SQL CE 3.6 you write:

SELECT TOP (10) [name] FROM [people] ORDER BY [name]

How annoying as it means that the same piece of SQL can't be used without a little translation layer. Why anybody though that wrapping the number of lines in parenthesis was a good idea I'll never know!

Shared Folders in Virtual PC 2007

I use Virtual Machines extensively but got caught this weekend with something I've not really found documented anywhere.

I was in the middle of restoring an 18GB Oracle 9i database, and rather than muck up my dev. machine I decided a virtual machine was the obvious answer.

All went well until I tried the Oracle "imp" tool to import the database from a "Shared Folder". It got part way through and complained of a corrupted backup file.

I tried again with a different version of Oracle and the same error occurred.

It turns out that the "Shared Folders" have a limitation on file size like that of FAT which I'm guessing is a 32bit pointer as 2GB seems to be the limit.

The simple answer to the problem is to map a network drive or use UNC but I was quite surprised that the facility of the VM additions failed in such a strange way.

Saturday, May 17, 2008

Immediacy <head> gotcha

I'm currently doing some Immediacy customisation work using templates developed by an Immediacy partner.

I was getting a very strange effect on one particular page when hitting a search button that did a form post... basically the CSS got lost.

I checked the templates thoroughly and couldn't see the problem but when comparing the page before and after a post I noticed that the lines in the head tag had mysteriously had their "href" attributes changed. It appears that something within the Immediacy page pipeline attempts to "play" with the contents of the head tag and on postback it makes a right mess.

I'm guessing it's to do with the themes support within Immediacy as even on a standard page there are a bunch of injected <link> elements picking up CSS from a handler and what it appeared to be doing on postback was moving the href attributes from elements in the template to the next sibling - I even ended up with <meta> tags with a href's pointing to CSS files!

The solution to the issue is to ensure that the head tag, which normally reads as:

<head runat="server">

Is attributed without viewstate and therefore reloaded from the original ASCX file each time.

<head runat="server" enableviewstate="false">

This has now solved the issue, and on further investigation I found that more than just this one page was being affected but due to the CSS in the template it wasn't quite so obvious. I've simply done a search and replace on all templates in the solution and replaced the head tag as above - problem solved.

Tuesday, May 13, 2008

SQL Server Locks

A better alternative to sp_lock with information about the locks in the current database:


SELECT
  li.req_spid As "Session ID",
  o.[name] AS "Object Name",
  i.[name] AS "Index Name",
  v.[name] As "Lock Type",
  u.[name] As "Lock Mode"
FROM
  master..syslockinfo AS li
  INNER JOIN master..spt_values AS v ON li.[rsc_type] = v.[number] AND v.[type] = 'LR'
  INNER JOIN master..spt_values AS u ON li.[req_mode] + 1 = u.[number] AND u.[type] = 'L'
  INNER JOIN sysobjects AS o ON o.[id] = li.[rsc_objid]
  LEFT OUTER JOIN sysindexes AS i ON i.[id] = li.[rsc_objid] AND i.[indid] = li.[rsc_indid]
WHERE
  li.rsc_dbid = db_id()
ORDER BY
  o.[name],
  i.[name],
  v.[name] desc

Wednesday, May 07, 2008

Huawei E220 USB HSDPA Modem

Finally someone has managed to get the Huawei E220 Vista 64bit drivers working on Windows XP 64.

Hurrah!

Much kudos to you whoever you are.

Saturday, April 19, 2008

Forza 3 suggestions

Well I'm not going to deny it - I'm a big fan of Forza 2 and it's probably been the most entertainment for £40 I can think of.

There's a few things though, that if they make it into Forza 3 will really make my day...

In no particular order:

  • Weather effects

  • The challenge here is not to get gimmicky - PGR 4 actually did a reasonable job of rain but the snow, although fun, isn't really worth the effort it must have taken.

    There's two parts to implementing this - the first is the visual effects of water on the cars, the circuits, the spray from cars, the rain itself and of course the darkening of the skies that would add considerable atmosphere to what is a very clinical game.

    The second part is implementing aqua-planing and friction against the water in puddles - PGR4's attempt here is a good example of what can be achieved, but with the additional dynamics that are being modelled in Forza surely it could be awesome.

  • Lighting effects

  • In a similar way that rain would add atmosphere I think that other lighting effects would give the game further depth.

    In addition to the obvious one of night races, the time of the day can trigger effects such as low sun glare or mist burning off during a race.

    I think what would really make things interesting is something along the lines of a weather forecast for the race adding dynamics such as choosing tyres and pit strategy to the mix.

  • Pit strategy

  • I believe I've read somewhere that Forza 2 models the effects of fuel use on the weight of the car, possibly even the weight distribution. That's a great piece of physics implementation but it's stillborn in that you have no choice as to how much fuel you're putting in the car.

    We've seen that in formula 1, pit strategy has become a huge element in determining who wins - I wouldn't want a game to lose it's driving aspects too much but the choice of only filling to say 75% from the grid and knowing that an early pit stop is required would add to the strategy.

    Likewise the pit stops all seem to take about the same length of time - I'd like to see the options as to whether certain damage is repaired and whether tyre changing should be performed and see an appropriate knock on effect on pit time. It would bring into the equation the possibility of "splash-and-dash" pit stops.

  • Length of races

  • I guess looking at all of the above you can see that I'm a fan of the longer races. If it was me designing the career elements I' have added about an extra 5 series, all as long as the endurance races and have some proper endurances races of 4 hours or more.

    The 50'ish minute races are well chosen in that an hour is a reasonable time to set aside for a race but the opportunity is missed to have some really long races allowing for far more to happen during the race.

    I also can't see why adding addition levels has a great deal of effect on play testing - the addition of an extra 50 combinations of race would surely be an easy thing to do. Maybe each class of car could have 5 or 10 circuits for the endurance races rather than just the one.

  • Difficulty levels

  • The model of difficulty affecting credits earned works well in Forza 2 - I've never found myself with too many credits nor too few.

    What I find annoying is that by dropping from hard to easy I only lose 15% of my credits won per race. This could have been changed considerably without affecting the early stages of the game where credits are at a premium. I also find that the "normal" level of difficulty is too closely matched to that of "hard". The "easy" levels can be completed with almost no concentration and in almost any car, yet "normal" and "hard" often require a car and driver of much higher skill. Either an additional level of difficulty or a rebalancing of these would smooth things out. In terms of credits - I'd like to see the levels at -50%, 0% and +100%. That would really make a difference as to which level is chosen.

  • Circuits

  • Oh for more circuits... I guess you can never have enough and at least with Xbox Live there's the possibility of more being added.

    I guess there's a high level of effort (and therefore cost) in presenting a new circuit but surely it's worth it. I'd almost go to say that I'd settle for 1st and 2nd grade circuits, differing in how well they've been modelled. Maybe that's where the community could come alive by modelling circuits they have an interest in - initially just from aerial photography but eventually with contours and additional touches such as scenery. There are so many circuits out there that very easily be modelled in outline from Google maps alone.

    What's most missing from Forza are the street circuits that have been implemented so well in other driving games such as PGR and GT. I know that it is a game concentrating far more on dynamics than visuals and that's one of the main reasons I like it but there's still something about screaming though an Italian city or through London that appeals. It's obviously possible as the New York circuit demonstrates. I can only assume that the development costs are prohibitive compared to that of a normal circuit.

  • Cars

  • With over 300 cars we're not doing badly and there's only a few manufacturers that I feel have missed the opportunity to get included.

    I'm not sure how the licensing works for cars - I'm guessing the manufacturer has to give permission for the trademarked brands to be included and may even contribute 3d models and technical data to start the process off. From there I guess it's all done from publicly available literature and photographs.

    The thing I'd like to see here is far more variants of some of the existing models - the gamer points can still be done my model but surely it can't be that hard to have statistics against different engine options for the same model. Maybe I'm the only person out there, but there is something nice about driving the exact model of car that you own - in the same colour and specification. Something I can only really do with the 350z as it's a popular choice in gaming.

  • Damage

  • The damage modelling in Forza 2 is a valuable addition that models crashes quite well - I'm looking forward to Race Driver: GRID as Dirt had stunning damage modelling and if they've been able to bring that across Forza will be looking very dated.

    More important than just crash modelling for me would be more subtle effects such as those of punctures caused by driving over debris and even flat-spots on the tyres caused by locking the wheels under braking. I don't think these will be hard to model but will add yet another depth of game play. They are also obvious candidates for the rumble in the controller and for the direction tug that's already been implemented.



Enough of me and back to the game - I'm sure there's plenty of other opinion out there and we'll just have to wait and see what Forza 3 brings. Let's hope its constructive towards game play though and doesn't follow GT5's route of only providing eye candy.

SSD performance

Continuing my investigation of SSD performance I've now installed Vista Business 32bit inc SP1 on my Latitude D600 with 32GB PATA Samsung SSD.

The results are a bit annoying... the machine feels much better running Vista than it did running XP and that's something I'm a bit embarrassed to admit to!

I haven't benchmarked it properly yet but so far there have been considerably less stutters that I experienced before and currently experience on the Precision M4300.

Given the 64bit driver problems I've been experiencing (mostly the 3 3G USB modem) I'm very tempted to install Win 2k8 Server on the M4300 and see how it gets on.

I'll be happily living without the Aero interface as I hate it - some of us have work to do - but given that 2k8 is working well on my Precision 690 workstation it's got to be worth a try.

Watch this space where I'll do some more formal performance analysis and benchmarking.

Friday, February 22, 2008

Book recommendations

I occasionally get asked what books I'd recommend to programmers starting out in the game.

Here's what I select for those getting into web applications, flex and ASP.NET



The pocket reference guides below are invaluable for their succinct style although need to be accompanied by more substantial references rather than used on their own

Friday, February 01, 2008

Wasted CPU cycles

Now TortoiseSVN is the antithesis of what I've recently discovered about ActiveSync.

Although the SVNCACHE.EXE programme does have a habit of hanging around when it's not really needed.

The difference though is that the boys and girls who put Tortoise together thought about it and made it optional - but I didn't know about that until I did a quick search on the TortoiseSVN website.

If you go to the TortoiseSVN context menu, and then Settings you'll get a dialog. In there is a treeview item called "Icon Overlays" in the "Look and Feel" branch.

On that panel are options for the Status cache.

Just how it should be done!

Wasted CPU cycles

This will hopefully be a regularly updated list of apps for which the programmer should be hung-drawn and quartered. I often come across bad examples of programmer and here I'm going to name and shame them.

WCESCOMM.EXE which is part of ActiveSync 4.1.0.4841 is the communications module part of ActiveSync - it is responsible for communicating back and forward with the device. By default its configured to autorun on user login.

In their infinite wisdom MS decided to create a log file in the logged on users %TEMP% folder called WCESCOMM.LOG. Now normally you'd expect a log file like this to contain all sorts of useful information relating to errors and activity.

Oh no - these guys are better than that - they write an entry every 250ms stating "No device detected, reset to default 115200". I feel so much better knowing that the electricity I'm paying to power by PC is being used to record that nothing has happened 100,000 times a day.

Oh and to make matters worse they delete the log file each time that ActiveSync restarts - so if you were trying to diagnose an issue the log file that you'd be using has been emptied of anything valuable - except possibly that there's still not a device connected.


Wednesday, January 30, 2008

Outlook 2007 issues

I've nearly had enough of Outlook 2007 and am seriously considering something like Firebird instead.

The guys appear to have added quite a few new features in 2007 over 2003 but have also created far more problems than I'm prepared to put up with.

I've now solved one of the most annoying which was performance related - how can anything run slowly on a 2.2 GHz Dual Core with 4GB RAM and a 64GB solid state disk!

The problem appears to be that Outlook offline data files were designed for very small mailboxes - I suspect the underlying architecture is very similar to that in a PST file. Somewhere in the design must be a hash-table and leafs of a b-tree and that b-tree is very much overflowing in a modern email environment.

I'm a power user and don't deny it and I like to keep almost every non-spam email I receive - they are an invaluable resource on a day to day basis. For that reason my .OST file was nearly 8GB - large - but not unreasonable with the bloat that is a XLS or DOC file.

The issue is that performance drops to unacceptable and although I can't hear the thrashing I can see that the SSD is being worked ridiculously hard by the flashing disk activity light.

The answer has been to do the following, and although it works for me because of the way I store my emails it won't work for everyone.

I personally like to keep archives in a chronological manner - maybe it's just me but I find it fairly easy to guess a date for something and from there honing in on the right thing is fairly easy. For that reason I simply have subfolders under the inbox and sent-items for 1997, 1998, 1999 etc through to 2007.

I generally keep 3 months worth of current emails in my Inbox and Sent Items and archive into the subfolders every month or two.

What I've ended up doing is copying the data (not moving) from all of the yearly folders into a PST file (with the exception of 2007).

This has resulted in a 2.7GB PST file.

The next thing I've done is to set the synchronisation filter for the yearly folders to only synchronise unread emails - in other word nothing. This leaves the emails where they belong - on the Exchange server - in an appropriate folder but means that my OST file has shrunk to just over 1GB.

Maybe it's an indication of how bad the OST structure is that the disk space required for this solution has almost halved. I can't think why other than Unicode/ANSI text issues.

I've made the PST file read-only and will copy it to each of my machines as an offline copy of data that won't change (well only at the beginning of each year when I move a whole additional years worth of mail into the PST).

The main reason the solution is acceptable is that Windows Desktop Search is able to index PST files and seamlessly integrates the results with those from the Inbox.

Windows Desktop Search is one of those applications I love to hate - but it works - which is why it annoys me as it really does solve problems such as these by bringing together results so effectively.

A solution which so far is proving far better than Outlook alone would provide - all I need to solve now is why Outlook keeps forgetting my favourite public folders...

Monday, January 28, 2008

Sage Line 50 on 64bit Windows

Well my 64bit laptop is gradually coming together - only a few more 64bit niggles to iron out and then it's fully up and usable.

The one I've solved today involves Sage Line 50 - and specifically the rather ancient version that I'm fully licensed for - v7.

The installers appear to be a 16bit app (is that possible?) and 16bit apps don't run at all on 64bit windows so that installer just starts setup.exe and does absolutely nothing.

Since I've done a fair bit of installshield work in the past I though the best route would be to monitor the install on a clean machine and reproduce the steps on the new laptop.

Using WinstallLE (from the Windows 2000 Server CD) I built an MSI but more importantly gathered the registry changes that were made during the installation. As always there were lots more than required so I trimmed out everything referencing parts of the registry that weren't relevant to the install.

In addition to the contents of the Line50 folder there are a bunch of files mostly matching SG*.dll in the system32 folder and also SW7*.dll which is the ODBC driver.

I copied these into the main installation folder and got a working Sage - but I knew that the hardest part would be to get the ODBC working.

It turns out that the ODBC driver was built against the MS VC RTL 2 so I copied that and also an unknown dll called MSIMTF.dll.

Once those dependencies were copied across (again into the Line50 folder) I was able to run the 32bit ODBC administrator which cunningly lives in c:\windows\syswow64\odbcad32.exe.

Unsurprisingly the ODBC driver wasn't yet registered which can be performed with the following statement:

C:\WINDOWS\SysWOW64>odbcconf INSTALLDRIVER "Sage Line 50 v7|Driver=c:\work\line50\SW7DBC32.dll|Setup=c:\work\line50\SW7DBC32.dll"

Where "c:\work\line50" is the installation folder.

And hey presto - a working Sage Line 50 complete with reports!

Saturday, January 26, 2008

Dell Precision M4300

My existing Dell Latitude D600 is nearly 4 years old and as it's Dell's year end and the discounting is good I though I'd treat myself to a new laptop.

My main requirements are 1400x1050 LCD, 4GB RAM, Core-2 duo and good battery life.

Dell appear to have left us developers in the dark these days and the choice of laptops with a decent vertical resolution has dwindled considerably - you either have the choice of a huge 17" screen and a luggable rather than portable machine or a D520 class machine which I've never been impressed at.

Being D Series compatible is important to me as I've got a number of peripherals that fit in the d-dock and docking stations at various places where I work - so I've ended up opting for the 1680x1050 resolution 15.4" screen of the precision M4300.

My first impressions are that it's big - much bigger than I was hoping for and next to my D600 it really is in a different league. I really hope that there's a revolt to continual use of wide-screen displays - they're very nice - but you do end up with an impractical display configuration. As a developer we always work on "tall and thin" code and how many people you know work on word documents in landscape mode? Is the modern laptop really dedicated to people who watch DVD's? If so how about those of us who actually work on our laptops for a living?

Well it's a big laptop and unfortunately that also means it's a heavy laptop - it's got a good array of ports - everything you'd imagine really from 3xUSB, eSATA, firewire, PCMCIA and Cardbus, VGA, serial, NIC, modem, and s-video. What's dissappointingly missing is a card reader of some variety which means I'll end up installing the little PCMCIA flash readers that I've used in my previous machines. A shame really given the huge amount of empty space there must be inside the case.

Performance wise though the size does have it's advantages - the screen is good, and the processor (2.2 GHz core-2 duo) is spot on - as is the 4GB RAM. I'm running Win XP 64bit so I can actually use all 4GB unlike many with 4GB installed. This laptop also has a nVidia QuadroFX 360M with 512MB onboard so I won't be sharing core RAM with the video card. You'd also have hoped that they'd have got a 370M into it but no such luck so this machine won't be the fastest around for Vista - personally I see that as an advantage rather than a disadvantage as I'll be switching to Windows Server 2008 once it's finally released rather than going anywhere near Vista.

The machine came with a 160GB 7200RPM SATA disk from Seagate which is about as good as 2.5" disks get these days - I did some performance stats with H2BENCHW and it really is a good disk, shame it's had to be removed to make way for an SSD.

Which cunningly leads me onto the most crucial bit - the Samsung 64GB SATA SSD - supplied by overclockers.co.uk at the whopping price of £499+VAT (that's 2/3rds of the cost of the laptop on top). Overclockers.co.uk have found a way of supplying these disks to the general public and this disk turned up Dell branded - they must be purchasing direct from Dell which sounds about right as I believe Samsung have agreed to supply to OEMs only to start off with.

Compared to the 32GB PATA SSD that I have in the D600 the 64GB SATA SSD is a far more polished product - rather than exposed chips in a plastic case the SATA model appears to be a single billet of aluminium with space carved out for the electronics - a much more appealing thing to behold but still far too expensive for the average user.

The first thing that I've really noticed with the SSD compared to the mechanical disk is how quiet the machine has now become - I hadn't realised quite how much noise the original disk was contributing whilst I was benchmarking and testing the original disk but now that the SSD is in I realise that the CPU fans only rarely cut in so the noise from the machine was almost entirely from the disk - not the sound of the heads moving but just a background noise of the spinning disk which has now thankfully gone - I'm finally beginning to like this machine.

Speed I guess is the reason for the SSD and I'm a bit dissappointed with the benchmarks - it's not looking any faster than the PATA model. I thought I was buying the Samsung 100MB/s model but it looks like that isn't the one in the market right now and 50MB/s is what I'm getting. That's slower than the 105MB/s I got from the 7200 RPM disk but as with any SSD it's the access times that count. Average Random Seek times have gone from the original 14.4ms (very respectable for a 2.5" 7200RPM disk) down to the almost insignificant 0.26ms - that's 55x faster which means that it can truly sustain 50MB/s at all times rather than just the occasional burst to 105MB/s that a rotating disk can manage.

In the real world what this means is that I'm booting from on-switch to login prompt in approximately 20 seconds - not forgetting that this is a machine with a 6GB page file, a full array of development tools including SQL 2k5 developer edition and then from login prompt so usable desktop is almost instantaneous and gloriously silent. That's quick enough for me.

So to rate the Precision M4300 - I'd have to score it:

Processor 9/10
Screen 9/10
Weight 4/10
Size 4/10
Disk 7/10 (original)
Disk 9/10 (SATA SSD)

Overall 8/10 - it's the size and weight of the machine that's dissappointing especially when you consider what Apple can do with the MacBook Air and what Asus can do with the Eee PC.

LED Bulbs

The time has finally come when the GU10 halogen bulbs in the office have died and I've decided to replace them with LED bulbs.

The deciding bit is easy - the choosing and purchasing is much much harder.

I've ended up going for some that I found in a local DIY store - they are branded - Philips Deco - and are 1W "Warm White" retailing at £6.99 each.

They consist of 9 LED's within the GU10 package and run at 240V AC - according to a spec I finally located in German they appear to be 6000cn rated - which is obviously quite low - but as they're installed three at a time I though I'd give it a go.

Compared to the 3x 35W bulbs that were in there before the light being emitted is almost negligible but that's not really surprising - 105W vs 3W is a considerable power saving.

I've manged to burn through 3 of the existing halogen's in 12 months so it'll be interesting to see how these LED bulbs compare. They are rated between 5,000 and 100,000 hours so it would be nice to think that they'll easily outway they're initial cost.

I'm also considering some of the bulbs that screwfix.com supply - they do two varieties - a Halolite one at 1W and also a Sylvania one at 1.5W.