Friday, 30 December 2011

Simple command line email on Mac using gmail account

Here's a simple 3 step process for configuring you mac to send email from the command line using a gmail account.  You will need to:
  1. Install macports if you haven't already
  2. Install ssmtp from macports
  3. Update the ssmtp configuration files
Step 1, Install macports

If you haven't already installed macports go here: macports and get it, and install it.


Step 2, Install ssmtp from macports

Open a terminal window and use the following to install the ssmtp software
$ sudo port install ssmtp

Step 3, Update the ssmtp configuration files

Using your fav editor, make the following changes to the non-existent ssmtp.conf file:

$ sudo vi /opt/local/etc/ssmtp/ssmtp.conf

root=yourgmailaccount@gmail.com
mailhub=smtp.gmail.com:587
rewriteDomain=
hostname=yourgmailaccount@gmail.com
UseSTARTTLS=YES
AuthUser=gmail_username_here
AuthPass=gmail_password_here
FromLineOverride=YES

Now edit the rev aliases file

$ sudo vi /opt/local/etc/ssmtp/revaliases


root:yourgmailaccount@gmail.com:smtp.gmail.com:587
rob:yourgmailaccount@gmail.com:smtp.gmail.com:587

Step 4, Test

Test that it works, from the command line:
$ /opt/local/sbin/ssmtp rob@somewhere.com
Subject: some subject
this is some text
^d 

