WordPress on OSX (10.6.8), Apache, PHP & htaccess

I’ve just managed to get OSX 10.6.8 to work with mod_rewrite and .htaccess to be able to let WordPress rewrite it’s URLs. Here is what I did.

I installed WordPress to my homefolder so I’ll access it using http://localhost/~ola/wordpress. Apache is configured to use a split config in OSX so to change the directives for the home folder you change the file /private/etc/apache2/users/Ola.conf. I changed AllowOverride None to AllowOverride All and restarted Apache.

I got a 403 Permission denied message. I checked the Apache error log /var/log/apache2/error_log. It said: [Mon Nov 28 16:30:47 2011] [error] [client] Options FollowSymLinks or SymLinksIfOwnerMatch is off which implies that RewriteRule directive is forbidden: /Users/Ola/Sites/slipstream/wp-admin/options-permalink.php, referer: http://localhost/~ola/slipstream/wp-admin/options-permalink.php

I added the Options directive FollowSymLinks to /private/etc/apache2/users/Ola.conf, restarted Apache and it worked fine.

I’m only using this config as a development box so I’m not sure if it has any security implications. If you have any knowledge about this just let me know.

Using Motion webcam software to capture an image every 30 seconds

Sometimes I use a webcam to capture images that I then use for time lapse videos. Other times I use my old Canon camera with CHDK and an interalometer script.

I have been trying to find a simple and robust webcam tool for this for years but all packages are too complicated and anoying. I just want to take an image every 30 seconds and be done with it. No HTTP server. No fancy scheduling. Nothing more than getting my images from the camera.

In Windows I have tried webcamXP and that’s pretty good. In Linux I have been running Motion. It’s a full featured motion detection package. Capable of much more than I want.

I adjusted the config file for Motion to only save one image every 30 seconds. Just as I want it.

My Motion config file (~/.motion/motion.conf)

# Motion is a webcam software that is designed for doing motion detection.
# I made the most simple config I could to disabled all motion detection
# features. Instead I just use it to take one picuture every 30 seconds.
# It's configured for giving the hightest quality possible with a
#   046d:0992 Logitech, Inc. QuickCam Communicate Deluxe
# Visit the web site for more information about Motion
#   http://www.lavrsen.dk/foswiki/bin/view/Main/WebHome

snapshot_interval 30
width 1280
height 960
quality 95
text_right ""
target_dir /home/ola/webcam/capture
snapshot_filename %Y-%m-%d/%Y%m%d-%H%M%S

process_id_file /var/run/motion/motion.pid
output_normal off
v4l2_palette 1
framerate 2

Multiple user profiles for Google Chrome

Recently I wanted to set up multiple profiles in Google Chrome. One for my personal browsing and one for my work. This way I don’t need to sign in and out from my different google, twitter, flickr and facebook accounts.

There is no GUI for this and it involves running some command line but it’s not too hard.

You should run all commands on one line and make sure to change the paths to your user name and profile.

Windows 7 / Vista

First you make a copy of your current default profile. You can do it either in Windows Explorer on on the command line.

xcopy "C:UsersOlaAppDataLocalGoogleChromeUser DataDefault" "C:UsersOlaAppDataLocalGoogleChromeUser DataOla" /e /i /h

Then you reset your new profile

C:UsersOlaAppDataLocalGoogleChromeApplicationchrome.exe --user-data-dir="C:UsersOlaAppDataLocalGoogleChromeUser DataOla" -first-run

Then you create a new shortcut on your desktop to launch your new profile

C:UsersOlaAppDataLocalGoogleChromeApplicationchrome.exe --user-data-dir="C:UsersOlaAppDataLocalGoogleChromeUser DataOla"

Ubuntu 10.10 (Linux)

Copy default profile

cp -r /home/ola/.config/google-chrome/Default/ /home/ola/.config/google-chrome/Ola

Reset your new profile

/opt/google/chrome/google-chrome --user-data-dir="/home/ola/.config/google-chrome/Ola" -first-run

And add a new Launcher (shortcut)

/opt/google/chrome/google-chrome --user-data-dir="/home/ola/.config/google-chrome/Ola" -first-run

That’s all there is to it.


Making screencasts for Youtube with CamStudio

Yesterday I needed to find a simple and robust solutions for recording a screencast. It turned out to be not as easy as I thought.

