Archive

Archive for the ‘Tech Talk’ Category

Dear Australian eBook publishers on Apple’s iBookStore

February 19th, 2011 bed No comments

Dear Australian eBook publishers on Apple’s iBookStore,

Compare these two pictures and tell me why on earth I’d buy from iBooks and not Amazon?

Here’s a tip, don’t try and sell an ebook for the same price I can pickup a physical copy of the book. $9.99 for an ebook is about the right price, $29.99 is not. As much of an Apple fan I am, and as much iTunes credit I have sitting there, I’m not going to spend 3x the amount just for the ‘Apple experience’. Besides I much prefer the Kindle (on iPhone & iPad) app over the iBook app, Apple pay attention to that too.

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

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.

Categories: Tech Talk

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

Twitter – Adium status syncing ignoring @replies

February 3rd, 2009 bed 3 comments

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

Windows 7 vs OSX Leopard

January 20th, 2009 bed 10 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.

Categories: Tech Talk

Turning a protected RTSP stream into an iTunes PodCast (with linux and OSX)

January 1st, 2009 bed 1 comment

A friend of mine does a radio show interstate that interests me. Unfortunately, being a late night show (midnight) and interstate, for me to listen to this live would require me being awake at 4am or so. Due to record label copyright permissions, this show is not available as a podcast download – its only available for live or delayed streaming. Undeterred, I wanted to automatically grab the stream and make it available on my iPhone for listening when it suited me, while out and about.

Getting the stream as a file with linux

The availability of the delayed stream, means this problem can be tackled with a cronjob on my gentoo linux server. This particular stream is served with the Real Time Streaming Protocol which means all we really need is the live555 media libraries. For Gentoo this was as easy as issuing “emerge live” as root on the commandline. For Ubuntu this would be “apt-get install liblivemedia-utils”.

Then its as simple as calling openRTSP with the stream url. ie:

openRTSP -4 -a -t -d 3900 rtsp://streaming.server.com.au:80/streaming.server.com.au/name.mp4 1>name.mp4

This will write the audio stream  as a file.

The next step is to automate this process with a script being launched by cron. In this case, the name of the stream is in the format radioshow_YY_MM_DD.mp4. So my script will grab today’s stream.
radioshow.sh:

#!/bin/sh
filename="radioshow_"`eval date +%Y-%m-%d`".mp4"
openRTSP -a -t -4 -d 7300 rtsp://streaming.server.com.au:80/streaming.server.com.au/$filename > /mnt/download/radioshow/$filename

Since this show is a weekly one, my crontab is setup to download the stream at 1:30pm every thursday.

crontab line:

#download behind the mirror every thursday at 1:30pm
30 13 * * 4       /home/bed/radioshow.sh

Converting to a PodCast with OSX

Once we have the files, I wanted to put it in my iTunes library flagged as a PodCast. A commandline tool AtomicParsley enables us to set the appropriate mp4 tags so iTunes sees the file as a PodCast, however AtomicParsley doesn’t like the mp4 tags created by openRTSP. To get around this we can load our file in QuickTime, and then re-export it to mp4. This will now be a file with mp4 tags that AtomicParsley can modify. We can then execute the following command:

AtomicParsley name.mp4 --podcastFlag true --artist name --title name --advisory explicit --description name --podcastURL name --podcastGUID 1 --year "2008-12-25" --overWrite

This will create a new file, which we can then drag into iTunes. This will now show up as a proper PodCast, so it will automatically sync to my iPhone and then be removed once I’ve listened to it.

Now that’s a fair bit of manual mucking around, so we can use AppleScript to automate all of this in one nice move, which can be the scheduled with launchd to occur at a convenient time:

-- This script does the following:
-- + looks in a directory in my file server and copies it file locally,
-- + loads it into quick time, and exports it to add proper tags
-- + sets podcast tags with AtomicPasley
-- + imports it into iTunes
-- + cleans up files

