Saturday, April 28, 2007

28/04/2007

I just wanted to recommend two movies that I've watched recently.

First up is Mr Bean's Holiday. If you've ever seen an episode of Mr Bean and liked it then you'll love the movie. He hasn't changed at all since Mr Bean finished in 1995 which is all down to Rowan Atkinson being such a great comedian and actor. I laughed for most of the movie which made it seem even shorter than the already short 85 minutes.

The second movie is The Guardian. It's about the US Coast Guard and it's pretty believing. There are times when you're shivering with them, and times when you're cheering them on. The ending was great, not expected, but it is hinted to at the beginning.

Friday, April 27, 2007

27/04/2007

It has been a while since I posted any healtheriser pictures (I don't think I've posted any of this new version!), so now is a good time to post some. I currently have adding weights and listing weights done and I'm happy with them so far, so now I can move on to doing the sizes (I just need to do the edit page and make sure that the weights delete).

Healtheriser - Add Weight
Healtheriser - Add Weight - Hosted on Zooomr

Healtheriser - List Weights
Healtheriser - List Weights - Hosted on Zooomr

Thursday, April 26, 2007

26/04/2007 - Building apache 2.2.4 and subversion 1.4.3 on Ubuntu

I've mentioned before that I compiled and installed Apache 2.2 and Subversion 1.4 on my Ubuntu machine due to the fact that the pre-built versions were pretty old. I recently upgrade the box to Ubuntu Fiesty (from Edgy) and that somehow installed Apache 2.2 and Subversion again (even though I had removed the subversion package before, and also removed the older Apache 2.0 package). That prompted me to remove them and to also update my own versions as I actually wanted to put Subversion in a different place to where I put it originally. While I was doing it I made a note of what I did so that I had instructions to follow if I need to do it again in the future (or just need to build a newer version).