(Use ctrl d to after you've finished writing your message.)

Tuesday, 30 August 2011

Drupal Error - PHP Warning: Unknown: POST Content-Length of 796 bytes exceeds the limit of -2147483648 bytes in Unknown on line 0

The following error appears in your apache log and it's not possible to do a lot on your drupal site....

PHP Warning:  Unknown: POST Content-Length of 796 bytes exceeds the limit of -2147483648 bytes in Unknown on line 0

This was caused by changing the values in the php.ini for the file upload max size.  Ensure that you encase all values in speech marks.

post_max_size = "1024M"
upload_max_filesize = "1024M"

Friday, 1 April 2011

How to install the latest ImageMagick on AWS

Amazon is still a fair bit behind the latest versions of ImageMagick.  If you need a latter release then follow these instructions.

Get rid of the old version
# yum remove ImageMagick

Install the dependancies
# yum install wget tcl-devel libpng-devel libjpeg-devel ghostscript-devel bzip2-devel freetype-devel libtiff-devel

Now get ImageMagick from http://www.imagemagick.org/script/download.php and download the latest source with wget or curl.

Extract it
# tar zxvf ImageMagick-x.x.x-x.tar.gz

Build it
# configure --prefix=/usr/local --with-bzlib=yes --with-fontconfig=yes --with-freetype=yes --with-gslib=yes --with-gvc=yes --with-jpeg=yes --with-jp2=yes --with-png=yes --with-tiff=yes
# make clean
# make
# make install


Then you should be hot to trot. Type convert -version to see the upgraded version number.

Sunday, 13 March 2011

Mirroring Root Disk with DiskSuite - mirror_root Shell Script

I wrote this script now almost decade ago, and actually had to use it the other day. Love it when that happens...

On Solaris 2.6 (With DiskSuite installed), 7, 8, 9 and 10 this will mirror your root disk to another using disksuite and then reboot the box to attach the mirror.



#!/usr/bin/ksh
#
# Purpose: Script to mirror root disk using Solstice Disksuite.
# Rob Brown 14/05/2001
#
ROOTDISK=$1
ROOTMIRROR=$2
METADBSLICE=$3
PATH=$PATH:/usr/opt/SUNWmd/sbin:/usr/dt/bin:/usr/openwin/bin:/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/openwin/bin

#
# Sanity Chk. Ensure Binaries exist and
# determine Paths to them. Also ensure no
# disksuite metadb's have been configured.
# Check users has sufficent permissions and check
# they are frood enough to continue.
#

#
# Configure Paths
#
if [ -f /usr/opt/SUNWmd/sbin/metastat ]; then
METASTAT=/usr/opt/SUNWmd/sbin/metastat
METADB=/usr/opt/SUNWmd/sbin/metadb
METAINIT=/usr/opt/SUNWmd/sbin/metainit
METATTACH=/usr/opt/SUNWmd/sbin/metattach
METAROOT=/usr/opt/SUNWmd/sbin/metaroot
MDTAB=/etc/opt/SUNWmd/md.tab

elif [ -f /usr/sbin/metastat ]; then
METASTAT=/usr/sbin/metastat
METADB=/usr/sbin/metadb
METAINIT=/usr/sbin/metainit
METATTACH=/usr/sbin/metattach
METAROOT=/usr/sbin/metaroot
MDTAB=/etc/lvm/md.tab

else
echo No Disksuite binaries found. Please ensure it is installed.
exit 1
fi


#
# Do Any metadbs already exist?
#
${METADB} > /dev/null
if [ "$?" -ne "1" ]
then
echo "Metadb's may exist, or funny return code from metadb. Please clear down before rerunning ${0}."
exit 1
fi


#
# Is user root?
#
ID=`id`
USER=`expr "${ID}" : 'uid=\([^(]*\).*'`

if [ "${USER}" != "0" ]; then
echo "You must be root to run $0"
exit 1
fi


#
# Are Disk variables populated?
#
if [ "${ROOTDISK}" = "" ] || [ "${ROOTMIRROR}" = "" ] || [ "${METADBSLICE}" = "" ]; then
echo "Information missing: "
echo "Usage: $0 rootdisk rootmirror metadbslice"
echo "e.g. ${0} c1t0d0 c1t1d0 s7"
exit 1
fi



#
# Main
#
echo "Backing up old system/vfstab..."
cp /etc/vfstab /etc/vfstab.pre-`basename ${0}`
cp /etc/system /etc/system.pre-`basename ${0}`


#
# Write vtoc and check, bomb out on any errors.
#
echo "Writing ${ROOTDISK}'s vtoc ---> ${ROOTMIRROR}..."
prtvtoc /dev/rdsk/${ROOTDISK}s2 > /tmp/root-vtoc
fmthard -s /tmp/root-vtoc /dev/rdsk/${ROOTMIRROR}s2

FMTHARD_RTN=${?}
if [ "${FMTHARD_RTN}" -ne "0" ]; then
echo "Error Writing the vtoc from ${ROOTDISK} to ${ROOTMIRROR}, are they"
echo "the same type/size of disk?? Exiting."
exit
fi

echo "Creating MetaDatabases..."
${METADB} -a -c 3 -f ${ROOTDISK}${METADBSLICE}
${METADB} -a -c 3 -f ${ROOTMIRROR}${METADBSLICE}

echo "Meta DataBase: "
${METADB}

for SLICE in `cat /tmp/root-vtoc |grep -v '*' |awk '{print $1}'`
do
if [ ${SLICE} -eq "2" ] || [ ${SLICE} -eq `echo ${METADBSLICE} |cut -c2` ]
then
echo Not Touching slice ${SLICE} as it is either the MetaDB or the backup Slice.
else
echo Creating Sub Disks and Mirroring Slice ${SLICE}
MD_ROOT="d`expr ${SLICE} + 10`"
MD_MIRR="d`expr ${SLICE} + 20`"
MD_MIRROBJECT=d${SLICE}
${METAINIT} -f ${MD_ROOT} 1 1 ${ROOTDISK}s${SLICE}
${METAINIT} ${MD_MIRR} 1 1 ${ROOTMIRROR}s${SLICE}
${METAINIT} ${MD_MIRROBJECT} -m ${MD_ROOT}

echo "${METATTACH} ${MD_MIRROBJECT} ${MD_MIRR}" >> /etc/rc3.d/S98finish_mirror

cp /etc/vfstab /etc/vfstab.pre_rootmirror
cp /etc/vfstab /tmp/vfstab

if [ ${SLICE} -eq "0" ]
then
${METAROOT} ${MD_MIRROBJECT}
else
# Need to change entry in vfstab
echo "Altering the vfstab..."
cat /etc/vfstab |sed -e "s/\/dsk\/${ROOTDISK}s${SLICE}/\/md\/dsk\/${MD_MIRROBJECT}/" > /tmp/vfstab
cp /tmp/vfstab /etc/vfstab
cat /etc/vfstab |sed -e "s/\/rdsk\/${ROOTDISK}s${SLICE}/\/md\/rdsk\/${MD_MIRROBJECT}/" > /tmp/vfstab
cp /tmp/vfstab /etc/vfstab
fi
fi
done

# Create md.tab, and make the finish_mirror script runable at next boot.
echo "${METASTAT} -p >> ${MDTAB}" >> /etc/rc3.d/S98finish_mirror
echo "/usr/bin/rm /etc/rc3.d/S98finish_mirror" >> /etc/rc3.d/S98finish_mirror
chmod 755 /etc/rc3.d/S98finish_mirror

echo "This system must now be rebooted, to attach new mirrors."

Thursday, 3 March 2011

Monitoring MacOS X host with SNMP and Cacti

I've been monitoring some hosts with cacti and needed to add a MacOS X host in.  This is how to configure SNMP on Snow Leopard and configure cacti.

Edit your /etc/snmp/snmpd.conf on the Mac and place the following into it:

rocommunity public
includeAllDisks 10%


Once saved, start the snmpd daemon with:

sudo launchctl load -w /System/Library/LaunchDaemons/org.net-snmp.snmpd.plist

Thats it from the Mac side, now in cacti add it as a you would any other device, but also add a graph type of "[SNMP - Get Processor Information]" to get the processor information broken down by core.

Thats it.  You should start seeing some graphs like the following:

Sunday, 13 February 2011

Goa Mix Cue Sheets

Tried everywhere to find some cue sheets for the two CD edition of the original 1994 Essential Mix - Goa Mix and finally had to create my own from different sources.

Here's the first CD:

PERFORMER "Paul Oakenfold"
TITLE "The Goa Mix - Silver"
FILE "cd1.mp3" mp3

TRACK 01 AUDIO 
 TITLE "Give Me Life" 
 PERFORMER "Mr V"
 INDEX 01 00:52:00
TRACK 02 AUDIO 
 TITLE "Skin On Skin (Orange Mix)" 
 PERFORMER "Grace"
 INDEX 01 1:53:11
TRACK 03 AUDIO 
 TITLE "Point Zero" 
 PERFORMER "Li Kwan"
 INDEX 01 8:07:21
TRACK 04 AUDIO 
 TITLE "De Niro (Spaceflight Mix)" 
 PERFORMER "Disco Evangelists"
 INDEX 01 13:29:95
TRACK 05 AUDIO 
 TITLE "Vaporise" 
 PERFORMER "Virtual Symmetry"
 INDEX 01 15:30:80
TRACK 06 AUDIO 
 TITLE "Tears In The Rain" 
 PERFORMER "Vangelis"
 INDEX 01 20:23:37
TRACK 07 AUDIO 
 TITLE "Eugina (Pacific Diva Mix)" 
 PERFORMER "Salt Tank"
 INDEX 01 22:17:35
TRACK 08 AUDIO 
 TITLE "LSD" 
 PERFORMER "Hallucinogen"
 INDEX 01 23:51:02
TRACK 09 AUDIO 
 TITLE "Only Love Can Break Your Heart" 
 PERFORMER "Saint Etienne"
 INDEX 01 29:43:62
TRACK 10 AUDIO 
 TITLE "Vampire Hunters" 
 PERFORMER "Wojciech Kilar"
 INDEX 01 29:59:84
TRACK 11 AUDIO 
 TITLE "Alcatraz" 
 PERFORMER "Electrotete"
 INDEX 01 30:59:61
TRACK 12 AUDIO 
 TITLE "Main Titles" 
 PERFORMER "Vangelis"
 INDEX 01 37:00:39 
TRACK 13 AUDIO 
 TITLE "Floor Essence" 
 PERFORMER "Man With No Name"
 INDEX 01 39:00:89
TRACK 14 AUDIO 
 TITLE "Bugcatcher" 
 PERFORMER "Scorpio Riding"
 INDEX 01 45:02:58
TRACK 15 AUDIO 
 TITLE "Evolution" 
 PERFORMER "Man With No Name"
 INDEX 01 48:01:97

and the second

PERFORMER "Paul Oakenfold"
TITLE "The Goa Mix - Gold"
FILE "cd2.mp3" mp3

TRACK 01 AUDIO
 TITLE "Inner City Life" 
 PERFORMER "Goldie"
 INDEX 01 00:00:00
TRACK 02 AUDIO
 TITLE "Love Remembered" 
 PERFORMER "Wojciech Kilar"
 INDEX 01 01:36:61
TRACK 03 AUDIO
 TITLE "Co-Incidence" 
 PERFORMER "Voodoo People"
 INDEX 01 03:09:17
TRACK 04 AUDIO
 TITLE "Stimuli" 
 PERFORMER "The Infinity Project"
 INDEX 01 06:23:62
TRACK 05 AUDIO
 TITLE "Wake Up! (Trance Mix)" 
 PERFORMER "Trance Team"
 INDEX 01 10:59:03
TRACK 06 AUDIO
 TITLE "Heretic Voices (Angeles Mix)" 
 PERFORMER "V-Tracks"
 INDEX 01 14:02:05
TRACK 07 AUDIO
 TITLE "Schöneberg (Marmion Remix)" 
 PERFORMER "Marmion"
 INDEX 01 16:11:63
TRACK 08 AUDIO
 TITLE "Hierophone" 
 PERFORMER "Karl Biscuit"
 INDEX 01 23:13:74
TRACK 09 AUDIO
 TITLE "Rachel's Song" 
 PERFORMER "Vangelis"
 INDEX 01 25:42:30
TRACK 10 AUDIO
 TITLE "Sun (Oakenfold & Osborne Mix)" 
 PERFORMER "Virus"
 INDEX 01 27:19:70
TRACK 11 AUDIO
 TITLE "Deliverance" 
 PERFORMER "Man With No Name"
 INDEX 01 35:27:66
TRACK 12 AUDIO
 TITLE "Reach Up! (Indian Summer Mix)- Remix - Man With No Name" 
 PERFORMER "Perfecto Allstarz"
 INDEX 01 42:40:72
TRACK 13 AUDIO
 TITLE "Song Of Liberation" 
 PERFORMER "Para-Dizer"
 INDEX 01 48:09:74
TRACK 14 AUDIO
 TITLE "Sanvean" 
 PERFORMER "Dead Can Dance"
 INDEX 01 53:35:54
TRACK 15 AUDIO
 TITLE "Eternal Spirit (Northern Mix)" 
 PERFORMER "4Voice"
 INDEX 01 57:08:23
TRACK 16 AUDIO
 TITLE "Sugar Rush" 
 PERFORMER "Man With No Name"
 INDEX 01 61:00:10

Friday, 11 February 2011

Tour de France iCal - Calendar Feed

Updated for the 2015 Tour de France!!!
Updated for the 2014 Tour de France!!
Updated for the 2013 Tour de France!
Updated for the 2012 Tour de France

Tour fan?  Want to know what stage is on at what time so you can organise your TV viewing around your work schedule (kidding - kind of)?  Want it to dynamically update your calendar as the Tour develops?

Well how's this look...



I've setup an iCal feed for the Tour De France which you can subscribe too.  If you use your iCal compliant calendaring tool (iCal.app on Mac or Outlook on PC, or your iPhone) then it will display all the stage details on the days that they happen.

You can see below that it creates a separate Calendar so won't write over the top of any other calendars you have, and can easily be toggled on and off.



As I get updates on the start times, distances and anything else I find interesting I'll update the feed and you will automagically see the updates in your calendar.

This will work (providing anybody uses it) for subsequent years of the TDF as well and will populate as the data becomes publicly available.

I've tested this on iPhone and Mac iCal, just clicking on this:

webcal://openstripe.com/iCals/icalgen.php?cal=tdf

Not sure about other clients, you may need to use the standard http protocol from other apps.

http://openstripe.com/iCals/icalgen.php?cal=tdf

Make sure you subscribe and don't just download the calendar entries otherwise you won't get any updates.

Please leave me a comment if you find this useful, it will help me find the five minutes needed to update the calendar with the stage details.

How to use with Outlook

 You can subscribe this calendar in outlook by doing the following.

"File" -> "Account Settings" -> "Account Settings" -> "Internet Calendars" -> "New" -> "webcal://shermanroad.dyndns-home.com/cals/icalgen.php?cal=tdf"

Change the Name to "Tour de France" or something meaningful for you.

You should then be able to toggle it on and off as a new calendar.

Thursday, 10 February 2011

Sheeva Plug Problems and Fixes

Problem)
PHP errors with "PHP Fatal error:  Call to undefined function curl_init()"

