Archive

Archive for the ‘Tech Talk’ Category

Setting up a Trac Server Under OS X 10.6

May 23rd, 2010 Bed No comments

Trac is an excellent open source tool that allows you to manage a software project;s development life cycle, incorporating a wiki with issue/bug tracking while integrating with a source control service such as subversion. Months ago I had set up a subversion server which was working great on my iMac. I then wanted to setup a Trac server to go along with it so I could manage all aspects for my projects properly. Here’s how I did it.

Installing and setting up Trac

Trac is written in the python scripting language, also requiring a number of other third party libraries. While a compatible version of python comes pre-shipped with OS X 10.6, these prequisite libraries do not. However its extremely easy to install trac along with all its prequisites by using python’s great ‘easy_install’ feature. Simply fire up a command line by launching Terminal.app and run the following command:

sudo easy_install trac

This will download and install everything you need for you without further input, so let it do its thing and when its finished we are ready to create our Trac environment. Because I had previously set up my subversion server under a dedicated OS X user ‘svn’, I wanted to run trac under the same user. Thus I was going to create my trac environment in the /Users/svn/trac/newproject directory and do so by ensuring it was created with appropriate permissions for the svn user. This can be done by prefixing any command with ‘sudo -u svn’, which will run the command as the svn user. For steps on setting up a dedicated user for this purpose see my previous subversion howto. Run the following command (after ensuring /Users/svn/trac/ has been created) in the terminal:

sudo -u svn trac-admin /Users/svn/trac/newProject initenv

This will create a whole bunch of directories and files and you can then run the standalone Trac server manually to check that these first steps have worked:

sudo -u svn tracd --port=8000 /Users/svn/trac/newProject

This will make the trac server listen on TCP port 8000, so we can then browse in Safari or the browser of choice to http://127.0.0.1:8000 and see that we have a trac server running. Its not terribly useful yet however, as we still need to create users, assign administrator privileges to somebody and setup our components and milestones. Press control-c in Terminal to kill the currently running server.

Adding Users

Even if you’re the only one who will be using your trac environment, its a good idea to set up a proper user for yourself. The easiest way to do this is by using tracd with Apache .htpasswd files. We can create a .htpasswd file using the htpasswd command.

sudo -u svn htpasswd -c /Users/svn/trac/newProject/.htpasswd username

This will then prompt for a password to set for the user. For any additional users we can run htpasswd again, just leaving out the -c switch (which tells it to create a new file):

sudo -u svn htpasswd /Users/svn/trac/newProject/.htpasswd another_username

Now that we have configured users and passwords, we need to tell the trac server to use them when running. We can do this by adding the –basic-auth paramater to tracd when we launch it:

tracd --port=8000 /Users/svn/trac/newProject --basic-auth=newProject,/Users/svn/trac/newProject/.htpasswd,/Users/svn/trac/newProject

Now we can browse to http://127.0.0.1:8000 again and see that this time we get prompted to login first. We can do so, but we still can’t administer our project yet. We need to give at least one of our users administrator privileges so they can define our project’s components, milestones and such. We can do this using by running the following command (this can be done while our existing tracd is still running, so there’s no need to kill it first):

trac-admin /Users/svn/trac/newProject permission add username TRAC_ADMIN

This will give username full administrator privileges to your trac environment. After running the command you can just refresh your browser and see the admin tab appear on the page. For a comprehensive guide to the various privileges you can give to users, see this page. You can now configure all aspects of your project directly from your browser.

Integrating with Subversion

Trac can integrate with your local subversion repository, to configure this we need to edit the trac.ini file for the project. In my case this can be found at /Users/svn/trac/newProject/conf/trac.ini. With your favourite text editor find the line that says

repository_dir =

For me this was line 172 of the file, it will be under the section labeled

[Trac]

Simply put the full path to your svn repository here, so in my case its:

reposistory_dir = /Users/svn/repos

and ensure that the line beneath it reads:

repository_type = svn

Restart tracd and refresh your browser to see that the “Browse Source” tab now lets you do exactly what it claims to do.