If you follow the instructions then you will download Apache 2.2.4, Subversion 1.4.3, NEON 0.26.2, and also Berkeley DB 4.5.20 (as for some reason Subversion couldn't find the previously installed versions).

========================
= STEP 1 - DOWNLOADING =
========================

Download svn:

wget http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz

Download apache2 2.2.4:

wget http://apache.openmirrors.org/httpd/httpd-2.2.4.tar.gz

Download NEON:

wget http://www.webdav.org/neon/neon-0.26.2.tar.gz

Download Berkeley DB
wget http://download.oracle.com/berkeley-db/db-4.5.20.tar.gz

======================
= STEP 2 - COMPILING =
======================

Extract sources:

tar xf subversion-1.4.3.tar.gz
tar xf httpd-2.2.4.tar.gz
tar xf neon-0.26.2.tar.gz
tar xf db-4.5.20.tar.gz

Build and install Berkeley DB

cd db-4.5.20/build_unix
../dist/configure --prefix=$HOME/bin
make
make install
cd ../..

Build and install apr 1.2

cd httpd-2.2.4/srclib/apr
./configure --prefix=$HOME/bin
make
make install
cd ..

Build and install apr-util 1.2

cd apr-util
./configure --prefix=$HOME/bin --with-apr=$HOME/bin \
--with-berkeley-db=$HOME/bin
make
make install
cd ../../..

Build apache2

cd httpd-2.2.4
./configure --prefix=$HOME/bin/apache2 --with-apr=$HOME/bin \
--with-apr-util=$HOME/bin --enable-dav --enable-dav-lock \
--enable-proxy --enable-proxy-http --enable-rewrite \
--enable-ssl --enable-mods-shared=all
make
make install
cd ..

Build neon

cd neon-0.26.2
./configure --prefix=$HOME/bin --with-ssl=openssl
make
make install
cd ..

Build subversion

cd subversion-1.4.3
./configure --prefix=$HOME/bin --with-apxs=$HOME/bin/apache2/bin/apxs \
--with-neon=$HOME/bin --with-berkeley-db=$HOME/bin \
PYTHON=/usr/bin/python PERL=/usr/bin/perl
make
make install
cd ..

======================
= STEP 3 - AUTOSTART =
======================

Copy apachectl to /etc/init.d

sudo cp apachectl /etc/init.d/apache2ctl

Autostart apache2ctl

sudo update-rc.d apache2ctl defaults


I copied apachectl as apache2ctl as I'm used to typing that for Apache 2 when I also had Apache 1 on there. I just like having a seperating version number in the name.

Berkeley DB, the Apache 2 apr and apr-utils tools, NEON and Subversion are installed into the $HOME/bin prefix, but I put Apache 2 into the $HOME/bin/apache2 prefix so that it's seperate and easier to work with (it uses more folders than the normal that you find in a /bin directory). I also have Apache 2 build with all the modules built as shared and all enabled, plus also build the proxy modules and ssl support.

Friday, April 13, 2007

13/04/2007 - Friday

On my webserver I'm still using Ruby 1.8.4 as that is what Ubuntu has in their software repository, however it is quite old (December 2005). I wanted to put 1.8.6 on there as that's the latest and I prefer using newer versions of software, but I wanted to keep the existing one incase there were any problems, so I installed it into my home directory. Here are the steps I took to get it set up.

Apparently Ruby needs a supportive application called readline, so first we will do that.

wget ftp://ftp.gnu.org/gnu/readline/readline-5.2.tar.gz
tar zxf readline-5.2.tar.gz
cd readline-5.2
./configure --prefix=/home/spidah/bin
make
make install

Once that is complete you can grab and install ruby:
wget ftp://ftp.ruby-lang.org/pub/ruby/ruby-1.8.6.tar.gz
tar zxf ruby-1.8.6.tar.gz
cd ruby-1.8.6
./configure --prefix=/home/spidah/bin --enable-pthread --with-readline-dir=/home/spidah/bin
make
make install
make install-doc

You will need to make sure that the bin directory is in your path (mine turns out to be /home/spidah/bin/bin). To do this just edit your ~/.bash_profile file and add
PATH=~/bin/bin:"${PATH}"

to the bottom. Now you can either source your profile (source ~/.bash_profile) or close the console and open a new one. Once you have done that running
ruby -v

should return
ruby 1.8.6 (2007-03-13 patchlevel 0) [i686-linux]

or similar. You can also check that it's finding it in the correct location by running
which ruby

If you want OpenSSL support then you need to do a little bit extra. From within the ruby-1.8.6 directory do:
cd ext/openssl
ruby extconf.rb
touch *.o
make
make install

I don't know which .o file needed to be touch for make to build, but it was just easy to touch them all.

As I was changing to a newer Ruby version and also putting it in a different location, I thought it was easier to also install rubygems in the new location so that everything is in the same place. I'm not sure if it could be used from the original location, but I'm not really bothered.
wget http://rubyforge.org/frs/download.php/17190/rubygems-0.9.2.tgz
tar zxf rubygems-0.9.2.tgz
cd rubygems-0.9.2
ruby setup.rb

and that's it! I also wanted to copy all my gems over, so I did this:
cd /usr/lib/ruby/gems
cp -r 1.8 /home/spidah/bin/lib/ruby/gems

and waited for that to finish. Once it was done I could go into one of my rails apps and boot the mongrel server without any problems.

Saturday, April 07, 2007

06/04/2007 - Friday

I was ill today so I spent most of the day in bed sleeping. I obviously didn't get anything done today, especially on the Healtheriser, but I'm feeling better today so I should be able to get some done tonight.

I'm also going to a quick video of what is there so far. There's not much to really look at as you can only login and then go to a pretty empty dashboard page or edit your settings. I should be able to get weight entry added tonight (well, hopefully!) so that the dashboard will at least have something to display. The dashboard will also display all the latest entries (weights, sizes, meals and exercise) as well as your latest target weight. Doing stuff like adding new entries, editing old ones, deleting them, and viewing reports (graphs) will be done in the various sections themselves. This will probably make a bit more sense as things are implemented and I can show them off.

Friday, April 06, 2007

05/04/2007 - Thursday

Today I was planning to add weight entry to the healtheriser website. I didn't get that far as I stumbled across a few bugs in the login code that I thought I had fixed. This obviously took precedence over adding new features.

As the website uses OpenID to handle its logins you don't actually "signup" for an account (other than at the OpenID provider that you pick), so your account is created when you login for the first time. I'm also grabbing a few optional values from your OpenID login like your email, nickname, and gender so that these values can be stored for you from the beginning.

The first bugs turned up when I made a change to only allow certain values to be updated when submitted through a login. One of the values that I disallowed was the OpenID login url, which meant that the login code failed to save the account as it couldn't set the OpenID login url. I made a few changes to set this manually and that was sorted.

Then I was having problems getting the optional values that were being sent to me when logging in. I'm not sure if this was ever working right from the beginning, I never actually noticed, but I doubt it was. This was another quick and simple change once I actually worked out why the values weren't being saved (no error messages, just empty values being saved).

After I fixed those I decided to make the timezone list better as it wasn't actually working right when editing your account. I ripped out the city list one and just went with a simple "GMT-9", "GMT+4" list that holds all the timezones (all the ones that are displayed in the Windows XP timezone list). I also added in a daylight savings value as I had forgotten about that.

All in all a pretty decent day as I fixed the login bugs and got a working timezone list, although it would have been better if I had got the weight entry done. At least I'll be able to do that tomorrow!

Wednesday, April 04, 2007

04/04/2007 - Wednesday

This entry is about CSS menus, so skip this if it doesn't interest you!

On and off for a while now I've been trying to get a decent looking centred horizontal tab menu for my websites. I did create one that looked good, but it was limited to being on either the left or the right side of the page (or the container that it was in). I wanted one that was centred in the middle, but this just wasn't possible with the old CSS as the tabs were actually floated li elements inside a ul. I was also turning the hyperlinks into rounded top tabs using Nifty Corners Cube, so I couldn't just display: inline; the li's as the a's need to have display: block; for the corners to be properly rounded, and if you combine the two then it looks like a mess.

I tried one method of centring the tabs by having left: 50%; on the ul and then right: -50%; on the li's. This actually centred the menu, but unfortunately it caused the horizontal scrollbars to appear even though there was no content in the extra area (shifting the ul over by 50% was the cause, as it is a block element and the width stays the same). When I noticed the scrollbar I attempted to find a better solution as the scrollbar was annoying.

I tried switching it over to using a definition list to "define" the menu, but this suffered from the same problems and also introduced some new ones.

Eventually I found a real solution, one that I probably should have seen, but I didn't actually know that it existed. Instead of floating the li elements so that I can use display: block; on the a elements, I was able to display: inline; the li elements and then display: block-inline; the a elements. block-inline does exactly what it says: makes the element act like a block, but keeping it inline. With the li's inlined and the a's block-inlined, I was able to use text-align: center; on the ul element and everything is now in the middle!

I managed to find the display: block-inline; bit of css on a website, but I can't remember which it was now. Every other website that I found about centred css tab menus were using funky padding to make the a elements clickable like block elements.

Here's an example of the menu that I have:

<ul id="nav">
<li><a href="/dashboard" id="menu-dashboard">Dashboard</a></li>
<li><a href="/weights" id="menu-weights">Weights</a></li>
<li><a href="/sizes" id="menu-sizes">Sizes</a></li>
<li><a href="/logout" id="menu-logout">Logout</a></li>
</ul>

And the CSS that makes it into a centred menu:
ul#nav, ul#nav li {
list-style-type: none;
margin: 0;
padding: 0;
}

