AliGrant.com
 
Valid XHTML 1.0!

Valid CSS!

Powered by PHP

Get FireFox

1&1 Internet


Archived News

ImageMagick and FastCGIMonday 28th July 2014
I have just been trying to get a Media Wiki install to use the ImageMagick conversion library on a Windows/IIS stack for the purpose of SVG thumbnailing.

In true open-source form, the documentation is weak. When I attempted to run the conversion I would receive an error from FastCGI "Unable to Fork" when using passthru().

I knocked up a PHP script to see if this was a standalone issue or all shellexec statements. Nothing worked.

Whilst ImageMagick is a standalone executable it needs to run in a command shell environment, so for this to work, the calling process needs to be able to execute "cmd.exe". Adding the appropriate IUSR_* account to be able to read/execute cmd.exe fixes the problem.

NB: you can do a lot of damage with cmd.exe; by allowing your web-server to execute this opens a large attack vector to your server.

If you're looking for a method of converting images, then probably using PHP extensions will be safer.


Trouble updating BizTalk BAMFriday 18th July 2014
BizTalk BAM isn't the easiest beast to tame, anybody who's tried to update an activity will have come across that issue.

I have recently tried to deploy some big additions to a BAM definition, by adding some new Activities. The problem is, when I came to deploy these additions with:
bm update-all -DefinitionFile:myexport.xml

I get presented with an error like this:
Updating Activity... ERROR: The BAM deployment failed.
Cannot remove or update an existing data item or milestone.

Somehow, somebody, didn't update our source-control correctly and the file I was working from was out-of-sync. I'm not entirely sure how anybody has ever updated things (which looking at the state of it, I doubt they have).

In typical Microsoft fashion, I have a cryptic error message. Whilst the cause of the error is fairly self-explanatory, the source is not. Like a Null Reference exception, the complaint is just *something* is wrong and never goes into detail of what.

In the end, I took the previous export of the bam definition:
bm get-defxml -FileName:olddef.xml

And compared the XML to my updated XML file (pro tip: use an XML comparison tool, or script out something to check each Activity) - indeed, I did find an activity that had an Milestone in the existing system but not in the new one.

As I had a lot of changes to add, I couldn't import the old XML and start again, so I wanted to hack the updated XML file with the missing field. I did this by adding it into the Activity through the Excel plugin and exporting as normal. When trying to import this, I continued to get the same error. The reason for this is that the unique ID/key for the field was not the same. So I then had to manually edit the XML file to use the ID attribute from the existing XML file.

It is important to note that the ID is used as an XML constraint and it is referenced elsewhere in the file, so you need to search and replace all instances. After that the updated XML imported ok and I could then export the definition file again to create a new Excel spreadsheet.


C# Duplicate random numbersWednesday 16th July 2014
A bug came about in testing, where there was multiple items to process things fell apart due to duplication - which is strange, as I had thought of that and generated, what I thought, was a random enough number to keep things unique.

The problem appears to be around how the standard .NET random number generator works in a multi-threaded, parallel environment. Take this bit of code for instance:
Parallel.For(0, 10, i => {
Random rnd = new Random();
Console.WriteLine("{0}: {1}", i, rnd.NextDouble());
});

When you run this, there is a good chance that most, if not all (especially if you add formatting) will come back with the same number.

I assume the issue comes from how random numbers are generated - I don't know how it works in Windows, but in a Linux environment there is a system random number generator, which you can access via /dev/random. If there isn't enough randomness available your code will hang until something is returned. To avoid this, you can use /dev/urandom, which returns immediately - but this reuses what it had before. I guess something similar is going on with the .NET Random class and as each thread has it's own instance, the class is unaware that it may need to mix things up a little.

The general solution is to use a single instance of the Random class and access it across all threads. This though isn't always a feasible option. What you can do though is seed the number generator with yet another random input, which so far seems to be reliable:
Random rnd = new Random(Guid.NewGuid().GetHashCode());

