10 Nov 2008, 1:00am
Programming:
by

1 comment

Setting up Perforce Server (p4d) on Mac OS X

This morning I have been attempting to get p4d running on my intel iMac (running MacOS 10.5.5) so I can do some proper development at home.  I easily found the official Perforce guide to launching p4d at start-up with Launchd here, which seemed helpful and simple enough.  But it would seem I am now bogged down in file permission hell, which is something I don’t know allot about as I mainly work on Windows systems…

When I login I get the following message in my Console log and no p4d instance started:
“10/11/08 2:56:59 PM com.apple.launchctl.System[2] launchctl: Dubious ownership on file (skipping): /Library/LaunchDaemons/com.perforce.plist”
The permissions for the plist file are:
-rw-r–r–@ 1 Daniel  staff  700 10 Nov 11:58 /Library/LaunchDaemons/com.perforce.plist
And the permissions for p4 and p4d are:
-rwxr-xr-x@  1 Daniel  staff   580272 10 Nov 11:25 /Developer/Perforce/p4
-rwxr-xr-x@  1 Daniel  staff  1695008 10 Nov 11:25 /Developer/Perforce/p4d

The rest of the perforce files are set to:
-rw-r–r–  1 Daniel  staff   * 10 Nov 13:14 *

I used the example plist file from the perforce website and filled in the details specific for my installation:

<?xml version="1.0" encoding="UTF-8"?>

<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Debug</key>
<false/>
<key>Label</key>
<string>com.perforce</string>
<key>OnDemand</key>
<false/>
<key>ProgramArguments</key>
<array>
<string>/Developer/Perforce/p4d</string>
</array>
<key>EnvironmentVariables</key>
<dict>
<key>P4LOG</key>
<string>/Developer/Perforce/p4log.log</string>
<key>P4PORT</key>
<string>1666</string>
<key>P4ROOT</key>
<string>/Developer/Perforce/p4root</string>
</dict>
<key>RunAtLoad</key>
<true/>
<key>ServiceDescription</key>
<string>Launches Perforce Server</string>
</dict>
</plist>

This plist file works if I use the following command:
launchctl unload /Library/LaunchDaemons/com.perforce.plist