mount volume "afp://bedentoo/download" as user name "XXXXXXXX" with password "YYYYYYYYY"
tell application "Finder"
	repeat until ((name of every disk contains "download") as boolean)
		delay 2
	end repeat
end tell

set source_location to "download:radioshow"

tell application "Finder"
	set new_file to {get name of files of folder source_location} as text
	with timeout of 7200 seconds --2 hour timeout, incase we're copying over a VPN or something
		copy {file new_file of folder source_location} to desktop
	end timeout
end tell

-- Use QuickTime to export it (to set proper mp4 tags)
set user to do shell script "whoami"
set local_new_file to {"/Users/" & user & "/Desktop/" & new_file} as text
set local_fixed_file to {"/Users/" & user & "/Desktop/" & new_file & ".fixed.mp4"} as text
tell application "QuickTime Player"
	activate
	close every window
	open local_new_file
	with timeout of 1800 seconds -- half hour timeout incase export takes a while
		export front document to local_fixed_file as MPEG4 using default settings
	end timeout
end tell
quit application "QuickTime Player"

-- our file is always the format of ccccccccccccccccYYYY-MM-DD.mp4 so lets extract the date
copy characters 17 through 26 of new_file as string to datestamp

-- run AtomicParsley (located in ~/scripts/) to flag it as a podCast
set run_ap to {"/Users/" & user & "/scripts/AtomicParsley " & local_fixed_file & " --podcastFlag true --artist radioshow --title 'radioshow '" & datestamp & " --advisory explicit --album radioshow --description radioshow --podcastURL 'http://www.url.au/shows/radioshow' --podcastGUID 1234 --year '" & datestamp & "' --overWrite"} as text
do shell script run_ap

-- import file into iTunes
tell application "iTunes"
	activate
	add ({POSIX file local_fixed_file})
end tell

--cleanup!
tell application "Finder"
	delete {POSIX file local_new_file}
	delete {POSIX file local_fixed_file}
	delete {file new_file of folder source_location}
end tell

Lastly, the applescript is saved as an .app and scheduled with launchd via lingon, which runs at 8am friday morning.

Categories: Tech Talk

Backing up an OSX profile to a linux server with rsync

December 31st, 2008 bed 3 comments

TimeMachine is some nice software, but its overkill for me. I’ve previously written about this and how I put together a rsync solution and why I did so. In the case that anyone might be interested in doing the same, here is my setup.

Linux Server
I have a gentoo linux server, but this should be a mostly generic rsync server setup. My rsyncd.conf looks like this

# /etc/rsyncd.conf
# This line is required by the /etc/init.d/rsyncd script
pid file = /var/run/rsyncd.pid
use chroot = yes
read only = no
uid = bed
gid = bed
hosts allow = 192.168.42.0/24

[bed-backup]
        path=/mnt/backup/bed
        comment = Beds Backup

and of course rsyncd is in my /etc/init.d and starts automatically at boot.

OSX
I have a simple bash script that I can run that will backup the contents of my home directory, called backup_bed.sh. This will turn sleep off, make sure the network is available (as the machine may have been woken from sleep) and then do the backup.

#!/bin/sh
#Bed's rsync backup script

echo `date` Beds Backup > last_backup.log
echo `date` ------------- >> last_backup.log
echo `date` Script Starting at `date` >> last_backup.log

# turn off system sleep
pmset -a sleep 0 2>&1 >> last_backup.log
echo `date` Turned off sleep >> last_backup.log

echo `date` ------------- >> last_backup.log

# wait for network to show up
pingcount=0
trycount=1
failflag=0
while [ $pingcount -eq 0 ]
do
    echo `date` Waiting for network... $trycount >> last_backup.log
    pingcount=$(/sbin/ping -c 3 -o bedentoo | grep "received" | awk -F',' '{ print $2 }' | awk '{ print $1 }')
    trycount=`expr $trycount + 1`
    if [ $trycount -eq 11 ]
    then
        echo `date` network fail - giving up >> last_backup.log
        failflag=1
        pingcount=-1
    fi
