Wireless Networking on Windows 2008 R2

I’ve just spent 30 minutes trying to get my new wireless card working under Windows 2008 R2. I had installed the drivers that came with the card, the card was visible under Device Manager but I could not connect to a wireless network.

It turns out that Windows 2008 R2 doesn’t include wireless LAN support unless explicitly enabled. So to rectify this, bring up Server Manager->Add Features->Wireless LAN Service and all the tools for connecting to a wireless network are installed.

Advertisements

Improving Ubuntu 12.10 Performance

Unity 2D was retired in Ubuntu 12.10. The new fallback desktop for low spec machines is Unity 3D with software rendering (the LLVM pipe). I’m do not know why anyone thought this would be a good idea as old machines without 3D capable video cards are somewhat unlikely to be powerful enough to perform 3D rendering on the CPU, but that’s for another day.

In order to make Ubuntu 12.10 work well in a VM, you need to ensure that the guest additions are installed and 3D rendering is enabled. This is trivial in VirtualBox, but there is a snag. You have to manually load the VirtualBox video driver. To do this, add `vboxvideo` without the quotes to /etc/modules. Restart the machine and everything feels faster.

Python Screen Grab Code

The following code listing is for a cross platform method for grabbing the screen in Python. It uses PIL on Windows, and ImageMagick on other platforms.

import PIL
import os
import platform

def grab_screen(fname):
    if platform.system() == 'Windows':
        PIL.ImageGrab.grab().save(fname, "JPEG")
    else:
        cmd = "import -window root %s" % fname
        os.system(cmd)

NTFS short file name generation

During the week, I discovered that the product I was working on appeared to slow down dramatically after the dataset reached a certain size (approximately 150,000 items). This was worrying, as we’re aiming to be “enterprise” ready and need to be able to process millions of items. In addition to that, we already had customers far more items than that and yet they had not reported such an issue.

After some in depth investigation involving a profiler, it turned out that our web service was spending >90% of its time on 1 line of code – this line created a file in a directory to store some binary data that was sent from the client. It wasn’t an I/O issue as the disk was hardly thrashing and the next line of code that actually wrote the data to the file was fast, i.e. <0.001% of CPU time.

It turned out that this was due to the way the file system worked. Windows automatically creates a MS-DOS short file name to go with each file. When there are many files in a single directory, the time it takes to generate a unique short file name grows. As we had more than 200,000 files in the directory, it was obvious that the hashing algorithm struggling. This would explain the huge CPU usage and the long file creation time.

To fix this, we disabled short file name generation by bringing up the command prompt and typing in the following command:

fsutil.exe behavior set disable8dot3 1

Microsoft cautions that this could break compatibility with older 16 bit applications that rely on short file names. Given that most machines are 64 bit capable and the days of 32 bit applications are numbered, I think it’s a risk is sufficiently minimal 🙂

Database options with Delphi XE Starter

I’m slightly annoyed at the lack of ADO components in DXE starter. I’m not familiar with BDE or Interbase, and the documentation for these appears rather lacking. As I’d prefer to use MS SQL Server Express because it’s free and it’s what I’m familiar with, I thought I’d look at ADO but Embarcadero have elected not to ship the ADO DB components with DXE starter.

Given that I’m not going to do any serious DB work in Delphi, the simplest alternative is to use SQLite. There’s a set of Delphi components for accessing SQLite databases called DISQLite3. It’s simple to use; TDISQLite3Database and TDISQLite3Statement and we’re rocking. A personal version of DISQLite3 is free for non-commercial use. As an added bonus, applications using DISQLite3 don’t depend on the SQLite DLL.

What’s not to like?

Delphi Sampling Profiler

There’s an excellent, free Delphi profiler called “Sampling Profiler”. It does exactly what it says on the tin, launch your application in the profiler and when it’s done you get a report detailing the parts of your program that are consuming the most CPU time. Unlike GProf, you even get the offending line that is taking up all your CPU time.

It’s simple, it works and it’s free. Get it from http://delphitools.info/samplingprofiler/

 

Initial thoughts about Delphi XE Starter

It’s been a very long time since I had any interaction with Delphi. We did a  lot of Delphi at university, and since then the Delphi world has changed a lot. These are well documented elsewhere so I won’t go into that here.

Instead, I discovered earlier this week that Embarcadero (Delphi’s current owner) has finally released a cut down version of Delphi for hobbyists and start-ups that’s priced very reasonably at about £120 for the upgrade. Most developers should qualify for the upgrade as you only need to use any of the free IDEs such as Visual Studio Express or Eclipse to qualify.

Now back to Delphi XE Starter. It’s a cut down version, so what did they cut out?

Quite a lot actually.

I’ve not spent too much time with it, but the notable omissions are:

  1. Class viewer. This panel hosting a tree control that lists all classes and methods are the staple of every IDE including the free ones.
  2. Code Insight. If you’re not familiar with Delphi (like me) then this would mean nothing to you. It the ability to go from declaration to definition (i.e. F12 in Visual Studio) and is very useful when attempting to navigate a source tree.

I’ve also started being slightly annoyed by the Pascal language that’s starting to feel like a dinosaur especially after spending years in languages like C++/C#. You cannot declare variables on the fly, the language is not case sensitive (n is different from N) and it’s very verbose.

This is just from a few hours use, so things might look up once I become more familiar with the product.