Twitter Updates

Tuesday, 30 December 2008

rTorrent Manuall install

Manual Install of latest rtorrent (on ubuntu 8.04 )
Original (and incomplete) instructions from here (I also think that the /usr/local/ is not the correct place to be installing these things but I do not have a better choice)

First remove apt-get rtorrent install
$ sudo apt-get remove rtorrent
This will also remove some no longer needed dependencies

Install other dependancies (not too sure if these are really required but were mentioned in the original guide), Oddly enough not installed or removed by apt-get when installing rtorrent!
$ sudo apt-get install build-essential libsigc++-2.0-dev pkg-config comerr-dev libcurl3-openssl-dev libidn11-dev libkadm55 libkrb5-dev libssl-dev zlib1g-dev libncurses5 libncurses5-dev

When I did this the latest versions were rtorrent 8.4/ libtorrent 12.4
$ cd /usr/local/
$ sudo wget
$ sudo wget

$ sudo tar xvf libtorrent-0.12.4.tar.gz
$ sudo tar xvf rtorrent-0.8.4.tar.gz

$ cd libtorrent-0.12.4
$ ./configure
$ make
$ sudo make install

$ cd rtorrent-0.8.4
$ ./configure
$ make
$ sudo make install

And where is it installed? taking a closer look at the readme's it should have put executables in /usr/bin.

$ sudo find / -name rtorrent
The binary executable has been left in the source folder!

$ cd /usr/local/rtorrent-0.8.4
$ sudo cp src/rtorrent /usr/local/bin/
$ ll /usr/local/bin/
> -rwxr-xr-x 1 root root 12168526 2008-12-31 10:13 rtorrent
$ which rtorrent
> /usr/local/bin/rtorrent
$ sudo ldconfig

Seems to be working ok, but getting some errors about my ~/.rtorrent.rc file containing invalid options.

Mac OS X Keybindings

I have previously mentioned this page in a previous post. I had not realised that ~/Library/KeyBindings/DefaultKeyBinding.dict only applies to programs using standard Cocoa AppKit text edit objects.

Well I created this ~/Library/KeyBindings/DefaultKeyBinding.dict so some home end keys would work for those applications.
/* ~/Library/KeyBindings/DefaultKeyBinding.dict */
"@\UF702" = "moveToBeginningOfLine:"; /* cmd-left = start of line */
"@\UF703" = "moveToEndOfLine:"; /* cmd-right = start of line */

