Christopher Murtagh http://christopher.murtagh.name co-founder, Blamey & Stella Information Company and onetimesecret.com, Linux and Open Source Software enthusiast, musician, geek and dad. Wed, 09 May 2012 04:18:25 +0000 en hourly 1 http://wordpress.org/?v=3.3.2 Bruce Schneier schools Sam Harris http://christopher.murtagh.name/2012/05/09/bruce-schneier-schools-sam-harris/ http://christopher.murtagh.name/2012/05/09/bruce-schneier-schools-sam-harris/#comments Wed, 09 May 2012 03:28:22 +0000 cmurtagh http://christopher.murtagh.name/?p=190 Unlike some readers, I wouldn’t call Sam Harris a ‘racist’ (religions or ideologies aren’t races) or even a bigot. He thinks he’s actually got a good argument when he calls for profiling by the TSA. On face value, his arguments might seem sound, perhaps even nearly convincing – even though there’s a nagging feeling that what he’s saying just isn’t right. One of the problems is that it’s sometimes hard to tell if that nagging feeling is simply an emotional reaction to something due to our need to be politically correct (which I would argue is rarely a good reason to make these sorts of decisions) or if it’s because his argument is inherently flawed.

Fortunately, Bruce Schneier makes it very clear that it’s the latter, and that profiling is A Bad Idea™. Security in general (computer or otherwise), is often a more difficult problem than most people will admit. When you start to add politics, social norms, a need and desire for tolerance, good will, personal freedom and a revulsion of tyranny it becomes a more complex. I’m glad that Schneier is as good at getting his ideas across as Sam is – it would be a shame for the better idea to lose out because it’s not articulated as well as a bad one.

Despite this, I’m looking forward to hearing Sam’s counter argument. However, since I wasn’t convinced by his initial argument (and I find Bruce Schneier very convincing), I don’t expect he will change my mind on this.

As an aside: This is an example of what I really like about the skeptical/rational community. Sam was willing and did post a counter argument to his (one that was devestating to his postion in my view) on his own blog. Good ideas are allowed to win in an open dialogue.Veritas rex.

]]>
http://christopher.murtagh.name/2012/05/09/bruce-schneier-schools-sam-harris/feed/ 0
Clever bash hack http://christopher.murtagh.name/2012/04/20/clever-bash-hack/ http://christopher.murtagh.name/2012/04/20/clever-bash-hack/#comments Fri, 20 Apr 2012 18:55:37 +0000 cmurtagh http://christopher.murtagh.name/?p=175 I stubled across this from a colleague at my new gig:

#!/bin/bash if uname -r | { IFS=.- read -r a b c _; [ "$((a*10000+b*100+c))" -lt 20622 ]; }; then echo 'Your kernel is too old!'; else echo 'Your kernel is 2.6.22 or newer!' fi ]]>
http://christopher.murtagh.name/2012/04/20/clever-bash-hack/feed/ 0
What nerds do for fun http://christopher.murtagh.name/2012/04/19/what-nerds-do-for-fun/ http://christopher.murtagh.name/2012/04/19/what-nerds-do-for-fun/#comments Thu, 19 Apr 2012 02:44:23 +0000 cmurtagh http://christopher.murtagh.name/?p=185 So, I was logging in to an account with my registrar today, and there was a notice saying that ‘.in’ domains were on sale for $2.48. I couldn’t resist, it is the best $3 I’ve ever wasted.

]]>
http://christopher.murtagh.name/2012/04/19/what-nerds-do-for-fun/feed/ 0
Back from my social ‘vacation’ http://christopher.murtagh.name/2012/04/04/back-from-my-social-vacation/ http://christopher.murtagh.name/2012/04/04/back-from-my-social-vacation/#comments Wed, 04 Apr 2012 16:42:31 +0000 cmurtagh http://christopher.murtagh.name/?p=165 It’s been a while since I posted anything here, I blame winter plus a host of all sorts of things that have been keeping me busy. Since the last blog post, there have been a number of things. Delano and I released One-Time Secret, along with Ruby, PHP and (thanks to Kyle Dawkins) Perl client libraries for using the API. OTS was a bit of distraction from our work on Blame Stella, but rest assured that work on Blame Stella 2.0 is still under way. We should have news on both of these projects in the near future.