Any help on resolving this would be greatly appreciated, I can start the server manaually for now but it would be great to have it running at start-up or login!  I’ve tried using the same plist file in the /Library/LaunchedAgents/ folder but I get the same results :(

Solution!

The following solution is from Perforce technical support, the owner and group of the plist file should be root:wheel which can be achieved by the following command:
sudo chown root:wheel /Library/LaunchDaemons/com.perforce.plist
The file should look like this after the change:
-rw-r–r–  1 root  wheel  797 11 Nov 11:01 com.perforce.plist

DjangoCon 2008: Why I hate Django.

This amusing keynote speech from DjangoCon 2008 by Cal Henderson is well worth a watch.

DIY Social Bookmarking buttons in WordPress

I recently redesigned the theme I am using for this blog and one of the things I’m happiest about is that the social link buttons are now in the footers of my posts along with the tag, category and poster information. This is where I’ve always wanted these buttons to live and I thought that how I achieved this may be of interest to others.

I’ve wanted to add link buttons to the end of my tops for social bookmarking sites like Digg, StumbleUpon and reddit, etc for a while now but never quite managed to get the syntax correct when trying to build the links myself in php. Recently I discovered the excellent sociable plug-in for WordPress that allows you to add link buttons for almost sixty different social bookmarking sites to the end of your posts, which is very handy. However I was not a great fan of where these buttons were inserted: right at the end of the text body of the post.

I decided I’d really prefer the buttons be placed in the post footer area for each post, so I started looking through the source of the sociable plug-in to see how it generated its links and it turns out it was pretty simple. The following php function is what I ended up with. It will build link buttons for five social bookmarking sites: del.icio.us, digg, reddit, stumbleupon and technorati.

function my_social_links() {
	$post 		= $wp_query->post;
	$permalink 	= urlencode(get_permalink($post->ID));

	$title 		= urlencode(get_the_title($post->ID));
	$title 		= str_replace('+','%20',$title);

        $templateDir = get_bloginfo('template_directory');

	echo '<a href="http://del.icio.us/post?url='.$permalink.'&amp;amp;amp;amp;amp;amp;amp;title='.$title.'">';
	echo '<img src="'.$templateDir.'/images/delicious.png" title="del.icio.us"/>';
	echo '</a>';

	echo '<a href="http://digg.com/submit?phase=2&amp;amp;amp;amp;amp;amp;amp;url='.$permalink.'&amp;amp;amp;amp;amp;amp;amp;title='.$title.'">';
	echo '<img src="'.$templateDir.'/images/digg.png" title="digg"/>';
	echo '</a>';

	echo '<a href="http://reddit.com/submit?url='.$permalink.'&amp;amp;amp;amp;amp;amp;amp;title='.$title.'">';
	echo '<img src="'.$templateDir.'/images/reddit.png" title="reddit"/>';
	echo '</a>';

	echo '<a href="http://www.stumbleupon.com/submit?url='.$permalink.'&amp;amp;amp;amp;amp;amp;amp;title='.$title.'">';
	echo '<img src="'.$templateDir.'/images/stumbleupon.png" title="StumbleUpon"/>';
	echo '</a>';

	echo '<a href="http://technorati.com/faves?add='.$permalink.'">';
	echo '<img src="'.$templateDir.'/images/technorati.png" title="Technorati"/>';
	echo '</a>';
};

The programmers amongst you will notice the recurring pattern in how the permalink and title are concatenated into the required URL format for each site. And that the interesting bit of code is the first part where the post permalink and titles are retrieved and then URL encoded so they can be embedded into the links. I added the above function to my functions.php file, so I can access it from anywhere and I currently call it from the loop on my main index page and on the single post pages.

I’d also like to recommend using the SyntaxHighlighter plug-in for WordPress for your code highlighting needs as it is more wordpress compatible and does not have issues with the TinyMCE editor stripping out tags or replacing ‘ with %27.

The great contacts shuffle

It took me a while to figure out the exact steps required to get my contacts on my mobile phone onto my Blackberry and to first wipe the current contacts off the Blackberry.  Thankfully the task was not as complex as I first feared or as tedious as sending each vCard between each device manually (which I’ve had to do in the past when upgrading phones)!  The only extra software that was required was the excellent Blackberry Desktop software for the Mac which you can find here, as iSync is included with Mac OS X.

  1. Syncing the Blackberry’s contacts to my iMac’s Address Book and then deleting all the contacts from Address Book.  The contacts on the Blackberry were all old contacts from Outlook at work which were  originally from my old Palm PDA, so I did not need them any more.
  2. Syncing the Blackberry to the iMac Address Book to wipe the contacts off the Blackberry.
  3. Syncing contacts from my old mobile phone to iMac’s Address book and then syncing the Blackberry to the newly populated Address Book on the iMac was very easy as iSync automatically recognised my Motorola Razr phone and set-up syncing with address book automaticallly.

My PDAs over the years

It is interesting to see how the personal organiser has morphed into the PDA which then morphed into a media device and now into a phone. Over the years I’ve lusted after and I’ve owned a number of PDA devices ranging from the sleek Palm Vx to the basic Palm Zire and now I’ve finally caught up a bit with the trend and have a mobile phone / PDA hybrid device: a Blackberry. I can remember being fascinated by devices like the Psion 3, Psion 5 and Psion Revo series of PDAs which all featured a miniature computer style form factor with monochrome screens and keyboards.  Then PDAs embraced touch screens with devices like the original Palm Pilot, Apple Newton and various Microsoft offerings.

The first PDA I owned was the super slick Palm Vx pictured on the left, it had 8mb of memory, a gorgeous aluminum body and the latest PalmOS.  I can remember working through various add-ons for this PDA over the years including USB syncing, OS upgrades and various carrying cases.  This device really cemented my love of Palm devices as they always performed their main function brilliantly: keeping you organised.  Other devices could connect to the internet, play music or videos but nothing I tried came close to the Palm organiser software or its PC counterpart: Palm Desktop.  From the get go Palm organisers could also sync with Microsoft Outlook but Outlook and Palm did not share the same organisation model so syncing could be a bit hit or miss.

I eventually sold my beloved Palm Vx in favor of upgrading to an HP Jordana 710 as I was seduced by its keyboard, storage options and the potential of a Wireless network card for mobile browsing.  However on taking delivery of the unit and some initial experimentation I sent it back for a refund as several things including the lack of a screen catch made it not a particularly well thought out piece of hardware.  Unfortunately as I’d already sold my Palm Vx to afford the Jordana I was left without a PDA for a while until Palm released the original super cheap Palm Zire which for a bargain 50 GBP I could not resist and it let me pick up the latest version of my favorite mobile operating system.

One of the best things about the Zire series was that they charged and synced by USB by default unlike the Palm Vx which was a serial device which you could upgrade to use USB, although it never worked great over USB in my experience.  I eventually outgrew the mere 2mb of memory the original Zire came with so upgraded to its bigger brother the Zire 21 with a whole 8mb of memory.  This device lasted for a long time until I started to outgrow it too and started looking around for something with more memory and a faster CPU than the Zire 21.

My next upgrade was to the new Palm Z22 which was the successor for the Zire 31 but they shortened the Zire title down to Z.  This model featured a faster processor, colour screen and 32mb of memory which for a Palm at the time was huge.  My only real gripe with this model and indeed the whole Zire series was the move away from the four application buttons that the original palms had: calender, contacts, tasks and memos to just two application buttons: calender and contacts (which I always changed to tasks).  One of the best new features on the Z22 was the new Agenda view in the calender application that showed both your next couple of appointments and the tasks at the top of your task list.

And now I have another new PDA device that is not a Palm for the first time in years. I’ve just recieved a Blackberry 8700v from a family member in the UK who just got a newer model.  My main desire for getting a Blackberry was to combine my mobile phone and PDA into one device. I had been looking at getting a Palm smartphone but then the offer of a free Blackberry came up.  I’m looking forward to getting to grips with a Blackberry after hearing so much about them.  As I’ve never really used a mobile phone for web browsing or email due to text input being so painful, I’ll be interested to see how it is on a device like a Blackberry with a miniature QWERTY keyboard.  I’m also interested to see if the Blackberry works better syncing against Outlook than a Palm device typically does.