Fix)
apt-get install php5-curl; /etc/init.d/apache2 restart

MacOS X Widgets - Video File Size Calculator

A while back wrote a simple widget for MacOS X which calculates the file size of Video files based on their length and Bitrate.



It also shows the workings on the reverse!



Just in case anyone might want it, and so I know where it is when I do...

You can download it here: Download Link

Saturday, 5 February 2011

To toggle the "Tick" in a UITableViewCell

To check or uncheck a "tick" box in a UITableViewCell cell and also unhighlight it afterwards.

First make sure it's accessoryType is set:

cell.accessoryType = UITableViewCellAccessoryCheckmark;

And then in the didSelectRowAtIndexPath method:


// Toggle the "Tick" on and off
UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

if (cell.accessoryType == UITableViewCellAccessoryCheckmark) {
cell.accessoryType = UITableViewCellAccessoryNone;
}else if (cell.accessoryType == UITableViewCellAccessoryNone) {
cell.accessoryType = UITableViewCellAccessoryCheckmark;
}
// This removes the highlighting of the Cell
[tableView deselectRowAtIndexPath:indexPath animated:YES];

Friday, 4 February 2011

A call to all Xcode / iPhone tutorial writers

I'm trying to learn some iPhone development using xcode - It's real difficult.  Xcode is really painful to learn.  It's often made even more confusing by Interface Builder the tool for graphically designing apps.