This uses the GUID generator, which should create a globally unique ID, and pull out the "hash code", this is a number that is used internally by things like hashtables for sorting etc. As the hash code is an integer - you honestly could probably just use this instead of Random, depending on how you require your numbers to be returned (e.g. bytes etc).


PC coolingTuesday 15th July 2014
I've been giving personal-computer cooling an unreasonable amount of thought recently; mostly the day-dream variety. It probably started around a year ago when I figured it was probably time to upgrade my case: an Antec SX835 II. Coming in a fetching shade of off-white it boasted five 80mm fan positions (three front, two back) plus an optional side fan fitting on the side panel. The removable drive bay and screwless door made it a pleasure to tinker with.

I spent a fair bit of time getting back up-to-speed with the latest cooling, the world had moved on from 80mm fans and everything was about 120mm fans and bottom-mounted power supplies. I figured I didn't need a lot of space and had to get with the times and accept that everything PC orientated (especially in the enthusiasts realms) came in black. I researched a bit and bought a gorgeous looking BitFenix Shinobi. With fan options including x2 120mm fronts, x1 120mm rear, it also boasts twin 140mm top-mounted and a 120mm bottom mounted. Spoilt for cooling options.

So a year later and I'm not happy with PC cooling. The issue comes from the movement of the PSU from the top of the tower, to the bottom; a craze that seems to be spear-headed by Corsair. The theory is sound, PSUs are sensitive to heat, so it was silly pumping all the heat from the CPU into the PSU, instead you mount it at the bottom where it can get its own source of fresh air from under the case (and a lot of dust). And true to this theory, the PSU does indeed stay cool. The snag is, now the CPU is directly below the top of the case - to the front you have your optical drive bays and below you still have your graphics card. The net result is there is no source of fresh air being pushed towards your CPU - instead air has to work its way between the back of your graphics card and the optical bays - hardly optimal. And a knock to the BitFenix design, whilst it looks good, having a solid front to the case is never going to be great for air-flow.

I have since been considering my options for better air-flow. There are many, many discussions on the optimal placement of fans and how to cool. A lot of "definitive" articles, with no evidence to back them up. A few experiments done by computer-magazines suggest that traditional thinking doesn't always work. My reading so far suggests that these are the key points into actively air-cooling your computer:
  • Direct air-flow on hot area works the best

  • Keep air-flow as straight as possible

  • The aim of the game is to get hot-air out and replace it with cool air

  • Extra fans are only beneficial providing they compliment the above

  • Heat only rises when there are no other forces working against it

  • Fans are only affective for a short-range

Positive and negative air-flow are a big conversation piece. Positive pressure could lead to having hot air caught up in the out-of-flow areas, whilst negative pressure lets exhausted hot air right back into the case. And the latest craze is high-static-pressure fans instead of high-air-flow. It's all very well having a lot of flow if there is not enough pressure to overcome any obstacles (stupid solid case fronts, fan filters, cable mess, etc). Is there any reason not to get the highest pressure fans possible? And then there is a complete lack of conversation on well-established science, such as Bernoulli's principle - why aren't we seeing velocity stacks on computers more?

On my old Antec case, I used to have the side fan-position filled, I eventually removed it as I discovered things were in fact warmer by a degree or two when it was in operation - I suspect this was due to the side fan pushing the front-air flow into the wall and destroying it's ability.

The main issue in computer cooling seems to be the layout of current cases are not optimal, which means a lot of fans are required to overcome the physical limitations. A more intelligent layout of components would allow cleaner airflow and less effort required to move it around. A few manufacturers have played with alternative layouts, Lian-Li have used a reverse flow (which is fine providing you can get your graphics card and CPU cooling to work backwards) and Silverstone have dabbled with rotating the motherboard 90 so that the expansion slots exit at the top - this seems the best approach but only available in the large variety. I hope to see more innovation and I also hope to see review-sites building cases and using appropriate fans optimally when reviewing instead of relying on the bundled fan(s).


Previous Next