To get a similar workflow as with my other video editing I wanted it to work like this:

  1. Record a 1280 x 720 section from my screen to a high quality format
  2. Open and edit the recorded file in Sony Vegas Platinum 8
  3. Render it from Vegas to a lossless format
  4. Re-render it using HandBrake
  5. Upload the file to Youtube

Record with CamStudio

I started out with the latest beta of CamStudio. It a nice, simple and easy tool that does what I need.

My first attempt was to save an AVI file with the included Microsoft Video 1 codec. The quality was pretty low so I tried to use the CamStudioCodec (from their web site). I got a nice looking AVI. However Vegas didn’t really like this file. It worked, but it was very slow.

Then I tried to use the Huffyuv codec that I had installed recently when I optimized my HDV workflow. It created a BEAUTIFUL HUGE file that I could work with in Vegas. I edited the file, normalized the audio and rendered the video almost exactly the same way as I render all my other videos (described in my HDV workflow). I just lowered the resolution from 1440 x 1080 to 1280 x 720.

Re-render and upload to Youtube

I opened the file in HandBrake and selected the High Profile. I exported the file the same way as in my normal HDV workflow. It created a good looking file. I uploaded it to Youtube. Everything went smooth. Until I looked at the video on Youtube. It came out gray. No video at all. I made a test upload to Vimeo. No problems. I tried with different codecs and settings. Both in Handbrake, Vegas and CamStudio. All came out gray on Youtube.

I tried really hard to understand why this didn’t work but I couldn’t get it to work so I resorted to Avidemux. I opened the file in Avidemux. Selected the MPEG-4 ASP (Xvid) codec for video and MP3 for audio (I increased the quality on both). I exported the file and boom. It worked fine on Youtube.

I’m not sure what went wrong. Or why. And I ended up yet another tool in my belt. But I almost reached my goal of having similar workflows so I’m pleased.

WordPress development environment – Aptana, Virtualbox and Google Code

At work we always have a pretty hefty development environment. At home I’ve never had any dedicated environment for my web development. It’s both a relief and something I miss.

Today I’ll try to set up a WordPress development environment that’s a bit more robust than my old setup where I download the file I need to change from my website to my desktop, change it, upload it and refresh the browser.

The idea is to:

Setup Google Code

I registered mypersonalblog on Google Code. For now I’ll probably mostly use the SVN features so you can swap out Google Code for any other repository.

I created a wp-themes folder in trunk where I’ll put one folder for each theme I use.

I download the theme I want to use from WordPress Themes. I add -ol to the end of the theme folder to not confuse the themes with the original folder names. Then I check it in. This is done to easily be able to track my changes compared to the version I started out from later. Both to be able to see what I have done but also to easily be able to merge updated theme versions further down the road.

I change the styles.css file and add some information. Here is an example from the  Simplr-ol style.css file.

THEME NAME: Simplr-ol
THEME URI: http://code.google.com/p/mypersonalblog/ (Simplr http://www.plaintxt.org/themes/simplr/)
DESCRIPTION: My customizations to Simplr; "The original minimalist one-column, content-centered theme for WordPress. A different type of theme. For WordPress 2.6.x."
VERSION: 4.6.1-0.1
AUTHOR: Ola Lindberg (Simplr by Scott Allan Wallick)
AUTHOR URI: http:///olalindberg.com/wp/ (Simplr http://scottwallick.com/)
TAGS: variable width, fixed width, one column, widgets, theme options, options page, white, orange, blue, microformats, hatom, hcard

If any theme diverges a lot from the original theme I’ll maybe come up with a new name and upload it to WordPress Themes. For now I think it’s good enough to have them all in one Google Code repository.

Setup VirtualBox, Ubuntu, Apache and WordPress

I installed VirtualBox, created an Ubuntu appliance and installed Ubuntu 9.10 desktop. I installed the guest add-ons and Apache. I changed the VirtualBox network to Bridge mode so it get’s its own IP address.

Screenshot from the Network Adapters in VirtualBox. Open it from Devices / Network Adapters...

Update 101118: I recently wanted to make this setup on another computer (using a wireless network card) where I couldn’t get the Bridged Adapter to work. I searched around a bit and it and it seemed like some people had similar issues. Instead I configured VirtualBox to use two network cards. One using NAT (giving internet access) and one using Host-only Adapter.

2 nic setup. The first using NAT providing internet access from my guest
2 nic setup. The second card using Host-only Adapter to be accessible through my Host system.