ul#nav {
font-size: 80%;
text-align: center;
}

ul#nav li {
display: inline;
margin-left: 3px;
text-align: center;
}

ul#nav li a {
background-color: #0e5fd6;
color: #fff;
display: inline-block;
padding: 5px 10px;
text-decoration: none;
width: 100px;
}

ul#nav li a:hover {
background: #cdffa1;
color: #006a35;
}

ul#nav li.activelink a, ul#nav li.activelink a:hover {
background: #fff;
color: #003;
}

This gives the tabs a blue background colour and white text, which changes to a light green background colour and a darker green text when the mouse hovers over the hyperlink.

I give all the a elements an id attribute so that I can switch the currently selected tab by outputting some extra css in the head of the html. This way I don't need to add an extra class attribute to the selected tab, which would make the menu creation more harder (I did it this way before though). The CSS for the selected tab would look something like this:
ul#nav li a#menu-dashboard, ul#nav li a#menu-dashboard:hover {
background: #fff;
color: #003;
}

which gives the selected tab a white background and a bluey black text on both the normal and hover states. Here's a picture of what the tabs look like (only showing the three states of the tabs, not an actual centred menu):



The Dashboard tab is the selected tab, Weights has the mouse over it (not visible in the picture though), and Sizes is a normal tab.

Monday, April 02, 2007

01/04/2007 - Sunday

Doctor Who started again on Saturday (as you probably know by now!) with a good episode. The new assistant seems alright, but I'm not sure if there is going to be family baggage like there was with Rose. Hopefully not, but it all depends on how well the family is written into the story.

I made the dalek cake on Saturday to celebrate the new series. It turned out better than I was expecting, although it was slightly misshapen (it leant backwards instead of being upright). I should have made the head section higher than the sloped front section as you really couldn't see where the head was supposed to start, but it still looks like a dalek though! Here's a photo of it:

Doctor Who Dalek Cake
Doctor Who Dalek Cake - Hosted on Zooomr

You can see the rest of the photo series here (from the setup to the finished cake). I didn't take any pictures while I was putting the sweets on though, so it suddenly jumps from a chocolate icing coated dalek to a finished dalek. The chocolate icing was pretty strong and eating it kinda made me feel sick after, but it tasted nice anyway.