Twitter Updates

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)
[global]
#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.

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

#Integer
somthing3 = 1

#Float
something4 =3.14

#Symbols (light weight strings)
:something5

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

#Global Variables (dollar sign)
$somthing100

#Instance Variables
@instanceVar

'Class Variables
@@classVariable

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

Object::classMethods
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.

Virgin.net 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
$ethstatus

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
http://www.virgin.net/allyours/faqs/trafficmanagement.shtml
--

Tuesday, 25 November 2008

Search and replace for multiple files

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

source

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 http://github.com 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.
http://github.com/munkymorgy/munkymorgy_scripts/tree

NOTE [Added 28/04/2009]:
The following link seems to suggest a good way of displaying code snippets on blogspot.com
http://lukabloga.blogspot.com/2008/10/to-test-new-highlighting.html

Saturday, 22 November 2008

Ubuntu Media Codecs

To install codecs to play back mpeg 4 video files I followed the instructions here http://linuxowns.wordpress.com/2008/02/11/media-and-ubuntu/ for Ubuntu 8.04

$sudo wget http://www.medibuntu.org/sources.list.d/hardy.list -O /etc/apt/sources.list.d/medibuntu.list
$wget -q http://packages.medibuntu.org/medibuntu-key.gpg -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 terminal.app.

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. http://www.erasetotheleft.com/post/mac-os-x-key-bindings/

This page gives an example of there fixed keymap
http://exported.wordpress.com/2008/01/12/mac-key-bindings/

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
http://www.macupdate.com/info.php/id/15585

Equivalently you could call this from the command line
$defaults write com.apple.finder 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 = Time.now

Main part of script goes here

#Calculate and Display Execution Time in seconds
execTime = Time.now - 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.

http://code.google.com/p/rssdler/
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
$wget http://rssdler.googlecode.com/files/rssdler-0.4.0a.tar.gz
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!
http://code.google.com/p/rssdler/wiki/InstallInstructions

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 setup.py 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 http://code.google.com/p/rssdler/wiki/CommentedConfig

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 '#'
----
[global]
downloadDir = /mnt/starbug1/terra1/samba/10-test/
workingDir = /home/morgy/.rssdler
log = 5
logFile = downloads.log
verbose = 5

scanMins = 2
runOnce = True
urllib = False

[testrss]
link = http://rss.thepiratebay.org/0
----

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
http://developer.apple.com/internet/opensource/osdb.html

The following way seemed to work for me:
Download the Mac OS X Package from http://dev.mysql.com/downloads/mysql/5.0.html#macosx-dmg. Requires a free registration but led me to this link in the end

http://dev.mysql.com/get/Downloads/MySQL-5.0/mysql-5.0.67-osx10.5-x86_64.dmg/from/http://mirrors.ukfast.co.uk/sites/ftp.mysql.com/

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 http://www.pengekcs.com/2007/12/25/taming-spotlight-to-not-index-specific-external-drives-at-all-in-os-x/ 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 Terminal.app)
$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 .

http://www.zaphu.com/2008/04/29/ubuntu-guide-configure-avahi-to-broadcast-services-via-bonjour-to-mac-os-x/

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

setting up for samba
http://holyarmy.org/benjamin/2008/01/advertising-linux-services-via-avahibonjour/#more-293

$ 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">
<service-group>
<name replace-wildcards="yes">%h</name>
<service>
<type>_smb._tcp</type>
<port>139</port>
</service>
</service-group>

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
192.168.1.1 router.local
192.168.1.3 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/Terminal.app


$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!