Automatic Startup
The final step in our trac server setup is to make the tracd service run automatically at system startup. To do this we can create a launchd service using Lingon. You can grab the latest version from Sourceforge. For more details on using Lingon see this previous article I put together, but for this task we just need to add a new User Daemon. Run Lingon, click the New button and select User Daemons. Fill out the dialog as follows:

Name: org.trac.tracd What: /usr/local/bin/tracd –port=8000 /Users/svn/trac/newProject –basic-auth=newProject,/Users/svn/trac/newProject/.htpasswd,/Users/svn/trac/newProject

and be sure to tick the “Keep it running all the time” and “Run it when it is loaded by the system” checkboxes. Click the save button and restart your Mac. If everything has been done right you should be able to instantly load trac in your web browser. Now you can focus on managing and implementing your project.

Categories: Tech Talk Tags: , , , ,

Text navigation shortcuts in Parallels 4

March 5th, 2009 Bed 2 comments

The most annoying thing with running windows in a Parallels virtual machine, is that the default key mappings for navigating text is different between windows and OS X:

Windows:

  • Go to end of line = End
  • Go to start of line = Home
  • Go to next word = control-right arrow
  • Go to previous word = control-left arrow

OS X:

  • Go to end of line = command-right arrow
  • Go to start of line = comand-left arrow
  • Go to next word = option(alt)-right arrow
  • Go to previous word = option(alt)-left arrow

Parallels by default remaps the text copy, cut & paste from command-c to control-c, command-v to control-v etc. Why oh Why didn’t it do this for text navigation I bemoaned over and over, frustratingly trying to remember which OS I was using and switching to the right one.

Then, today, I had a moment of clarity. It was so obvious. I felt stupid for not looking for it before. Behold the screen shot below and now I am calm and relaxed with a unified text navigation scheme.

Fugliest iPhone App EVER

March 3rd, 2009 Bed 1 comment

I didn’t think it was possible for any iPhone application to be as ugly as a windows mobile application. I was wrong.

Its so bad it makes my eyes bleed. How did this get past the Apple approvers? My mind boggles.

Categories: Tech Talk Tags:

Twitter – Adium status syncing ignoring @replies

February 3rd, 2009 Bed 1 comment

A while ago, I found a nice ruby script that would keep my Adium’s status synced with my Twitter status. I’ve recently started using twitter a bit more, and replying to friends with it. This basically does a tweet with @username at the start of it. I didn’t want these @replies to sync to my Adium’s status. So I’ve modified the original script to ignore these. This script runs every half hour via launchd.

#!/usr/bin/env ruby
#
# Update iChat/Adium status from Twitter
#
# Original Script by Michael Tyson
# http://michael.tyson.id.au

# Modified to ignore @reply tweets by Andrew Bednarz
# http://abednarz.net

# Set Twitter username here
Username = 'bed42'

require 'net/http'
require 'rexml/document'

# Download timeline XML and extract latest entry
# Skip @reply tweets
url = "http://twitter.com/statuses/user_timeline/" + Username + ".atom"
xml_data = Net::HTTP.get_response(URI.parse(url)).body
doc    = REXML::Document.new(xml_data)
index = 1
notreply = false
until notreply
	latest = doc.root.elements['entry/content['+index.to_s()+']']
	message = latest.text.gsub(/^[^:]+:\s*/, '')
	exit if ! message
	if message[0,1]=='@' then
		index = index + 1
	else
		notreply = true
	end
end