With this setup you should access you guest os from your host os with the IP address your 2nd network card gets (in Windows).

I created an Apache Virtual Host and installed WordPress to that folder. The production URL is http:///olalindberg.com/wp/ and for the local URL I use http://o/blog. I added the IP for my virtual Ubuntu to the name o i my hosts file. Now I can surf to http://o/blog.

My virtual host is configured like this

	ServerName o
	DocumentRoot /home/ola/shared/web/ola
	#Only put the log file like this in the web root on a local server
	CustomLog /home/ola/shared/web/ola/ola-access.log combined

Share files between my workstation and the virtual Ubuntu server

To share files in VirtualBox I use SharedFolders. The folder on my Windows workstation where I checked out the repository is D:CodingMyPersonalBlog and it’s mapped to the name MyPersonalBlog in Ubuntu.

The VirtualBox Shared Folder dialog. Open it via Devices / Shared Folders...

To mount the folder MyPersonalBlog to /home/ola/MyPersonalBlog in Ubuntu you run the following from an Ubuntu terminal

sudo mount -t vboxsf mypersonalblog /home/ola/MyPersonalBlog

Make sure that the files are visible in you Ubuntu server by running ls -la in the folder.

Note! You need to run this every time you login or you can create a script and make it auto run.

ola@ubuntudevserver:~/MyPersonalBlog/wp-themes$ ls -la
total 28
drwxrwxrwx 1 root root 4096 2010-03-27 11:08 .
drwxrwxrwx 1 root root 4096 2010-01-01 19:09 ..
drwxrwxrwx 1 root root 4096 2009-12-29 11:45 AutoFocus-ol
drwxrwxrwx 1 root root 4096 2010-03-27 11:12 room-34-baseline-ol
drwxrwxrwx 1 root root 4096 2009-12-29 11:13 Simplr-ol
drwxrwxrwx 1 root root 4096 2010-03-27 11:13 .svn
drwxrwxrwx 1 root root 4096 2009-12-29 10:58 veryplaintxt-ol

The last thing to do is to tell WordPress that the themes exists. I do that by creating soft links in the theme folders

ola@ubuntudevserver:~/www/olalindberg.com/wp/wp-content/themes$ ls -la
total 24
drwxrwxrwx 5 www-data www-data 4096 2010-03-27 11:48 .
drwxrwxrwx 6 www-data www-data 4096 2010-03-27 11:20 ..
drwxrwxrwx 2 www-data www-data 4096 2009-12-19 00:22 classic
drwxrwxrwx 3 www-data www-data 4096 2009-12-19 00:22 default
-rw-r--r-- 1 www-data www-data   30 2010-03-27 11:01 index.php
lrwxrwxrwx 1 ola      ola        55 2010-03-27 11:48 room-34-baseline-ol -> /home/ola/MyPersonalBlog/wp-themes/room-34-baseline-ol/
drwxr-xr-x 3 www-data www-data 4096 2009-12-29 10:42 simplr
lrwxrwxrwx 1 ola      ola        45 2010-03-27 11:06 Simplr-ol -> /home/ola/MyPersonalBlog/wp-themes/Simplr-ol/

Now I can enable the themes in the WordPress admin panel.

The WordPress theme administration page

Note! If WordPress can’t see the themes look at the permissions for the shared folder. I set mine to 0777 since it’s a local setup.

Import all posts from the production setup

I use the build in WordPress feature to export all posts and pages to an XML-file. I import that file to my local setup. I include all attachments. Some minutes later I have all my posts in my local development environment.

If I need to re-import all posts I use the plugin Bulk Delete to empty my current local database. Then I empty the Media Library in the WordPress admin panel. One tip is to increase the number Media items per page via the Screen Options.

Setup Aptana

I installed Aptana, created a project file and added all my theme files to it. I have never used Aptana before so it’s a test. We’ll see how it goes.

Upload with Uploadify running in public_html folder

Just to try it out I tried to get Uploadify to work in my public_html folder. I set it up according to the guidelines in the docs/example and ran. It returned success but the file wasn’t uploaded.

My first debug idea was to add an alert to the onError event. It wasn’t triggered.

My second idea was to try and print the response in the onComplete event. I added:

