Small Mosaic


Categories:

/books
/career
/codinghorrors
/events
/geekstuff
/justdont
/languages
/languages/bash
/linkshot
/magazines
/meta
/misctech
/movies
/nottech
/operatingsystems
/operatingsystems/linux
/operatingsystems/linux/debian
/operatingsystems/solaris
/perl
/presentations
/programming
/python
/ruby
/security
/security/apache
/security/tools
/serversmells
/services
/services/dns
/sites
/specifications
/sysadmin
/testing
/tools
/tools/commandline
/tools/firefox
/tools/gui
/tools/network
/tools/online
/tools/online/greasemonkey
/tools/puppet
/unixdaemon

Archives:

July 20111
June 20112
May 20113
April 20112
March 20117
January 20111
December 20103
November 20103
August 20101
July 20101
June 20104
May 20102
April 20101
March 20108
February 20101
January 20102
Full Archives

Sat, 08 Nov 2008

Disturbing Diffs - Unsafe open?


-  file_move_safe(move_from_path, move_to_path)
+  move_file(move_from_path, move_to_path)

Is move_file not as safe as file_move_safe? Is it safer? Dare I read the other diffs to find out? Am I better off not knowing?

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2008/11/08 13:11 | /programming | Permanent link to this entry | This entry and same date


Events - November 2008
It's actually a good month for dynamic language fans in London as we've got both the London Perl Workshop and the inaugural Ruby Manor - both of which I'll be attending.

Although, as a sysadmin, I feel a little bad about not making it to the Linux 2008 event (organised by the UKUUG) I couldn't really justify the time and cost this year. The talks were a decent selection but not enough to get me up to Manchester on my own budget for a weekend. I'll have to keep an eye out for next years LISA event in London to make up for it.

Last but not least - the FOSDEM 2009 dates have been announced (for the second time). Assuming they don't change during the week I'll be booking those before Xmas. Roll on February!

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2008/11/08 13:06 | /events | Permanent link to this entry | This entry and same date


Dynamic Languages and joining arrays
I've been spending a fair amount of time recently trying to choose my Language of the year for 2009. I've always been a dynamic language fan (yes, I know this means I should be looking further afield for the next one) and I was surprised at how different even such a common task as joining all the elements of an array together, using a given separator, looks between them.

First let's look at the big three, including perl, my current favourite.

  
# perl
$ perl -d -e 1;
DB<1> my @names = qw( A B C);
DB<2> print join(" : ", @names), "\n";
A : B : C

# python
>>> names = ['A', 'B', 'C' ]
>>> " : ".join(names)
'A : B : C'

# ruby
irb(main):009:0> names = [ 'A', 'B', 'C' ]
=> ["A", "B", "C"]
irb(main):010:0> names.join(' : ')
=> "A : B : C"
  

The perl approach is very procedural (ignore the use of the debugger as perl doesn't come with an excellent REPL in the core like the other two) and is the one I'm most familiar with so it's hard for me to be too critical about it. If you like OO then it's not for you.

Next we have Python, which is really growing on me as a language - apart from in this case. Putting the separator first and passing the list in as a parameter just feels very wrong and is the exact opposite of the ruby version, which I much prefer. To me the ruby approach of operating on the array is the most natural version and sits well in my head. As a small 'bonus' I also looked at the PHP equivalent -

  
# PHP
$array = array('A', 'B', 'C');
echo implode(" : ", $array);
  

This is close enough to the perl version that I can't really object to it, other than to (rhetorically) ask why the hell it's called 'implode'?

I guess all I can say in summary is round one to ruby.

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2008/11/08 12:41 | /programming | Permanent link to this entry | This entry and same date


Rebooting Via Proc and the magic sysreq key
You know what the best way to start the day is? I'm pretty sure that it doesn't include a production web server putting its file systems in to read only mode. When this happens most local commands don't work - init, shutdown, telnit and reboot all stop being useful and you have to resort to desperate measures... and here's the desperate measure of the day.

First, check that your system supports the magic sysreq key -


$ cat /proc/sys/kernel/sysrq
1  # nonzero is good

Now you know you have the power to destroy your system through a single incorrect character, have a look at the Redhat Sysrq command reference (you want the 'sysrq' section). We tried to make it sync the disks and reboot - your requirements may vary.


root@web02:~# echo s > /proc/sysrq-trigger
root@web02:~# echo b > /proc/sysrq-trigger

# machine reboots

As techniques go this one's a little obscure but it's very useful in the right circumstances.

Like this post? - Digg Me! | Add to del.icio.us! | reddit this!

Posted: 2008/11/08 12:25 | /tools/commandline | Permanent link to this entry | This entry and same date


books career codinghorrors events geekstuff justdont magazines meta misctech movies nottech operatingsystems/linux operatingsystems/linux/debian operatingsystems/solaris perl programming python ruby security security/apache security/tools serversmells services/dns sites sysadmin testing tools tools/commandline tools/firefox tools/gui tools/network tools/online tools/online/greasemonkey tools/puppet unixdaemon

Copyright © 2000-2010 Dean Wilson XML feed logo