# Apply to status
script = 'set message to "' + message.gsub(/"/, '\\"') + "\"\n" +
         'tell application "System Events"' + "\n" +
         'if exists process "iChat" then tell application "iChat" to set the status message to message' + "\n" +
         'if exists process "Adium" then tell application "Adium" to set status message of every account to message' + "\n" +
         'end tell' + "\n"

IO.popen("osascript", "w") { |f| f.puts(script) }
Categories: Tech Talk Tags: , , , , ,

Windows 7 vs OSX Leopard

January 20th, 2009 Bed 9 comments

 

VS

For nearly the last year I’ve been using my Mac Book Pro with OSX Leopard as my primary operating system, which replaced years and years of Windows XP. I still had to run XP for work development, which I did in a virtual machine. A few months ago I had to move the VM to Vista to help ensure our application compatibility. So now the Windows 7 public beta was available, I decided to try it out as my work VM. Of course I have a handy backup of my old Vista VM – just in case. However after a week of use, I don’t think I’ll need the backup. Windows 7 should really be called Vista SP2 and it optimises and polishes off the Vista core. In-fact I would say now that Windows 7 finally catches up to OSX, in terms of being a polished, good looking, efficient, practical modern operating system. Having said that, I will not be moving back to the windows platform as my primary operating system any time soon. I really prefer OSX, and here’s why…

Font Rendering

When I first moved to Macs, I thought “everything looks better, text is easier to read without straining my eyes”. So I googled and found that there’s a ideological difference with how Microsoft and Apple go about rendering their fonts. To get a clear understanding of the differences see “Font smoothing, anti-aliasing, and sub-pixel rendering”. Personally, after over ten years of viewing fonts the Microsoft way, it took less than a month to become used to and much prefer Apple’s way. 

Font Rendering Differences

Task Management

Finally, Microsoft have realised the advantage of a combined application launcher and switcher. The new taskbar acts very much like the Dock now – and personally I think this is a great thing. Icons stay in the same place. Apple dock gives a dot under or next to running applications, while the TaskBar draws a box around running applications. Microsoft have this new ‘jumplist’ feature – but this has always been present with the Dock by right clicking the app icon to access application specific functionality. However the OSX dock can contain ‘stacks‘, or folders. Just drop a directory on it and you’ve got an easy menu heirachy, this is not possible with the new windows 7 taskbar.

OSX Dock

Windows 7 taskbar

Windows 7 taskbar

As for switching tasks, on the OSX side you have exposé, which will display all windows so you can see which one you want. On the windows side you have thumbnails and Aero Peak. Both effectively function to let you see what’s going on and find the application you want. Personally, I don’t really use either. I use spaces in OX and generally have one application per space. If I want to go to my email, I go straight there by pressing command-3. For my browser its command-4, and so on. On windows I stick to good old alt-tab.

 

Exposé

Exposé

 

Thumbnails

Thumbnails in Windows 7

Look’n'Feel

To me, Apple provide user interface elements that are straight forward, look great and encourage intuitive operation. You don’t see a lot of badly designed software for OSX because the SDK and developer documentation heavily promote not only good user interface design, but good development design. The single menu bar at the top of the screen had always appealed to me, harking back to my Amiga days. Using windows applications always makes me think “what a waste of screen real-estate”. OSX’s window decorations are minimal and sleak compared to any of the styles offered in Windows 7. Even OSX application toolbars can be quickly toggled visible or hidden with one click (clicking the button in the top right) to maximise screen space. There is a much greater consistency with application look and feel in OSX than there is in the windows world.

 

Toolbar visible

Toolbar visible

Toolbar visible

Toolbar toggled off

 

UNIX-like

The core of OSX is UNIX-like. With this comes great power, flexibility and history. Not only can it easily support any UNIX-based software, I can get to the guts of the OS at a terminal. Configuration files are generally standalone, log files are all in the same place and we have powerful standardised permission systems. Being familiar with linux means its easy to grapple into the core of the OS directly with command line tools. Microsoft do things their own way, and everything is stored in the registry. I always thought that the registry was the worst idea ever and it remains one of the weakest parts of Windows.

Automation Solutions

With OSX I have some great choices to automating tasks. I can write a standard UNIX shell script. I can write some Apple Script to ‘remote control’ any application. Or I can even use Automator to create automatic tasks by ‘drag’n'drop’. Windows has classic batch files, Windows Script Hosting and the new PowerShell. But can you write a script that takes control of any application to automate behaviour? And do so in a way that doesn’t just move the mouse around and simulate mouse clicks and keystrokes? Like most things in the windows world, solutions exist, but they feel clunky. I am constantly impressed with how powerful and embedded AppleScript is. 

OSX for me

These are all, of course, just my personal preferences. The great thing about operating systems in 2009 is that the main three options (OSX, Windows, Linux) are all perfectly capable of letting you do whatever you need to do. The choice really comes down your preference of operation.