'onComplete': function(event, queueID, fileObj, response, data) {
    alert('onComplete: ' + response)

and it returned:

Warning: move_uploaded_file(/var/www/home/ola/public_html/uploadify/uploads-folder/test-image.jpg) [function.move-uploaded-file]: failed to open stream: No such file or directory in /home/ola/public_html/uploadify/_lib/uploadify.php on line 40

Warning: move_uploaded_file() [function.move-uploaded-file]: Unable to move '/tmp/php1rJUsg' to '/var/www/home/ola/public_html/uploadify/uploads-folder/test-image.jpg' in /home/ola/public_html/uploadify/_lib/uploadify.php on line 40

I guess it’s some rewrite issues when Apache rewrites the /home/ola/public_html folder to /~ola.

I opened uploadify.php (the ”server side code” for Uploadify) and replaced:

$targetPath = $_SERVER['DOCUMENT_ROOT'] . $_REQUEST['folder'] . '/';


$targetPath = $_REQUEST['folder'] . '/';

And it worked.

Write to TinyMCE in a WatiN integration test

Last week I worked on some integration tests in Selenium. Today I’m redoing the same test in WatiN to get a feel for both tools.

Since the application uses TinyMCE for most of it’s text inputs I had to find a way to write to it within the tests. With Selenium Nick Bartlett had a solution. For WatiN I used the Eval method and executed the setContent JavaScript method in the TinyMCE API.

var js = "tinyMCE.get('tinyTextAreaId').setContent('some html');";
var s = Document.Eval(js);

This would work just as good with Selenium and it has one advantage over setting the text areas. It executes the eventual cleanup rules in TinyMCE before it sets the text.

Start and stop Selenium Server with NUnit

I want to have our Selenium tests to run automatically the same way as our other NUnit tests does. This means that I want to have the Selenium Server started automatically before running the test cases.

  1. I started by downloading the Selenium RC and unzipped it to C:SeleniumSelenium-RC
  2. I created a .NET project where I referenced the ThoughtWorks DLLs in C:SeleniumSelenium-RCselenium-dotnet-client-driver-1.0.1
  3. I added a new class to where I copied the Selenium getting started C# class
  4. I added my own TestFixtureSetup and a TestFixtureTeardown to this class. TestFixtureSetup launches the Selenium Server and TestFixtureTeardown closes it

Here is the class for starting the Selenium Server and the example Selenium test.

using System;
using System.Diagnostics;
using System.Text;
using NUnit.Framework;
using Selenium;

namespace Test.UI.Web.Selenium
	public class SeleniumGoogleTest
		private ISelenium selenium;
		private StringBuilder verificationErrors;

		private Process seleniumServer;
		private readonly ProcessStartInfo seleniumServerProcessStartInfo = new ProcessStartInfo("java", @"-jar C:SeleniumSelenium-RCselenium-server-1.0.1selenium-server.jar");

		public void TestFixtureSetup() {
			seleniumServer = Process.Start(seleniumServerProcessStartInfo);

		public void TestFixtureTearDown() {

		public void SetupTest()
			selenium = new DefaultSelenium("localhost", 4444, "*iexplore", "http://localhost:4444");
			verificationErrors = new StringBuilder();

		public void TeardownTest()
			} catch (Exception)
				//Ignore errors if unable to close the browser
			Assert.AreEqual("", verificationErrors.ToString());

		public void OpenGoogleWebSite()


Combine Time Lapses with standard DV – Avidemux and Sony Vegas

I’ve just gone trough some hoops to import a time lapse video made in Avidemux into my standard DV project in Sony Vegas. My first issue was to find a suitable video format and the second to get the size of the time lapse video to match the size of the DV format. I’ll go through all steps in an example project below. I’ll use a time lapse with 14 stills and a DV project (PAL, 720×576, 4:3) with one clip.

Sequence the filenames
Avidemux is a bit picky that the file names of the images are in a sequence. I use ReNamer to automatically serialize the images.

I use ReNamer to serialize file names
I use ReNamer to serialize file names

Making the time lapse video in Avidemux
Even though Sony Vegas can import still images I prefer Avidemux for my time lapses.

Open the first image in Avidemux and make sure all frames are visible in the video. Since I’m going to export the video to Sony Vegas I want to use a format that preserves as much quality as possible. I chose Huffyuv.

Select the frame rate you want. I choose 5 fps.

My time lapse images are in 640 x 480 px and my DV stream is in 720 x 576. I’ll resize the images to 768 x 576 px, then I crop 24 px on each side to get a 720 x 576 px image.

Scale the time lapse images in Avidemux
Scale the time lapse images in Avidemux

Save your time lapse video to avi.

To be able to play the video (in Windows Media Player) I had to install a codec for Huffyuv. I installed the latest ffdshow and selected to install Huffyuv only. I also had to enable Huffyuv in ffdshows VFW configuration utility.

Enable the correct codec
Compare the black border in the preview window with the next screenshot

Now you should be able to play the file in Windows Media Player and it’s time to import the video to Sony Vegas!

Import to Sony Vegas and fix the size problem
I start by just adding my two files to Vegas and preview them. I can see a black border around my time lapse file. I fiddeled around quite a while with this. I tried to resize the time lapse in Event Pan/Crop -tool but could only get that to work if I dissabled Maintain aspect ration.

Compare the black border in the preview window with the next screenshot
Compare the black border in the preview window with the next screenshot
See the black border on the left and right hand side in the preview window. Time lapse video has wrong pixel aspect ratio.
See the black border on the left and right hand side in the preview window. Time lapse video has wrong pixel aspect ratio.

Finally I found out that the pixel aspect ratio differs from my DV file and my time lapse file. On the DV file it’s set to 1,0926 (PAL DV) and on the time lapse it’s set to 1,0000 (Square). I changed it by right clicking on the media, select properties and it’s in the media tab.

Media properties for DV file
Media properties for DV file
Media properties for time lapse file
Media properties for time lapse file

You are done!

Big thanks fo LoRd_Mulder and DarkZell666 in the Avidemux forum for helping me out!

Script to cleanup Windows hidden attributes and AlbumArtSmall.jpg

I wanted to remove the hidden files attributes and delete some types of files so I created the following bat-file.

attrib -R -A -S -H D:Music* /S /D
del /S /P D:Music*AlbumArtSmall.jpg D:Music*desktop.ini

(Don’t ask me why /S /D should be last on the line when using attrib and first when using del, but the manual said so.)

The first line removes all read only, archive, system and hidden -attributes on all files, folders and subfolders in folder D:Music.

The second line removes all files named AlbumArtSmall.jpg and desktop.ini from the folder D:Music and all it’s subfolders. The /P argument asks for confirmation so if you are sure you can remove it.

Pair programming to close the gap between business and development

Before I started pairing I often felt that there was a gap between business and development -departments. Communication was mostly done via bug trackers or specifications. Issues were ofter dealt with via e-mail and misconceptions were common.

Since I started pairing I feel a greater (not perfect but better!) contact to the business and I think it’s because I’m used to take discussions. Both about coding details, but also and more important about usefulness of requirements. If we are stuck on an issue we walk over to business and solve the issue instead of making it an e-mail-reply-cc-all-thing.

If I’m working on an issue with a person I don’t know I start out by shaking hands and talking to the person about what he or she does in the company and how they interact with the tools. I tell them what resources we have for the issue and we discuss a possible solution together. Just common sense.

It feels like software development is a too social activity to be done alone! At least for me!

Listen to Deep Fried Bytes – Episode 35, Chariot Tech Cast – Episode 39 and Hanselminutes – Episode 171 for more info about pair programming and other goodness about the software craftsmanship!

Logitech QuickCam mod to fit a standard tripod

I have a Logitech QuickCam Communicate Deluxe webcam. It’s a decent webcam apart from the non standard mounting holes. I wanted it to fit a standard tripod so I did some modding. Here is how.

Webcam before mod

I started out by splitting the screen clip from the cam. It’s a bit scary but I pulled until it released.

Split clip from cam
Split clip and cam

We will going to use the plastic part with the screws so just unscrew it from the screen clip.

Removed the plastic part from the clip
Removed the plastic part from the clip

A standard tripod is just a 1/4″ screw. I found the following two.

I found the following two 1/4" screws that could work
One of these two could work

Here is how they would look. Not sure what the right one was used for but I think it would be easier to attach to the plastic part so I chose that one.

Trying out my options
Trying out my options

I’ll glue the plastic part with the metallic part so I’ll polish both to make the glue stick better.

Polish to make the glue stick
Polish to make the glue stick

Time to glue. I used a double sided tape but glue would work just as well.

Glue together
Glued together

Put the plastic part back to the webcam attach it to you tripod and we are done.

My modded webcam attached to a Gorillapod
My modded webcam attached to a Gorillapod