In this time, I did write a couple of blog posts for One-Time Secret. If you haven’t seen them, they’re here:

I’ve got a bunch of exciting new things on the horizon that I can’t announce yet, but will in the very near future.

]]> http://christopher.murtagh.name/2012/04/04/back-from-my-social-vacation/feed/ 0 SimpleRSSEmbed – my first WordPress plugin http://christopher.murtagh.name/2011/12/12/simplerssembed-my-first-plugin/ http://christopher.murtagh.name/2011/12/12/simplerssembed-my-first-plugin/#comments Mon, 12 Dec 2011 09:49:41 +0000 cmurtagh http://christopher.murtagh.name/?p=137 Ok, I’ve been doing all sorts of things with WordPress for a while now, but oddly enough, I never actually wrote a plugin (although, in retrospect, I did a lot of template hacks that probably would have been easier to do as plugins). Anyway, I needed a plugin for a blog I was working on that would allow me to display the summary of N number of blog posts from another blog. There seem to be plenty of existing plugins that do this, however most of them are either horrible code (both HTML and PHP), or they don’t work with Atom feeds that don’t have descriptions. I wanted something very simple, with very clean output that would ‘just work’™. So, after trying about a dozen of them, I decided to just write my own (which turned out to be insanely easy). If I would have started down that path at first, I probably would have been done sooner.

So, if anyone is interested in this very simple plugin, here it is. Of course, it’s GPL. I expect I’ll be adding more features to it as I need, but for now this does exactly what I want with very little code to maintain.

Documentation

Download

You can get the current version from here: simplerssembed.zip

Installation

Put the contents of simpleressembed.zip into your wp-contents/plugins directory, and unzip it. This should give you a directory called ‘simpleressembed’ which has 3 things in it:

  • an empty directory called ‘cache’
  • a file called readme.txt
  • a file called simplerssembed.php

