Archive for May, 2007

Bash script woes

Monday, 28th May, 2007

I had an opportunity to play with Bash script on Friday. My task was to write a small deployment script to grab our server class configuration settings from subversion and rsync them to the appropriate machines.

This was easy enough, a couple of commands to subversion, rsync and some glue and I’d be done. However, an hour into writing it I wish I’d used PHP or used my time to learn how to do it in Perl.

For one, a hash of arrays doesn’t sit well in Bash script. I wanted to define a list of servers for each class. In PHP the code would have been as simple as:

$servers = array(
  'web' => array('server1', 'server2', 'server3'),
  'db'  => array('server4', 'server5', 'server6')
);

Fortunately I was able to work around this with separate arrays for each class. What I couldn’t get around was the pain I had to endure to pass an array as an argument to a function.

Passing an array involves loading the space-separated elements of the array into a variable with command substitution.

Taken from Chapter 33 of the Advanced Bash-Scripting Guide.

printarray () {
  local passed_array
  passed_array=( `echo "$1"` )
  echo "${passed_array[@]}"
}

original_array=( element1 element2 element3 element4 element5 )
argument=`echo ${original_array[@]}` # command substitution
printarray "$argument"

This is just clunky and showed me that for anything more than basic conditional logic I’m better off investing some time in learning Perl.

What is it with INT(11) columns?

Wednesday, 23rd May, 2007

At every company I’ve worked for and many open source projects I see MyISAM tables with INT(11) columns. Why?

MySQL’s INT columns are limited to 2^32 unsigned (4,294,967,295) which if you count the length is 10 digits long. Therefore INT(11) is impossible – although it worth noting the length on integer columns is only the display width.

If you’re looking to reduce the size of your tables/rows use the appropriate type of integer column.

</rant>

Time for an upgrade

Tuesday, 15th May, 2007

It’s been almost 5 years since I last upgraded my PC. How times change, I never would have thought I’d be considering a laptop to replace a desktop machine any time soon but that’s exactly what I’m going to do.

When I’m not in the process of upgrading I pay little attention to PC hardware so I was surprised to see one terabyte disks available (for only £230!) and even solid state disks (SSD) are now financially viable.

I’m seriously considering upgrading to SSD in Q4, with no moving parts noise and heat is greatly reduced, battery life is improved and they’re more robust than conventional hard drives (being dropped isn’t a problem). The only downsides are price, write performance and lifespan.

Ironically when it comes to deframentation SSDs are deliberately fragmented to prolong disk life. Each cell has a limited number of reads/writes (approximately 1 million) so data is deliberately spread to maximise the lifespan. Therefore defragmentation is discouraged!

I’m waiting for Sony to release their SZ5 notebook which is based on Intel’s Santa Rosa platform (marketed as Centrino Duo for consumers and Centrino Pro for enterprise).

Just a week after deciding it’s time to upgrade, my main PC develops a weird problem where the monitor will go to sleep while I’m using it, even when listening to music or watching a movie. The audio can still be heard when the monitor is in sleep mode.

First thing I did was to set all power management to ‘Always On’ and not to power down the monitor. Didn’t work. So I switched out the graphics card with a spare one I had. Didn’t work. I’ve monitored my PSU voltages, no spikes.

So while I wait patiently for the SZ5 to hit the streets I’m working off an old laptop my Dad has kindly lent me, which I use to remote desktop to my Windows machine.

Pastures new…

Monday, 14th May, 2007

I am still alive but I’ve not really dedicated much time to blogging this year. Last Friday was my last day at Evolving Media. I enjoyed my time at EM, and they produce some quality work but I really want to move on to using more robust development practices. Namely using a versioning system again, when I first started there it felt a little bit like walking a tight rope without a safety net with no CVS.

I was also in denial about how much of an OO zealot I’ve become, the trouble is I’m not writing enough OO code to progress as quickly as I’d like. Not employing OO was basically a huge road block for starting test driven development, automated testing (continuous integration) and automated deployment. All of which are nice to have but come at the cost no one could afford at EM – time; victims of their own success in that regard.

As I’ve mentioned before, one thing I never really settled with was working on a Mac. It was doing my head in going to work on Mondays and hitting CTRL instead of the Apple key and pressing those retarded page up and down keys that aren’t (they only scroll your screen and not the cursor).

I’d have the reverse situation at home where I’d keep hitting the ALT key instead of CTRL in Windows, ALT + right for End, ALT + left for Home and @@ for “”. As developers we use # symbols more than most and ALT+3 just isn’t convenient dammit. Apple keyboards, pha!

I think a six month run on OSX was long enough for me to decide I’m still a Windows fanboy, there’s some dev tools for Windows I’ve grown up on. I never found a decent replacement for Regex Coach (I even made a long over due donation the other day as a thank you!).

So where am I off to next? On May 21st I start at Alexander Street Press, an academic publisher with US roots who focus on the humanities. I’m looking forward to it; the two guys I’m working with, Paul and John, seem really knowledgeable, I’m sure I’ll learn a lot.

I’ve a week to myself this week to tie up some loose ends (private work namely). I’m hoping to get some more posts up here this week. In an ideal world I wanted to:

  • Push my new blog layout live (3 columns tagged up with microformat goodness)
  • Make a start on Groovy in Action
  • Read more of PHP in Action
  • Ditto for Agile Web Development with Rails
  • Finally get Zend (PHP5) certified

But I can’t see me squeezing that all in…

You are currently browsing the greg's weblog – the more I learn, the less I know weblog archives for May, 2007.

Categories

xhtml 1.1 compliant   xhtml 1.1 compliant