Twitter Updates

Wednesday, 19 November 2008

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 ?