Make sure that the cache directory is writeable by your web server, or whatever user that will be executing the php scripts. The safest way (on *nix system) is to do the following (assuming that the process runs as the user ‘apache’:

[root@ simplerssembed]# chown apache: cache [root@ simplerssembed]# chmod 755 cache

Then go to the plugins tool in your WP dashboard, and activate the plugin.

Using the plugin

Once the plugin is activated, you can embed RSS feeds with the following shortcode:

[simplerssembed rssfeed='http://wordpress.org/news/feed/' rssitems='5' rsscssclass="rssfeeditem" rssdateformat="j F Y" rsslinktarget="_new"]

Parameters

The currently defined parameters are as follows:

rssfeed -> URI of the RSS feed rssitems -> The number of items to display rssmaxdescription -> The maximum number of summary characters to display rsscssclass -> The class name to give the containing <div> (per item) rsslinktarget -> The target attribute for the link to the post rsscacheduration -> The duration (in seconds) of the cache rssdateformat -> The data format (see PHP's date function)

Default values

The default values for the above parameters are:

rssfeed => 'http://wordpress.org/news/feed/' rssitems => '5' rssmaxdescription => '400' rsscssclass => 'rssitem' rsslinktarget => '_self' rsscacheduration => '3600' rssdateformat => 'j F Y | g:i a'

Example output:

This is output from the actual code above:

Plugin Directory Refreshed

Been hanging out with a few WordPress.org hackers — Scott, Nacin, and Otto — the last few days in a BBQ-fueled haze of hacking to make plugin directory better. There are over 19,000 plugins listed and they’re really the heart and soul of WordPress for many people, so they deserve a little tender loving care. [...]

Posted on 19 May 2012

Calling All Contributors: Community Summit 2012

Each year, the WordPress core development team meets in person for a week to work together and discuss the vision for WordPress in the coming year. As annual events go, it’s easily my favorite. Don’t get me wrong, I love attending WordCamps and local WordPress meetups (which are awesome and you should try to attend [...]

Posted on 15 May 2012

WordPress 3.4 Beta 4

Less bugs, more polish, the same beta disclaimers. Download, test, report bugs. Thanks much. /ryan #thewholebrevitything

Posted on 3 May 2012

WordPress 3.3.2 (and WordPress 3.4 Beta 3)

WordPress 3.3.2 is available now and is a security update for all previous versions. Three external libraries included in WordPress received security updates: Plupload (version 1.5.4), which WordPress uses for uploading media. SWFUpload, which WordPress previously used for uploading media, and may still be in use by plugins. SWFObject, which WordPress previously used to embed [...]

Posted on 20 April 2012

WordPress 3.4 Beta 2

Howdy, folks! Another week, another beta. Since we released Beta 1 last week, we’ve committed more than 60 bug fixes and feature adjustments based on testing and feedback. If you’ve been testing Beta 1, please update to Beta 2 to make sure things are still working for you. If you are a theme or plugin [...]

Posted on 12 April 2012

]]>
http://christopher.murtagh.name/2011/12/12/simplerssembed-my-first-plugin/feed/ 0
Upgrading software RAID drives (and increase capacity) http://christopher.murtagh.name/2011/12/07/upgrading-software-raid-drives-and-increase-capacity/ http://christopher.murtagh.name/2011/12/07/upgrading-software-raid-drives-and-increase-capacity/#comments Wed, 07 Dec 2011 06:07:51 +0000 cmurtagh http://christopher.murtagh.name/?p=72 Disclaimer: This is one of those semi-selfish posts, where I need to perform a task that I do only once in a while. So, to save myself from having to search these steps every time, I’m documenting it here. I hope someone else will find this useful as well.

Recently, I decided to upgrade the drives in my desktop. Since I don’t like the idea of downtime due to a failed drive (my desktop is also my home file server and firewall/router/dhcp server), I use software RAID1. The cost of an extra drive has been well worth the time saved from the last couple of HD failures I’ve had (including the lousy refurbished Seagate RMA drives). My initial array was 2 Seagate ST3750330AS (750GB, 32MB cache, 3Gb/s). They’re reasonably good drives, and I’ve had them for 4 years or so. For the same price I bought these drives for a couple of years ago, I managed to get 2 Western Digital WD1002FAEX-00Z3A0 (1TB, 64MB cache, 6Gb/s). So, a bit more space and faster drives. Now, the trick was to upgrade them without any downtime (other than the time to drives), or the need to resort to copying data off and/or restoring from backups (backups are important, but that’s another topic). In my setup, I have 2 drives (/dev/sda and /dev/sdb) which are combined to make 2 MD devices, /dev/md0 (my /boot partition, which is 100MB) and /dev/md1 (a physical volume used for LVM, and is the rest of the drive). Here are the steps I had to take to do this:

Step 1. Remove one drive from the array

Flag one of the drives as ‘faulty’ so that it can be removed from the array. In this case, I’m going to start with /dev/sda, but I could easily also use /dev/sdb. The command below will remove both partitions (sda1 and sda2) from their respected raid devices (md0 and md1) and set the drive as ‘failed’.

[root@ ~]# mdadm /dev/md0 --fail /dev/sda1 mdadm: set /dev/sda1 faulty in /dev/md0 [root@ ~]# mdadm /dev/md1 --fail /dev/sda2 mdadm: set /dev/sda2 faulty in /dev/md1

Step 2. Physically replace ‘failed’ drive

I then safely removed the ‘failed’ disk from my tower (kept is as a safety backup too), and replaced it with one of the 1TB drives.

Step 3. Copy partition data from old drive to new

I dumped the partition scheme from sda to sdb. This would have been more important if I was replacing the drive with an identical one (in the case of a drive failure). However, this would allow me to be sure that my md0 (/boot) partitions were the same size. IMPORTANT: Make sure you put the devices below in the right order, otherwise very, very bad things will happen.

[root@ ~]# sfdisk -d /dev/sdb | sfdisk /dev/sda

If the above step looks too scary for you, then you might want to save the partition map to a file first, to at least have a chance of recovering it should you mess up. Here’s how:

[root@ ~]# sfdisk -d /dev/sdb > partition_backup.txt

Step 4. Replace 2nd partition with bigger one

Next I used fdisk to delete the 2nd partition so that it will be larger (almost 1TB instead of almost 750GB)

[root@ ~]# fdisk /dev/sda Command (m for help): p Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sda1 * 63 208844 104391 fd Linux raid autodetect /dev/sda2 208845 1465144064 732467610 fd Linux raid autodetect Command (m for help): d Partition number (1-4): 2 Command (m for help): n Command action e extended p primary partition (1-4) p Partition number (1-4, default 2): 2 First sector (208845-1953525167, default 208845): [enter] Using default value 208845 Last sector, +sectors or +size{K,M,G} (208845-1953525167, default 1953525167): [enter] Using default value 1953525167 Command (m for help): t Partition number (1-4): 2 Hex code (type L to list codes): fd Changed system type of partition 2 to fd (Linux raid autodetect) Command (m for help): p Disk /dev/sda: 1000.2 GB, 1000204886016 bytes 255 heads, 63 sectors/track, 121601 cylinders, total 1953525168 sectors Units = sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disk identifier: 0x00000000 Device Boot Start End Blocks Id System /dev/sda1 * 63 208844 104391 fd Linux raid autodetect /dev/sda2 208845 1953525167 976658161+ fd Linux raid autodetect Command (m for help): w The partition table has been altered! Calling ioctl() to re-read partition table. Syncing disks.

Now I’ve got 2 drives with 1 partition (for /boot) that is exactly the same size, and the second partition on the second drive is almost 1TB instead of 750GB. Software RAID is ok with this, and it will allow me to add both partitions to my previous RAID devices, however each device will only be the size of the smallest partition. I could have taken the opportunity to increase the size of md0 if I wanted to, but didn’t really need to.

Step 5. Update MBR for Grub

OK, this is going to assume you’re using grub as your bootloader and that it’s on the MBR. Since a drive has been replaced, this needs to updated otherwise the machine might not reboot.

[root@mafalda ~]# grub GNU GRUB version 0.97-75.fc15 (640K lower / 3072K upper memory) grub> root (hd0,0) root (hd0,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd0) setup (hd0) Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/e2fs_stage1_5" exists... yes Running "embed /grub/e2fs_stage1_5 (hd0)"... 26 sectors are embedded. succeeded Running "install /grub/stage1 (hd0) (hd0)1+26 p (hd0,0)/grub/stage2 /grub/grub.conf"... succeeded Done. grub> root (hd1,0) root (hd1,0) Filesystem type is ext2fs, partition type 0xfd grub> setup (hd1) setup (hd1) Checking if "/boot/grub/stage1" exists... no Checking if "/grub/stage1" exists... yes Checking if "/grub/stage2" exists... yes Checking if "/grub/e2fs_stage1_5" exists... yes Running "embed /grub/e2fs_stage1_5 (hd1)"... 26 sectors are embedded. succeeded Running "install /grub/stage1 (hd1) (hd1)1+26 p (hd1,0)/grub/stage2 /grub/grub.conf"... succeeded Done. grub> quit quit

Step 6. Add drive back to array

Next step is to add this drive back to the RAID array and rebuild.

[root@ ~]# mdadm /dev/md0 --add /dev/sda1 mdadm: added /dev/sda1 [root@ ~]# mdadm /dev/md1 --add /dev/sda2 mdadm: added /dev/sda2

Step 7. Wait, wait, wait

After that, I wait for the RAID to rebuild and show up in a 'clean' state. Since this is 750GB of data that needs to sync, it means several hours. So, I keep checking the state of the array until I see this: [root@mafalda ~]# mdadm --detail /dev/md1 /dev/md1: Version : 0.90 Creation Time : Fri Mar 14 23:36:49 2008 Raid Level : raid1 Array Size : 732467520 (698.54 GiB 750.05 GB) Used Dev Size : 732467520 (698.54 GiB 750.05 GB) Raid Devices : 2 Total Devices : 2 Preferred Minor : 1 Persistence : Superblock is persistent Update Time : Tue Nov 29 04:01:16 2011 State : clean Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 UUID : bad9d783:9b7b40be:9fd48ad3:7334f5c6 Events : 0.3555449

Step 8. Rince, lather and repeat

Repeat steps 1-7 using sdb instead of sda and vice versa.

Step 9. Resize the raid partition

After both drives have been replaced, the second RAID device is still only 750GB. It needs to be modified to bring it up to 1TB. This is the command to do that:

[root@ ~]# mdadm --grow /dev/md1 --size=max mdadm: Limited v0.90 array to 2TB per device mdadm: component size of /dev/md1 has been set to 976658048K

Checking the status of the device will show it's new size, and it's back to the waiting game.

[root@ ~]# mdadm --detail /dev/md1 /dev/md1: Version : 0.90 Creation Time : Fri Mar 14 23:36:49 2008 Raid Level : raid1 Array Size : 976658048 (931.41 GiB 1000.10 GB) Used Dev Size : 976658048 (931.41 GiB 1000.10 GB) Raid Devices : 2 Total Devices : 2 Preferred Minor : 1 Persistence : Superblock is persistent Update Time : Tue Nov 29 04:01:27 2011 State : active, resyncing Active Devices : 2 Working Devices : 2 Failed Devices : 0 Spare Devices : 0 Rebuild Status : 0% complete

Step 10. Resize the LVM physical volume

Now that the RAID device has been resized, the next step is to resize the LVM physical volume. The pvdisplay command confirms it:

[root@ ~]# pvresize /dev/md1 Physical volume "/dev/md1" changed 1 physical volume(s) resized / 0 physical volume(s) not resized [root@ ~]# pvdisplay --- Physical volume --- PV Name /dev/md1 VG Name mafalda_gv PV Size 931.41 GiB / not usable 7.44 MiB Allocatable yes PE Size 32.00 MiB Total PE 29805 Free PE 1053 Allocated PE 28752 PV UUID SoHDMC-kf1N-YgsY-D5wq-tTE0-Z1sq-MKlTCR

Step 11. Adding adding the extra space to my /home partition

I've pretty much done all the necessary things that this post has set out to do. If I wanted to add 200GB of this data to say, my /home partition (the 'home_lv' logical volume in the 'mafalda_vg' volume group), this is what the commands would be:

[root@ ~]# lvresize -L +200G /dev/mapper/mafalda_vg-home_lv

Then I would need to grow the ext[2|3|4] filesystem, which can also be done online

[root@ ~]# resize2fs /dev/mapper/mafalda_vg-home_lv

That would effectively add 200GB to my /home partition. All done with minimal downtime (the time to swap physical drives).

]]>
http://christopher.murtagh.name/2011/12/07/upgrading-software-raid-drives-and-increase-capacity/feed/ 0
Short video on FounderFuel http://christopher.murtagh.name/2011/11/30/short-video-on-founderfuel/ http://christopher.murtagh.name/2011/11/30/short-video-on-founderfuel/#comments Wed, 30 Nov 2011 23:53:46 +0000 cmurtagh http://christopher.murtagh.name/?p=68 A bunch of folks were asking me what FounderFuel is, and I’ve tried to explain what a StartUp accelerator/incubator is. Here’s a nice little promo video on what FounderFuel is all about.

]]>
http://christopher.murtagh.name/2011/11/30/short-video-on-founderfuel/feed/ 0
Carlsberg ad http://christopher.murtagh.name/2011/11/24/carlsberg-ad/ http://christopher.murtagh.name/2011/11/24/carlsberg-ad/#comments Thu, 24 Nov 2011 18:43:29 +0000 cmurtagh http://christopher.murtagh.name/?p=62 This is a great ad. It says a lot about our impressions, our fears and prejudices. A whole paper could be written on why some folks left and the body language of the couples coming in. The ending is uplifting too.

]]>
http://christopher.murtagh.name/2011/11/24/carlsberg-ad/feed/ 0
Hello (again) world! http://christopher.murtagh.name/2011/11/22/hello-world/ http://christopher.murtagh.name/2011/11/22/hello-world/#comments Tue, 22 Nov 2011 20:58:37 +0000 cmurtagh http://christopher.murtagh.name/?p=1 Wow, it’s been a while since I’ve had a professional blog, (back when I was working for Terra Soft and managing YDL.net in fact) and my own website was worse than terrible. It’s ironic, because I was too busy building medium and large web systems for universities, SMBs and ISPs to actually keep my own site up to date. I still wish I had it, because I used it as a place to store tidbits of things I needed to do fairly infrequently, but then would have to look them up every time. Tons of little things like this link that my friend Rich Lafferty (@mendel) shared on Twitter recently. I’ll probably dig up the archives of my old blog and slowly put some of them back and pre-date them to their original post date. So, while this is my ‘first post’ under this new blog, there will be posts that pre-date this.