Why does a company so steeped in design and graphical loveliness make it impossible to graphically layout the majority of your app?

I've been trying for a day and a half to learn how to select an option in a list and navigate to a different view when it is selected - I'm still not there, why is this so difficult?!  I'm on probably my 13th tutorial but I'm suffering badly with these as well.  And there's two common problems with them:
  1. Not providing downloadable code.  I've worked my way through at least 5 which plain out just didn't work.  If I can download the code I can check it works, does what I need, and only then read the tutorial.
  2. Not explaining the Interface Builder actions well enough.

Here's an example of the second from an otherwise excellent tutorial:
"Once you have dragged this on connect the IBOutlet in the Driller App Delegate object to the Navigation Controller by dragging from the app delegate whilst holding the control key".  
WTF.  

I'm sure it's easy when you know, but if I knew I wouldn't be here looking at a tutorial.  As soon as you don't get this bit the rest of the article is then off limits.

Having said that however I'd like to thank everyone that has bothered to write tutorials.  But please provide the source code....

Monday, 31 January 2011

Thursday, 6 January 2011

Change the Password Complexity of Windows Server 2008

For a default install of windows server 2008 the password has to be overly complex.  This is a right pain in the ass.  To switch this off (this won't work if it's part of a domain) use the following:

Start -> All Programs -> Administrative Tools -> Local Security Policy

Open Account Policy and change the field "Password must meet complexity requirements" to disabled.