done

if [ $failflag -eq 0 ]
then
        #do rsync
        echo `date` RSync started.  >> last_backup.log
        /usr/bin/rsync -a -x -S -v -v --progress --exclude-from=/Users/bed/scripts/backup_excludes.txt  /Users/bed/ bedentoo::bed-backup 2>&1 >> last_backup.log
        echo `date` RSync finished.  >> last_backup.log
fi

#turn system sleep back on
echo `date` ------------- >> last_backup.log
pmset -a sleep 30 2>&1 >> last_backup.log
echo `date` Turned on sleep for 30 min >> last_backup.log

echo `date` Script Finished  >> last_backup.log
echo `date` ------------- >> last_backup.log

I exclude non-essential stuff from my backup, notably temporary files and my virtual machines. These excludes are specified in the backup_excludes.txt file:

- .Trash
- Downloads
- temp
- Caches
- Parallels

And finally, the backup_bed.sh script is run every morning at 8am by launchd. The easiest way to configure launchd is with a nice GUI tool called Lingon. This is created as a User Daemon.

Finally my OSX is configured to automatically wake up a minute before the launchd runs (via System Preferences -> Energy Saver -> Scheduler). If for some reason the machine is actually off, launchd will run the script as soon as it can when the machine is next booted. (launchd is a very nice system).

One note of warning, this setup will not properly support Classic MacOS resource forks. These are nolonger used in OSX, however if you maintain a classic MacOS enviroment, you can backup to a OSX server (not a linux server) and use the -E option of OSX’s rsync.

Categories: Tech Talk

Bed's Top Five Jailbroken iPhone Apps

December 6th, 2008 bed 2 comments

The iPhone is my favourite internet-enabled mobile device – and I’ve used quite a few; I write software for Windows Mobile devices at work (and I hate Windows Mobile). But I don’t wear rose-coloured glasses, the iPhone and Apple aren’t flawless. Thus I fill the holes by jailbreaking my phone (running unauthorised by Apple applications). When an iPhone firmware update comes out I patiently wait until the jailbreaking community has updated too. To jailbreak your iPhone browse through the iphone-dev’s blog. Once you’re jailbroken, Cydia is pre-installed, and serves as the equivalent to Apple’s AppStore for getting Apps. Here are my top five reasons to jailbreak my iPhone.

Swirly MMS

Swirly MMS

Swirly MMS

The lack of MMS support on the iPhone has been discussed greatly on the webisphere. Apple made a conscious decision to leave MMS out in favour of encouraging email (which can achieve the same result). However my wife doesn’t have an internet plan enabled on her phone. Now while the only MMS’s we send each other are usually of cute cats or dogs, its nice to be able to do so. Swirly MMS gives full MMS support for US$8, with a free 14 day trial. It works seamlessly and as expected. While you have to manually enter your carrier’s SMS network details, there are numerous listings for all the major carriers for you to reference. MMS notifications come through in a similar manner to standard SMS notifications. 

Read more…

Categories: Tech Talk, Top Fives

Bed’s Top Five Useful iPhone Apps

December 6th, 2008 bed No comments

Following on from Bed’s Top Five Essential iPhone Apps, here are my top five useful iPhone Apps. These aren’t used on a daily basis – but are useful to have around for when they may be required.

IM+ Lite

IM+ Lite

IM+ Lite

Its always handy to have an Instant Messenger application around. While I don’t need always-on-push instant messaging on my iPhone – having the ability to log on and talk to someone quickly can be useful. Just the other month I was relaying technical support to a work colleague while in a busy loud shopping mall. It was much easier via IM than trying to talk on the phone through all the noise. IM+ Lite isn’t fancy, but it supports pretty much all IM protocols (AIM®/iChat, MSN®/Windows Live™ Messenger, Yahoo!®, ICQ®, Jabber®, Google™ Talk and MySpaceIM) and is free.

Read more…

Categories: Tech Talk, Top Fives