Hardware vs Software Raid

Hmm.. Which is better?

I would say software raid is better*, my reasons:

  1. Software raid follows the OS around, upgrade all your hardware, your raid array will still work (In Theory)
  2. Software is easy to update, Firmware is not
  3. If your on a budget, do you really want to trust a cheap raid controller?

[*] Under most conditions, ie. without big budgets, mission critical servers etc…

See Also:
Stackoverflow Blog: Tuesday Outage: It’s RAID-tastic!
Linux: Why software RAID?

Converting Videos for the Creative Zen

I have a Creative Zen, its a very nice little mp3/video player, and while it plays xVid/DivX/WMV its a bit picky about what it will play.

So ive created this script to convert videos to a format it will play (320×240, xVid, with auto black bars to maintiain aspect ratio & 128KB ABR MP3 audio).
Its a Bash script using Mplayer / Mencoder.

Files

Lambda's and Anonymous functions in C# 3.5

Here’s a lambda function in use with the new extensions for a List object.

personnel.foreach(x => x.DoSomeCoolStuff());

Continue reading

360° Angle Class for C#

Here is a nifty class to handle an angle. it will wrap around increments and decrements that exceed 360 or 0, e.g. adding 20 to 350 will give 10 not 370 and subtracting 10 from 5 will give 355 not -5.

  • Implicit conversion to and from double
  • ToString and GetHashCode are mapped to the inner angle
  • Operators +,-,>,>=,<,<= have been implemented.
  • Mixing this class and doubles in statements works seemlessly.

Code sample:

Angle angle = 0;
double angle2 = angle + 5;
Console.WriteLine("a1:{0) a2:{1}",angle,angle2); 
//Output: a1:0 a2:5

Files

Making better use of mod_deflate

Output compression using Gzip and Deflate is a common feature of modern webservers. Webpages can be compressed by the server and then decompressed by the client seamlessly.

By default (at least on debian/ubuntu) Apache has a module installed and enabled called mod_deflate. While great, here is the default configuration:


      AddOutputFilterByType DEFLATE text/html text/plain text/xml

Now at a glance this is fine, But modern webpages consist of more than just html, we have CSS, Javascript, RSS and even JSON, all of which can benefit from compression but aren’t enabled by default.

Here’s a modified config file that will compress these files:


      AddOutputFilterByType DEFLATE text/html text/plain text/xml application/javascript text/css application/rss+xml application/json

This config is usually located at /etc/apache2/mods-enabled/deflate.conf.

With this done jQuery (minified) goes down from 54KB to just 16KB of data send to the client :D

Multiple Onload Functions

Here’s a quick way not so good way (see update) of getting multiple javascript functions to be called when the page has finished loading.

Add this to the pages Head section:

 

And then where you need an onload event callback do this:

onload_functions.push(function() {alert('The page loaded...'););

Update:

As pointed out by phihag, this solution isn’t great, instead try using phihag’s code or use jquery and just $(document).ready(function{} {alert('The page loaded...');});.

CSS Columns and the Box Model

One of the greatest frustrations for me when designing a website has been using css to layout a multi-column format (like this one).

I’ve found that it is important to understand the box model. more importantly knowing that when you set the width of a block element (ie div) it sets the width of the content. The padding, border and margin is wrapped arond it.

Box model image

Comments fixed!

It seems that when i upgraded to django v1.0 it broke the captcha as all template variables are now auto-escaped, whereas previously escaping had to be done explicitly this meant that you would see the html, the field is now marked as safe and so fixed! :)

This really does prove to me the value of testing as its been weeks since I upgraded, I never noticed because as a site admin I dont see it. Doh!

On a side note, i’m wondering what peoples opinion on captcha is? personally I see it as essential, and that re-captcha is the best, second only to googles own.

New Look!

Heres a new theme and header image, what do you think?

Stack Overflow Beta

For those of you who dont follow Jeff Atwoods blog, he and Joel Spoolsky are creating a question and answer site for programmers called Stack Overflow.

Its in late beta now, and its great, to make it more than just your basic Q&A site theres a reputation score (based on how many people have up-voted your questions/answers) and badges, which were inspired by Xbox Online. The community is also top-notch.
Continue reading