The (found in /Applications/Utilities/) has its own keyboard settings in its preference menu.
escB - move left one word
escC - move right one word (and uppercase first character, lowercase every thing else)
escF - move right one word
esc[H - move to beginning of the line
esc[F - move to the end of line
esc sequence is \033 press ESC to insert the escape sequence.

To view other terminal key bindings just take a look at the output of
$infocmp -L

Thursday, 25 December 2008

Removing CCC (Carbon Copy Cloner) from MAC OS X

So when I rebuilt my machine from a clean harddrive I tried to clone it using CCC, but it would not create bootable clones. it was not leopard compatible. So I switched to SuperDuper which worked great first time.

However every day CCC pops up with a scheduled task.which is very annoying, I just want it (At least this version) off my system.

NOTE : Added 16 January 2009
I have since removing ccc noticed that the scheduled task still gets launched (look in console message) and silently fails in the background, slowing my system down a tiny amount.

Following advice from link above Delete scheduled tasks before Trashing the App

Removing / Uninistalling CCC and ccc_helper
Find the 'Carbon Copy' probably in /Applications .
I try to keep Applications tidy and put it in /Applications/Accessories .

Drag 'Carbon Copy' into the Trash can.
Now if you try to empty the Trash can it will fail beacuse part of the program is still running called ccc_helper this is the part that schedules those annoying popups.

Start 'Activity monitor' found in /Applications/Utilities .
Set the filter in the top right to all processes. and sort by name (or add ccc_helper as a search term). once found double cick on the ccc_helper then select Quit.

Once ccc_helper has been shutdown you can then empty the Trash with out a problem.

These files may need to be Manually deleted
~/Library/Preferences/com.bombich.ccc_helper.plist (if it exists)

Tuesday, 16 December 2008

Screen hardstatus

Tips on changeing you screen hardstatus colours. (Original post)

my new ~/.screenrc
# Color table:
# 0 Black . leave color unchanged
# 1 Red b blue
# 2 Green c cyan
# 3 Brown / yellow d default color
# 4 Blue g green b bold
# 5 Purple k blacK B blinking
# 6 Cyan m magenta d dim
# 7 White r red r reverse
# 8 unused/illegal w white s standout
# 9 transparent y yellow u underline

hardstatus alwayslastline
hardstatus string '%{= kW}%-Lw%{= KW}%50>%n%f* %t%{= kW}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'

vbell off

Sunday, 30 November 2008

Mac OS X 10.5 Clean Install

When I upgraded my macbook harddrive I took the opportunity to do a clean install of OS X and to figure out which programs I really needed.

After installing the harddrive, power up and insert the Leopard disc-01 you will need to press C to boot from CD. The BIOS might have missed this when you were inserting the disc so may need to power cycle (switch on and off again). Other boot options

The install was pretty straigh forward but unlike every other OS installer it does not bring up the disk partition and formatting box by default so you have to go looking for the disk utility in the top right menu, very annoying!

after an hour it asks for the second disc, which it fails to recognise the first time. Cant remember if I had eject and insert the disc several times ot power cycle but it then accepted the disc and an hour later the fresh install of OS X was complete.

I then installed al the programs I was going to need.

Firefox 3.0.3 [Free]
Quicksilver 3815 [Free]
Xcode 3.1.1 [Free with apple developer registraion also free]
Macports 1.6 [Free]
istat pro 4.71 Dashboard [Free]
VLC 0.95-Intel - Media Player with most codecs built-in [Free]
Max 0.8.1 - Audio conversion [Free]
Lightroom 2 [NOT Free]
Photoshop CS3 [NOT Free]
Handbrake - Video encoder [Free]
Smultron - text editor [Free]
Visual Hub - Now called FilmRedux [Now Free]
Super Duper - Clone bootable drives [Used Free version]
Sound Pref - stop OS X boot up sound, previous post [Free]

After the installation:
Restore my firefox settings, including bookmarks and passwords

Create a user bin folder, for scripts
$mkdir ~/bin
Copy from backup all my scripts in to this folder.
Configure the Terminal and X11 setting and then restore my .bashrc & .bash_profile

Set up scripts to mount my samba shares
Set Desktop Icon size
Set Background Image and screen savers

Samba and Finder (OS X)

Recently I have had problems with finder not being able to copy and paste files from my network shares. I could still use quick look, preview etc.

The problem seemed to be specifically with finder although this article seemed to suggest it was todo with samba file locking Maybe finder got a bug in the last mac update and this is just a work around.

Any way adding this option seems to help finder copying files over samba (option goes in the smb.conf file on the server)
#Stop Mac Finder thinking it can not copy files
locking = no

Saturday, 29 November 2008

Ruby Variables

Just brushing up on Ruby from the cartoon fox who loves chunky bacon. Chapter 3 introduces so many types of variables, here is my quick summary of ruby variables.

something = "A string"
something2 = 'Another string'

somthing3 = 1

something4 =3.14

#Symbols (light weight strings)

#Constants (Capitalized)
SOMETHING = "This can never be changed"

#Global Variables (dollar sign)

#Instance Variables

'Class Variables

#Calling methods
objectInstance.add( :red ) , objectInstance.remove( :blue)

eg Object::new() , Object::killall

Ubuntu, Monitoring broadband data usage.

As many ISP now have data limits (quotas), be it hard or soft. With Hard limits they cut you off once over your quota or switch over to billing you a lot per MB, with a soft limit they just slow down your access. will take your bandwidth down to 50% or 25% of the amount you pay for depending on tarrif. This is triggered by down loading 500MB (depends on tariff) between the hours of 4pm and 9pm. once triggered the reduced BW will stay in place for 5 hours.
Also note that the 500MB is less than half a movie rented from itunes, which means that are destroying the apple movie rental business!

For an 8Mb (Mega-bit) broadband full speed is actually 640KB /s (Kilo-Bytes)
500MB / 0.64 = 781.25 Seconds =13Minutes

The reduced BW can be triggered in just over 13 Minutes!
My experience for there non-cable 8MB connection reduced BW is 10KB/s Which is way beyond what they claim to reduce your BW to.

because of this it is useful to keep track of the BW that you home network is using. this is easy to do (I guess) if you only have one computer but if you have multiple machines or live in a flat with flatmates then the BW measuring must be done at a central point. For me my mini-itx server uses about 90% of my bandwidth so just measuring this should be good enough.

For Ubuntu (from a terminal do)

$sudo apt-get update
$apt-cache search ethstatus
$sudo apt-get install ethstatus

launch with in a terminal by calling

Just need to work out how to make it clear/keep daily/monthly totals.

NB : Added 01/12/2008
Just found the ADSL Managment page for my isp

Tuesday, 25 November 2008

Search and replace for multiple files

A nice oneliner
$perl -pi -w -e 's/search/replace/g;' *.php


Monday, 24 November 2008

Linking to Scripts from Blogger

I have for a while been looking for better ways to include scripts in blog posts. A link to a downloadable file would be nice. Trying to get it relying on other peoples free web services so that my home server can go down/break/catch fire and all the scripts will still be available.

Tried Google docs but that forced me to change all file extensions to .txt
The free account on seems very promising. I have only used Subversion revision control before so may take a while to get use to a GIT revision control system.

This also means I need to set up GIT on all my machines.
So for Ubuntu

$apt-get update
$sudo apt-get install git-core

and Mac OS X
$sudo port -d selfupdate
$sudo port install git-core

My first repo is munkymorgy_scripts this is probably going to be a flat (1 level) store of the useful scripts I post.

NOTE [Added 28/04/2009]:
The following link seems to suggest a good way of displaying code snippets on

Saturday, 22 November 2008

Ubuntu Media Codecs

To install codecs to play back mpeg 4 video files I followed the instructions here for Ubuntu 8.04

$sudo wget -O /etc/apt/sources.list.d/medibuntu.list
$wget -q -O- | sudo apt-key add - && sudo apt-get update

#DVD support
$sudo apt-get install libdvdcss2

#Some mpeg 4 codecs
$sudo apt-get install w32codecs

#Other codecs
$sudo apt-get install non-free-codecs

Thursday, 20 November 2008

Remote X Forwarding

Forwarding the GUI (Graphical User Interface) from an application on a remote (not locallhost) server is known as X Forwarding. As X11 is the unix/linux display stuff.

a typical noddy example is the xclock which can be lanched from any terminal mac users might have to use the X11 terminal instead of

so to make sure that my (remote) server was setup to forward X over ssh check that the config file contains the forwarding option
$sudo vim /etc/ssh/sshd_config
X11Forwarding yes

Then when I ssh on the local machine to the remote machine include the -X option
$ssh -X me@remote_server

Mac OS X 10.5 et al. Keybindings Beginning of Line/End of Line

I do a lot of text editing and find the traditional windows buttons Home/End very useful especially on the terminal when you found you made a mistake at the start of the line, you cannot use the mouse to move the cursor.

Mac Home/End functions by default take you to the Top/Bottom of a page instead of the Beginning/End of line.

I have not tried it yet but this page looks like it has the some very useful information for fixing this.

This page gives an example of there fixed keymap

Wednesday, 19 November 2008

Finder show hidden files

To make finder (mac file browser) show hidden files you can use the apple script found here

Equivalently you could call this from the command line
$defaults write AppleShowAllFiles TRUE
$killall Finder

Original source

Ruby script performance measure

For measuring runtime performance of ruby scripts insert the few lines below around the part you want to measure.
# Record Startime For performance measurments
startTime =

Main part of script goes here

#Calculate and Display Execution Time in seconds
execTime = - startTime
puts "Execution time #{execTime} seconds."
Thats it!

Tuesday, 18 November 2008

Setting up an RSS with rTorrrent

So I though t that I would have a go at setting up an RSS feed to put torrent files in to a watch folder for rTorrent to pick up.
Is meant to be very good at this

The requiremnets are this program pyhton above 2.4 and mechanize.
for my ubuntu server.

$ mkdir ~/bin
$cd ~/bin
Once that is finished
$python --version
>Python 2.5.2
So that is OK
$apt-cache search mechanize
>python-mechanize - stateful programmatic web browsing
$sudo apt-get install python-mechanize

Now Build rssdler
$cd ~/bin
$tar -xvzf rssdler-0.4.0a.tar.gz

Now erm check the instructions!

Looks like this is also required
$sudo apt-get install python-feedparser

Make dir for runtime files
$mkdir ~/.rssdler

Install rssdler
$cd ~/bin/rssdler040
$sudo python install

now apparantely it will just work by calling
$rssdler -r

eek no config file found
$cd ~/.rssdler
copy the sampe config.txt from here

Still does needs some work before it will do something useful. Will update soon.
Update: got it working my config file with all the blotted comments removed.
$cd ~/.rssdler
$cat config.txt | grep -iv '#'
downloadDir = /mnt/starbug1/terra1/samba/10-test/
workingDir = /home/morgy/.rssdler
log = 5
logFile = downloads.log
verbose = 5

scanMins = 2
runOnce = True
urllib = False

link =

Sunday, 16 November 2008

Install mysql on Mac OS X 10.5

I have trying out some ruby on rails which requires a database, the most common for rails is mysql.

Itried the mac ports install
$sudo port -d selfupdate
$port search mysql
$sudo port install mysql5

but that did not seem to work ie '$which mysql' returns no results

Note: checking out the contents of /opt/local/bin I notice that mysql5 and mysqladmin5 are there. so using these program names it might have all been working!

Apple have this guide

The following way seemed to work for me:
Download the Mac OS X Package from Requires a free registration but led me to this link in the end

just download mount the .dmg (by double clicking on it) then install both .pkg inside (by double clicking on it).

dont forget to add this to your path
$vim ~/.bashrc
Paste in the follwoing
#Add path for mysql package
export PATH=$PATH:/usr/local/mysql/bin/

now '$which mysql' and '$which mysqladmin' should return results

NB: I had to reboot to get the mysql demons (the server) to start, but I am sure there is a quicker way of starting the server up after the first install.

Wednesday, 5 November 2008

MAC OS X spotlight indexing external drives

So still busy with rebuilding my Macbook, software installs and workflow, so its a good time to try and sort all the niggly things to do with the OS. One thing that I do not really like is spotlights indexing of external drives and network filesystems, so how do I stop it?

According to I just have to create an empty file called 'metadata_never_index' in the root folder of the drive.

I mount my network drives under ~/mnt so to create this file I just need to do (in
$touch ~/mnt/Starbug1_Public/metadata_never_index

and my network share should no longer get indexed.
How do I remove all the rubbish the index has already put there ?

Tuesday, 4 November 2008

MAC OS X Menu for setting up Dektop Icon size

I spent ages trying to find the option to resize the icons on my desktop, so here is a reminder to myself.

Right-Click on the dektop and select 'Show View Options'
This brings up the menu shown below with my chosen settings applied.

Monday, 3 November 2008

Avahi, Bonjour for Linux

I can connect to my Ubuntu servers samba shares through scripts but it would be nice if I could just browse for them. So I am going to try install avahi which is the linux version of bonjour .

$ sudo apt-get update
$ sudo apt-get install avahi-daemon avahi-discover avahi-utils

setting up for samba

$ sudo vim /etc/avahi/services/samba.service

type i to enter insert mode on vim
then ESC then ':wq' to leave insert mode then write the file and quit.
but paste the expert below first.

<?xml version="1.0" standalone='no'?><!--*-nxml-*-->
<!DOCTYPE service-group SYSTEM "avahi-service.dtd">
<name replace-wildcards="yes">%h</name>

The avahi-demon.conf can also be edited to added services to on other mamchines which do not run bonjour/avahi
$ sudo vim /etc/avahi/hosts

I have the following in the hosts file router.local wifi.local

restart avahi server
$ sudo /etc/init.d/avahi-daemon restart

The servers name should now appear in finder on the left. If it says failed to connect, it is often todo with the samba server not having a guest user. Clicking connect as and entering username and password should allow you to see network shares.

Sunday, 2 November 2008

Replacing Macbook Hard Drive

I have just replaced my mac book Hard drive. Originally a Seagate 5400.3 5400RPM 160GB. Cache is ?. Max power is 5v x 0.487a.

The new drive is a Seagate 7200.3 7200RPM 320GB 16MB cache. max power is 5v x 0.62a.

Macbook 5400.3 7200.3
Idle Battery Life 6:23 ?
Average datarate RW 30MB/s ?

Saturday, 1 November 2008

Saving Space/Backing up on OS X

I am currently running Mac OS X 10.5 Leopard, Which Snow Leopard is set to replace with a smaller more efficient code base. Until it is released I found a few folders that can be occasionally delted. This has all been triggered by me trying to figure out what I need to save/archive on my macbook so that I could restore it if it all went wrong.

All these commands/paths are from the terminal (dont type the $). it can be found in /Applications/Utilities/

$cd ~/Library/Caches
$du -h -s

du is a program to report disk usage. It reports my cache as 1.2GB.
This is just a Temporary storage for programs and should be safe to delete its contents
$rm -r ~/Library/Caches/*

I also use the online printers photobox, their uploading software seems to have left another massive cache else where.

$cd ~/Library/Application\ Support/Photobox
$du -h -s

du reports 386MB an exact copy of what I uploaded from from the same disk, what a rubbish program! Lets get rid of that as well
$rm -r ~/Library/Application\ Support/Photobox/*

NB: Just noticed this folder as well
$cd ~/Library/iTunes/iPod\ Software\ Updates/
$du -h -s

This reports an extra 1.1G of downloaded software updates. no need to back these up/keep them.
$rm -r ~/Library/iTunes/iPod\ Software\ Updates/

Summary: these folders are not needed and just take up space
$rm -r ~/Library/Caches/*
$rm -r ~/Library/Application\ Support/Photobox/*
$rm -r ~/Library/iTunes/iPod\ Software\ Updates/

For me they took a 2.5GB Library folder down to 152MB!

Wednesday, 29 October 2008

ruby flick-1.0.2 gem and rake docs

When running 'gem server' flickr-1.0.2 gem did not have any docs available (on OS X10.5 at least). So to add the flickr rdoc into the gem server :

find the location of your gems, you can use locate.
$locate flickr

$cd /Library/Ruby/Gems/1.8/gems/flickr-1.0.2
$rake rdoc
/Library/Ruby/Gems/1.8/gems/flickr-1.0.2/doc/* /Library/Ruby/Gems/1.8/doc/flickr-1.0.2/rdoc

Now start the gem server and the rdoc link should be active.
$gem server

Tuesday, 28 October 2008

Display command output from bash script

To directly display the output from a command in a bash script (do not forget to set executable on the file $chmod u+x Where is the name of the script file.


#List home directory (note the back ticks)
echo `ls -l ~`

#Store command output as a variable
i=`ls -l ~`
echo $i

Sunday, 26 October 2008

Ruby Gems & gem_server

The default Leopard Ruby installation does not include the gem_server by default.
NB: it is now called gem server (no underscore)

I performed a gem update then the gem server worked.
$ gem update --system

$ gem server

gems are Ruby libraries that add functionality to the basic install.

Some gems require you to build the documentation. in this case cd to the gem location and call
$rake docs
$rake rdocs

you can view a gems doc directly by pasting the gem docs folder into your web browser.

Thursday, 23 October 2008

.bashrc history tips

Some usefiul lines in my .bashrc

#Reload Bashrc
alias reload='source ~/.bashrc'

#Save history correctly when using multiple terminals
# Dont save duplicate lines or blank lines in to history
export HISTCONTROL=ignoreboth
export HISTSIZE=1000
#Append changes to history instead of overwrite full file
alias exit='history -a && exit'

An alternative to the line above is
# make it append, rather than overwrite the history
shopt -s histappend
Advantages of the alias exit it will group the output of each terminal in the history file, rather than a all terminals adding there input on the fly.

Wednesday, 22 October 2008

Linux Flickr command line(broken)

Installing a linux flickr command line uploader

$ cd ~/Bin
$ wget
$ tar -xvz FlickrUploadr-1.0.0.tar.gz

could not find the pyhton xmltramp package under apt get so had to manually add it

$ cd /usr/lib/python2.5/site-packages/
$ sudo wget

Now to configure the uploader
$ cd ~/Bin/FlickrUploadr-1.0.0
$ sudo python install

Now Run Uploader
$ Uploadr
and WHOO Segmentation fault just what I wanted. But I was calling it from a no Xwindow terminal.

Any way my flickr page

Monday, 20 October 2008

MS Visio Block Connection Points

In Visio it is easy to move and add extra connection points to an object.

Just select the 'Connection Point Tool' from the drop down menu next to the normal arrow tool.

You can then click and drag the pre-drawn connection points or CTRL-Left click add new connection points

Friday, 10 October 2008

rtorrent Views

I just discover views in rtorrent. My favourite terminal torrent client.
Just pressing keys 1-7 will show different sorted/filtered lists of your torrents.

Original source

1: Main (sorted by name but new torrents are added to the bottom of the list)
2:Name (alphabetical I think)
3:Started (a filtered Name)
4:Stopped (a filtered Name)
5:Complete (a filtered Name)
6:Incomplete (a filtered Name)
7:Hashing (a filtered Name)

Tuesday, 23 September 2008

Search for files NOT containing text

I have been trying to use grep to find files that dont contain certain text.
And well it has not been going so well, to find files that contain text is easy
$grep -il text *.txt
To invert a grep search just add the option -v, that will be the non matching files?
$grep -ilv text *.txt
What actually happens is it is searching line by line, and invariably the .txt file has more than one line that does not contain the 'text'.
What you actually want to do is find all the files that match (because that is easy) then print out a list of files omitting all the ones that match.
So here is a short ruby script to do just that:
I called the script ruby_find.rb
and call it using $ruby_find.rb text

Ruby case-insensitive test

Three Ruby methods for case insensitive string matching.
'Ruby' can be replaced by any String or variable of type string

if 'Ruby'.downcase == 'ruby' then
print("'Ruby'.downcase == 'ruby' true \n")
if 'Ruby' =~ /^ruby$/i then
print("'Ruby' =~ /^ruby$/i true \n")
if 'Ruby'.casecmp('ruby') == 0 then
print("'Ruby'.casecmp('ruby') true \n")

Wednesday, 17 September 2008

Replacing Macbook Hard Drive

Since I saw some 500GB 2.5" SATA Hard Drives I have been thining about repacing my 160GB HD. Instructions on replacing macbook drive can be found here

Unfortunately macbooks (as of 2008) only allow 2.5" drives upto a height of 9.5mm. the new 400GB and 500GB 2.5" form factor drives use 3 disc platters in stead of the standard 2 and are 12.5mm in height, therefore will not fit in the macbooks :-(

Looks like the current biggest that will fit are the 320GB which can currently be found for £50

MAC OS X 10.5 Leopard changing spaces with one hand

I really like Spaces on Leopard but some times when walking around with my macbook I cant use ctrl-cursors to change spaces and would like a really nice way to change Spaces with one hand. I could show spaces in the menu bar but that is getting a bit cluttered.

If I could use the accelerometer and just tap the side of the monitor to change Spaces that would be nice, the next best thing I have found is Warp which pops up a preview of the next space when the mouse hits the edge of the screen.

Mac OS X Full Screen Button

While I have not quite got this one cracked yet I found a script that came close.
The script is the equivalent of pressing the top left + window button. which toggles the window between its optimised size and the last user defined size.

I also have quick silver installed and added ctrl-m to trigger the script.
I keep the script in ~/Scripts
maximise app.scpt

tell application "System Events"
if UI elements enabled then
set FrontApplication to (get name of every process whose frontmost is true) as string
tell process FrontApplication
click button 2 of window 1
--button 2 is the green "zoom" button for all applications
--window 1 is always the frontmost window.
end tell
tell application "System Preferences"
set current pane to pane ""
display dialog "UI element scripting is not enabled. Check 'Enable access for assistive devices'"
end tell
end if
end tell

I did not write the script and unfortunately cant remember where I got it to credit the writer. If you know the original source let me know.
if it does not run you probably need to set the execurtable permission from the terminal
cd ~/Scripts
chmod u+rwx maximise\ app.scpt

Mac OS X Screen Capture

For the Firefox 3 and post I wanted to include a screen grab of the settings I was using. I discovered that this is very easy on OS X I used the site below to quickly find the keyboard shortcuts.

⌘ ⇧ 3 Screen to png file on desktop
⌘ ⇧ 4 + Drag: Selection to png file on desktop
⌘ ⇧ 4 + Spacebar: Window (click camera) to png file

It is possible to change the output format by typing the following at the terminal
$defaults write type jpg
$killall SystemUIServer

Tuesday, 16 September 2008

Mac OS X Default $PATH

Just in case the $PATH terminal variable gets corrupted, for MAC OS X 10.5 .
export PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

Bash Double Quotes Single Quotes

When working on the command line some scripts/programmers seem to arbitrarily switch between "Double Quotes" and 'Single Quotes'.

The difference in bash at least is
Double quotes evaluate variables inside of them.
Single quotes are a literal string (NO evaluation).

computer ~ $ fred=result
computer ~ $ echo "fred is $fred"
fred is result
computer ~ $ echo 'fred is $fred'
fred is $fred and firefox 3 cookies

Since upgrading to Firefox 3 when logging into then viewing my own blog at I no longer had the options in the top right corner to add new posts and the edit button at the bottom of my posts.

This was due to the fact that I have disabled 3rd party cookies, which meant that my credentails for being logged into could not be read by

By adding to the allowed list I now remain logged in when viewing my blog on Is this a security risk can any site now read my cookies?

Here is the setting that got it working again.

Sunday, 14 September 2008

Setting up the terminal

This was something I discovered a long time ago and could not find an earlier entry about it.
Certain Mac OS X terminal programs read the properties from the ~/.bash_profile and some fom the ~/.bashrc.

NB: ~ means the users home directory. and files beginning with a dot '.' are hidden files in unix speak. Something rc often refers to configuration files for the something program.

A good soloution to the problem is to make .bash_profile load your .bashrc, like so

if [ -f ~/.bashrc ]; then
. ~/.bashrc

A very basic .bashrc file would look something like

#.bashrc file for users terminal /command line preferences
# This is a comment. MAC-UK keyboards type alt-3 for a # character

#Add a shared scripts folder to the Path
export PATH=$PATH:/Users/Shared/Scripts/

#make ls look pretty with colours (list your files)
alias ll='ls -l -FG'
alias ls='ls -AFG'

Friday, 12 September 2008

Twitter to update Facebook Status

Found this Facebook app to allow Twitter tweets to appear as your Facebook status

Install plugin (above link), enter twitter account details, then select allow status updates.

Read about in the article

Tuesday, 9 September 2008

An Applescript Preference Systems

I found the basis for an applescript preference systems at macosxhints.
I have corrected a few typos and here it is.

tell application "Finder"

end tell

Preference system version 1

Chris J. Shull

The code is free. Re-use at will, but please leave this acknowledgement in your code.
Feel free to email me and tell me you've found it helpful!

---Base prefs snippet
set prefname to "net.munkymorgy.pref" --this will be the filename
set prefcontent to "default" --this will be the content of the pref file. NOTE that you can create multiple lines
set prefpath to FindPrefFolder() --finds the path to the user's Prefs folder
set ContentParaNumber to 1 --is the paragragh that will be found in a single preference finder. change it throughout the script to switch paragragh found
---End of Base

--write prefs snippet (overrides original)
if CheckIfExists(prefname, prefpath) is true then DeleteAFile(prefname, prefpath)
MakeAFile(prefname, prefcontent, prefpath)
display dialog (prefpath & " " & prefname)
--end write prefs

---read Prefs snippet
if CheckIfExists(prefname, prefpath) then
set pref to paragraph ContentParaNumber of ReadAFile(prefname, prefpath)
set ThereArePrefs to true
set ThereArePrefs to false
end if
if ThereArePrefs then display dialog pref --or whatever you want
---End read

on UnixfyPath(stringer, origchar, newchar)
set the testlist to the text items of the stringer
repeat with letter in testlist
set let to letter as string
set orig to origchar as string
if let is orig then
set the contents of the letter to newchar
end if
end repeat
set the newpath to "/" & (the testlist as text)
return the newpath
end UnixfyPath

on MakeAFile(filename, filecontents, folderpath)
tell application "Finder"
do shell script ("echo \"" & filecontents & "\" | cat > \"" & folderpath & "/" & filename & "\"")
end tell
end MakeAFile

on ReadAFile(filename, folderpath)
tell application "Finder"
set filecontent to do shell script "cat \"" & folderpath & filename & "\""
end tell
return filecontent
end ReadAFile

on DeleteAFile(filename, folderpath)
tell application "Finder"
do shell script "rm \"" & folderpath & filename & "\""
end tell
end DeleteAFile

on CheckIfExists(filename, folderpath)
tell application "Finder"
set folder_cmd to ("find \"" & folderpath & filename & "\"")
do shell script folder_cmd
set worked to true
on error
set worked to false
end try
end tell
return worked
end CheckIfExists

on FindPrefFolder()
tell application "Finder" to set libpath to path to home folder
set userName to do shell script "whoami"
set UnixPath to UnixfyPath("Users:" & userName & ":", ":", "/")
set prefpath to UnixPath & "Library/Preferences/"
return prefpath
end FindPrefFolder


Turning applescripts into apps

This may seem very simple to those have done it before but it took me a while to figure it out.

Once you have written your applescript and saved it as normal.

File -> Save As and change format to application.
When it is saved it will be a *.app

Saturday, 23 August 2008

Testing blogger div postioning iframes

here should be 3 iframes next to each other

Friday, 22 August 2008

OS X and X11 XTerm

For some reason I have to use the X11 Terminal when using Screen on some remote machines, it might just be a setup issue with screen on those machines but for now I wanted my XTerm to look similar to my pro Terminal windows ie black background and white text.

for this you need to create a .Xresources file. Which can be done using vim from a terminal.
$vim ~/.Xresources
and paste in the following

XTerm*foreground: white
XTerm*background: black
You will then need to completly restart the X server, easiest way I know is a full system restart.
NB: you can actually see what this will do by launching X11 and creating several new XTerms. The settings do not get applied to the first instance but they will once rebooted.

Shebang Line Magic

For scripts that are written in languages that often have a nonstandard install location I use to just call directly eg $ruby script.rb. as there was non standard dir like #!/bin/bash

but I recently discovered a nice shebang line trick.
#!/usr/bin/env ruby
Will look up the users path to the program and call it. So as long as ruby is intstalled and on the users path (as it would need to be for ruby script.rb to work) the script should be portable between users/systems. Now I just call $script.rb

Sunday, 17 August 2008

Linux, Mac Os X and Windows Portable Filesystem

[Update] Newer easier to use MAC NTFS driver post [/Update]

Portable file systems between all 3 big OS, Linux, Mac OS X and Windows.

Fat32 is compatible with all three but is very inefficient when dealing with larger disks (500GB+).

Unfortunately the most compatible seems to be Windows NTFS. Using FUSE and NTFS-3g on Linux and MAC we can have Read/Write access, I do not think that the Journaling is used though.

Mac OS X guide at
Basically install mac ports
then $ sudo port install ntfs-3g

NB: when switching on external drives they will try to automount. if the safe device removal is not used the NTFS disk is labeld as an unclean mount. (Even if the windows option is set to write directly to the driver, and not use a cache to improve performance)

The dialog box that displays this warning does not list the correct command to fix it it should be replaced with something like :
$ /usr/local/bin/ntfs-3g /dev/rdisk2s1 /Volumes/Terra02 -o force

Saturday, 16 August 2008

Mac OS X & GPS

So finally Garmin have released so software for OS X
But it mostly requires you to have bought one fo the more expesive models with USB and not the more popular Serial models. I think I still have a problem of connecting my Serial Garmin eTrex Legend to a macbook via usb. Dont think the serial to usb cable I have is compatible but cant check until I get some software that can try accessing the GPS!

Memory map is Windows only, so it is looking likely that I will have to install parallels just to get the GPS working.

PS I got my GPS from but it looks like they have stopped trading now :(

Saturday, 9 August 2008

My Camera Wish List

My current camera is the Canon 400D. My favorite lens at the moment is the 17-85mm f4-5.6 IS it is a 3 stop Image stablising lens and is great for walking about with.

My current Wish list for Camera parts is:

055 3 Stage Normal

055 3 Stage Light Weight.

190 Normal

190 Light Weight

SanDisk seem to make fast reliable Compact Flash (CF) cards and occasionally come up for amazing prices. £17.99 for a 4GB x133 speed card!

The 70-200 F4 IS Lens seems to have gotten good reviews. there is a F2.8 version of this lens but it is much heavier and it is not that sharp at f2.8 and twice the price. The f4 version is sharp from f4. and you could set the exposure compensation to ev-1 for Av mode and you would get the shutter speed of a f2 lens and then post process compensate by 1 Stop.

I Really Like the Quality of the Manfrotto tripods but can not decide which model I would like. The 190 series don't quite go up to eye level and feel a little flimsy while the 55 is rock solid but quite weighty. The 055 Mag fiber is about the same weight as the standard 190, but then you could get the lieght weight 190 and have a tripod that you could take any where. For both there are 3 and 4 section legs. 4 is a little it more compact but 3 is lighter and stiffer which is what you want out of a travel tripod?

I love the geared head. it is so easy to accurately position no real effort required and the action is very smooth but it is expensive and adds a lot of weight (if you have just paid double for a light weight set of legs).

The 3D Magnesium Head is cheaper and very light but I found the knobs very hard to turn. They are very stiff unlike the geared version and do not have large grips like the geared head.

New DIY Desk for my Macbook

I have been unable to use my nice chair for a while as I had know where to put my mac book. Last weekend I bolted a few scraps of wood I had lying around together and came up with this.

Wednesday, 6 August 2008

Applescript Resources

From the horses mouth (Took along time to find this link)

When using apple script to call shell commands
Blogged with the Flock Browser

Tuesday, 5 August 2008

Edinburgh Fringe First Weekend 2008

Shows i went to see on the first fringe weekend 2008

Dermot Mcmorrow: 13 Black Cats In The Shape Of A Magpie
Eco-Friendly Jihad
X-Files Improv with Dean Haglund
Paul Kerensa - iPaul

Bombay to Beijing by Bicycle
Phil Kay - Greatest Hits

PLUCK: The Titanic Show
Stephen Grant - Second

Bad Dog Variety
The British Ambassadors Belly Dancer
7 Sins

Sunday, 27 July 2008

Darwin Ports useful commands

To update the ports
sudo port -d selfupdate

To search for and install a port, example program is fping
port search fping
sudo port install fping

More information can be found at

[Edit 19/07/2009]
This page looks like a very good resource on port commands:

Saturday, 26 July 2008

More pocket guides that I own

Favourite Pocket Guides

O'Reilly are one of my favourite publishers. When looking for a desktop manual their in a nutshell series is very useful. They also have a very good set of Pocket Guides, some of my favourite ones are:

Friday, 25 July 2008

Mac OS X boot options

When OS X (at least 10.5) is booting there are several key combinations that can be pressed for different modes:

C : Boot from CD or DVD
N : Attempt NetBoot server boot
R : Reset display for mac laptop
T : Boot as a mountable firewire harddrive, switch off to exit
X : forces OS X boot when OS 9 installed
CMD-S : Single User mode
CMD-V : Verbose Mode just like linux
Shift : Safe mode
Option : Load Startup manager
Mouse Button : Eject Disc

Make bash your default shell

For some reason in screen on my ubuntu mini-itx machine when I create new terminals the shell just defaults to sh. so I have been trying to make it go straight to bash.

The following command should make bash the default shell
chsh -s /bin/bash username

Wednesday, 16 July 2008

VLC Now works on OS X 10.5.4

VLC, My favorite media player for the Mac now works correctly on OS X 10.5.4.

Bugs I have seen fixed are:
Full screen now exits correctly. Instead of getting locked out in the spaces layer.
When in Full Screen mode Expose and spaces work

latest version VLC 0.8.6i

Blogged with the Flock Browser

Friday, 11 July 2008

Inverting Screen Colours OS X

I often get saw eyes when reading web pages in low light on my macbook, so I find this keyboard short cut very useful.
Which inverts the colours. White text on a black back ground is much easier on the eyes, and since there is less light comming off the screen your eyes can adjust better to see the keyboard.

Wednesday, 9 July 2008

Screen CTRL-S Bug

When switching between terminals and text editors the occasional ctrl-s gets accidentally typed into the terminal. For along time I thought that this was a bug in screen but it is a standard terminal feature. Ctrl-s calls the software flow control method XOFF which stops the character flow to the terminal, which when you did not realise what you pressed just seems to freeze the terminal.

ctrl-q calls XON and starts the terminal again.

For a more permanent fix you can add this to your .bashrc (not sure how other shells are effected).

stty ixany

Which allows any character to call XON, so the character press is sent and displayed and you will never be aware of the terminal freezing.

If this does not work for you, or you also don't seem to be able to send ctrl-s ctrl-q commands to terminal applications you can use
stty stop undef To unmap ctrl-s
stty start undef To unmap ctrl-q

Or to stop XOFF and XON being sent from the keyboard but still allowing other software to send the commands use
stty ixoff -ixon
NB: ctrl-q can now be used to shutdown rtorrent

Tuesday, 24 June 2008

Screen tips

I am a big fan of screen for when working with terminals. When working with remote connections it is very handy if you require a new terminal do something and protects you against dropped connections. or if you start running a job that takes longer than expected, you can just disconnect and pick it up again later.

Just found this tip at
Add this to ~/.screenrc
hardstatus alwayslastline
hardstatus string '%{= mK}%-Lw%{= KW}%50>%n%f* %t%{= mK}%+Lw%< %{= kG}%-=%D %d %M %Y %c:%s%{-}'

This gives a tab along the bottom of the open terminal (Screen Session).

also this line (from the same source) added to crontab
@reboot screen -S rtorrent -md /usr/bin/rtorrent

Will create new screen session (disconnected) and start the bit torrent program rtorrent.

To edit the crontab
$crontab -e

This page looks like a good crontab reference

Wednesday, 4 June 2008

Adding Samba Users

To add new users to Samba with out enabling ssh login to Ubuntu and Debian systems
$sudo adduser --disabled-login newuser
$sudo smbpasswd -a newuser

Don't forget to add the newuser to the smb.conf allowed user property

My favourite terminal torrent client

I have been looking for a nicer terminal bit torrent client than bit tornado for a while and came across rtorrent. It has its own wikipedia page. I have found this torrent client to be much faster than the official version.

It is easily installed on Debian and Ubuntu systems with
$sudo apt-get install rtorrent

NB: if $apt-cache search rtorrent does not return any results you may need to add some thing to your sources list.

On OS X it is available once you have installed and setup Darwin ports.
$sudo port install rtorrent
Good tutorial here for getting it running

Sunday, 1 June 2008

Installing phpmyadmin

Installing phpmyadmin for web admin of mysql database.
First install mysql
$sudo apt-get install mysql-server mysql-client php5-mysql

Then install phpmyadmin
$sudo apt-get install phpmyadmin

there is a howto forge document here that gives a fuller explanation.
The correct how to suggests that you include the config file in the main apache2.conf.

Ubuntu/Debian systems have a folder called sites-enabled sites-available in /etc/apache2 .
conf files in these folders are loaded. Generally you will write the .conf files in the available forlder and create soft links to them from the enabled folder. so instead of inlcudeing this line in apache2.conf
Include /etc/phpmyadmin/apache.conf

I suggest creating a link to it from the enabled folder
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/sites-enabled/phpmyadmin

If doing it properly you should copy it to the sites-available and link to it there, rather than linking directly to it.

Ubuntu reconfigure software once installed

Note to self when you mess up the installation of a program by choosing the wrong options in the blue configuration screen run dpkg-reconfigure.
$sudo apt-get install somepackage
somepackage downloads installs and runs through configuration.
choose the wrong option and try to remember how to run the setup
$sudo dpkg-reconfigure somepackage

Ubuntu setting up Apache

Setting up Apache2 with php5 on my Ubuntu server is as simple as .

$sudo apt-get install apache2 php5 libapache2-mod-php5

Well Apache and php works, just got to get mySQL and phpmyadmin setup.
Used this page as reference.

Saturday, 31 May 2008

Ubuntu configuring samba

Installing Samba on my new server
$sudo apt-get update
$sudo apt-get install samba

Backup configuration
$sudo cp /etc/samba/smb.conf /etc/samba/

Now configure
$vim /etc/samba/smb.conf

my setup
[edited 01/11/09]
My Example Config can be found here
[edit over]

Dont forget to create a samba user (relies on a standard user with that name present) then set the samba password.
$sudo smbpasswd -a username

Final step restart Samba
$sudo /etc/init.d/samba restart

Convert debain/ubuntu to static IP

My Ubuntu Mini-ITX server was by default being assined an IP through DHCP from the router. If my router could assign IP based on the MAC address I would not have to assign a STATIC IP on the machine itself but could control it from a central location. Since I dont have this most of my machine have a static IP assigned. For Debain and Ubuntu systems this is quite easy.
Following instructions are for eth0 (the first real network socket)

$sudo vim /etc/network/interfaces

This text should already be present
auto lo
iface lo inet loopback

if these lines are present delete/comment out (#at the beginning of the line is a commet)
auto eth0
iface eth0 inet dhcp

Add the following (replace the x's with the assigned ip)
#### Manually Added Below Morgy ####
auto eth0
iface eth0 inet static
address 192.168.1.x
gateway 192.168.1.x

Now restart networking
$ sudo /etc/init.d/networking restart

A more complete tutorial

Darwin Ports

I recently found out about the Darwin Ports. It is built on the BSD package management system and lets you easily install unix programs that have been ported to os x. The package management part of it handles the dependencies for you. You do need to install Xcode first though.

Once downloaded you need to add the darwin ports binaries folder to the search path. from the terminal run (or manually added the path to the .bashrc)
$echo 'export PATH=$PATH:/opt/local/bin' >> ~/.bashrc
$echo 'export PATH=$PATH:/opt/local/sbin' >> ~/.bashrc

Friday, 30 May 2008

Moving the /home dir

I am currently working on a low power mini-itx server. The operating system and boot partition is a 8GB flash drive, with a 1TB SATA drive for storage which can be powered down when not being used.

The OS is Ubuntu, running samba. I will be backing up my laptop to the server and so lots of data will be going into the homes directory. Therefore I need to move the /home/ directory to the 1TB Drive.

The partitioning/formatting/mounting steps taken for /dev/sda.

$ sudo fdisk /dev/sda
option n to edit partition table.
option w to write the new partition.

Format ext3
$ sudo mke2fs -j /dev/sda1

Mounting, edit /etc/fstab
$ sudo mkdir -p /mnt/hostname/partitionname
$ sudo vim /etc/fstab

added this line
/dev/sda1 /mnt/hostname/partitionname ext3 rw,auto,async,errors=remount-ro 0 1

$ sudo mount -a

The new partition is now mounted.
Now move the homes directory
$ sudo cp -ax /home /mnt/hostname/partitionname/
$ sudo mv /home /home.old
$ sudo ln -s /mnt/hostname/partitionname/home /

Thursday, 3 April 2008

Crucial 4GB DDR2 Kit

I have just upgraded my macbook from 1GB to 4GB for £55 from

very pleased with the price apple were 12 months ago charging £500 for it to be pre-installed!

Saturday, 1 March 2008

Stream Line Windows XP intall

I have a motherboard with SATA but when installing windows XP I am required to provide the SATA drivers by floppy disc. I dont have a floppy disc drive so I managed to find a way around described in this article

As long as you already have a working windows installation you can use nLite
to create a custom windows installation disc, that includes any required drivers.

Sunday, 24 February 2008

Stop the Startup Sound on OS X

The default system preferences in mac os x do not give you the option to stop the sound that os x makes when booting. This could be a problem if you were in a library or a lecture, luckily there is a 3rd party app that will mute the sound on shutdown and return it to the original volume when booted there fore stopping any sounds during boot (even the warning ones when things go wrong)

Graphical ftp for Mac OS X

After reading this article

I decided to try the Cyberduck as my ftp program, seems pretty straight forward and reliable so far.

Saturday, 26 January 2008

Mac OS X tips

discovered this site today and so far worked back through to Nov 2007 archives.

My favorite tips so far have been about 3 apps.
iRed Lite - get the apple remote working with other apps like VLC.

Battery Health Monitor - Tells you current capacity of your battery and number of charge cycles you have put it through.

As a recent convert from Windows (and Linux) I am use to having a start button with access to all applications, which seems to be missing on OS X. So on Leopard i created a stack from the applications folder. However I have grouped a lot of similar applications in folders so clicking on this in the stack just opens the folder in the finder. This program says that it will fix that and I can treat my applications stack just like a windows programs menu.

Wednesday, 23 January 2008 on OS X Leopard Backspace

When using on OS X Leopard the backspace works correctly until I ssh onto another machine, running debian and normally accessed by putty from a windows machine.

When ssh'd onto the external machine the backspace acts as a delete key.

I fixed the Problem by going to
Terminal -> Prefferences settings tab, advanced sub tab then select "Delete sends Ctrl-H"
This fixed the problem for me.