I’ve often got things I’d like to share, or better still, discuss with other sysadmin friends, and Facebook doesn’t seem to do it for professional content, or for things that are worth keeping around – everything get lost in Facebook’s firehose way too quickly.

]]>
http://christopher.murtagh.name/2011/11/22/hello-world/feed/ 0
Postgresql, plperl and custom rowtypes http://christopher.murtagh.name/2007/09/14/postgresql-plperl-and-custom-rowtypes/ http://christopher.murtagh.name/2007/09/14/postgresql-plperl-and-custom-rowtypes/#comments Fri, 14 Sep 2007 07:21:51 +0000 cmurtagh http://christopher.murtagh.name/?p=43 I had a problem that I needed to solve recently, and the most elegant way to do this was with a stored procedure. However, the procedure needed to return 2 columns – an index id and a sort order. One way to tackle this is to have the plperl function called by a wrapping plpgsql function, but that’s ugly. I wanted to do it all in plperl, but couldn’t find any documentation on it with custom rowtypes. So, off to IRC for some info.

xzilla on #postgresql (irc.freenode.net) pointed me out to a recent blog posting of his that seemed to do what I wanted using Out parameters. This was really great, and I knew I had something I could work with there. Thanks xzilla!

So, I took it a bit further and modified his example slightly to see if I could also do it without the out parameters and just use the rowtype. Here’s the result:

CREATE TYPE footype AS (number int, oddoreven text);

CREATE OR REPLACE FUNCTION odd_or_even(int) RETURNS SETOF footype
AS $$
my @Return;
my $Count = 1;
my $Input = $_[0];

while ($Count <= 10) {
  if ($Input%2 == 0) {
     push @Return, { number => $Input, oddoreven => 'even' }
  } else {
     push @Return, { number => $Input, oddoreven => 'odd' }
  }
 $Count++;
 $Input++;
}

 foreach my $Row (@Return) {
     return_next $Row;
 }
 return;

$$ LANGUAGE plperl;

test=# SELECT * FROM odd_or_even(23)
test=# ORDER BY odd_or_even.oddoreven;
 number | oddoreven
--------+-----------
     24 | even
     26 | even
     28 | even
     30 | even
     32 | even
     23 | odd
     25 | odd
     27 | odd
     29 | odd
     31 | odd
(10 rows)
]]>
http://christopher.murtagh.name/2007/09/14/postgresql-plperl-and-custom-rowtypes/feed/ 0