A simple CPP program

Hello everyone. This semester I’ve been the learning CPP (C++ / CXX) programming language and I thought I’d write a simple program in order to help out some of my friends. This program has one class; person. This class contains two private variables called name and age, these have the associated accessors and mutators.

Lets start the program, first we need to include the iostream library, we will also include the string library. They handle the input and output and give us the ability to use strings respectively. I personally thing using strings is easier and neater than using char arrays. We also have to declare our namespace.
Continue reading “A simple CPP program”

Apache user support in Tiger

Last time we showed you how to install Apache 2.2 on OS X Tiger. This time we will show you how to add user directory support to it.

Assuming you installed Apache to /usr/local/apache2 then you need to look at a file called httpd-userdir.conf in /usr/local/apache2/conf/extra. This is the file that tells Apache where there user’s directory is and what directory inside it is the public_html one. Open this file up in a text editor of your choice. There are only two lines you need to edit.

UserDir public_html
<Directory "/home/*/public_html">

This is the default config for Apache but this is designed for linux systems. To make this work on OS X you need to change these lines to the below.

UserDir Sites
<Directory "/Users/*/Sites">

You will notice that public_html has been changed to Sites. If you look in your home directory this folder will be here. We also changed /home to /Users because this is what OS X uses for the user’s directories.

The last thing you need to do is to enable the user directory support in the main httpd.conf file. It will be in /usr/local/apache2/conf. Look for the below line and simply remove the # (hash) symbol from the beginning.

#Include conf/extra/httpd-userdir.conf

Now just save the file and go into system preferences, select sharing then stop and start “Personal Web Sharing”. Now enjoy your user directory support for Apache 2.2 in OS X Tiger.

All comments and questions are welcome. I’m always looking to improve my writing.

User directory suppport on OS X
User directory suppport on OS X

Apache 2.2 on OS X Tiger

System Preferences
System Preferences

This guide will show you how to install Apache 2.2 on Mac OS X Tiger (and probably Leopard) in a way that will allow you to turn the apache server on and off via System Preferences. Phpmac.com had a guide to do this for Apache 1.3 but I have been unable to get onto that website for a long while now so I decided to write my own guide. This guide assumes that you are installing from source, that you have the Xcode package installed and you know how to user the Terminal.

Getting the source
First thing you will need to do is to go to httpd.apache.org and download the latest version of Apache 2.2. I used version 2.2.8 but the latest is 2.2.9 at the time of writing this. You should see a link to the source on the front page.

Configure and Compiling
I choose to install apache to /usr/local/apache2 with modules enabled. Assuming that you have unpacked the version of Apache you have just downloaded you should open the Terminal and change into that location.
$ ./configure --prefix=/usr/local/apache2 \
--enable-module=most \
--enable-shared=max
$ make
$ sudo make install

These commands will configure the httpd package, compile and then install it. This is the easy part, the hard part is configuring Apache to run from system preferences.

httpd.conf
Now that Apache is installed we need to configure it. There are three things you will need to do to the config file which is located in /usr/local/apache2/conf/httpd.conf . The location will depends upon what you used for –prefix= .

You need to search for the user and group name in httpd.conf. The default user and group is “daemon” but OS X uses “www”. This is line 65 on my install. After you have changes the user and group from “daemon” to “www” it should look like this.

User www
Group www

At the bottom of this config file you need to add a line to tell Apache where to store it’s PID file. This is important as this tells OS X what program to terminate when you stop the Apache service.
PidFile /var/run/httpd.pid

System link
This is the last step to getting Apache 2.2 to work from system preferences but I have an important note. This moves the default Apache 1.3 binary and replaces it with a link to our Apache 2.2 install. I have found that when I install one of Apple’s security updates the link has been replaces with the original Apache 1.3 binary. Therefore you may have to repeat this step from time to time.

In there terminal there are three command you have to run. The first one moves us into the directory that we need to work in. The second commands moves the Apache 1.3 binary out of the way and the final command replaces it with a link to our Apache 2.2 install.

$ cd /usr/sbin
$ sudo mv -v apachectl apachectl-1.3
$ sudo ln -sv ../local/apache2/bin/apachectl .

The End
Now all you have to do is go to System Preferences, click on “Sharing” and then enable “Personal Web Sharing”. When you open up your browser and type in 127.0.0.1 or [::1] (IPv4 and IPv6 respectively) you should see “It Works!“.

PSU hell

Some time ago I was given a a PowerMac G4 Quicksilver that needed a new PSU. Instead of getting a new one I made an adapter that used the damaged original PSU to supply the 25v needed and a regular ATX PSU to do the rest of the work.

Now I have a newer PowerMac G4 Mirrored Drive Door that also has a damaged PSU. I plugged it in when I got home and the fuse blow up. I’m hoping that the fuse is the only thing that needs replacing as this computer is would be the best mac that I have.

It would also seem that either the PSU or logic board has gone in my PowerMac G4 Sawtooth so that would need fixing at some point or it might be given away for recycling. In other mac news I need a new logic board for my PowerBook G4 because my FW400 port has gone and that is needed for the scanner. Even if I can’t get the software to work it would be a good idea to fix the laptop before my warranty runs out. Also my PowerMac G3 B&W is running fine with no faults that I know of. Cos one of them has to be fine…

Cats v3

I have been working on a new website for my uncle and aunty. They breed cats and dogs so they use the website do display information about their animals and what kitties and pups they have for sale. Their current website was made in 2005 and the last back end update was in 2006. Since then I have learnt so much more about websites and my code has become much more refined. The new site that is still in development features a small amount of CSS3 and an easy to update layout with all the pages being stored in a sub directory. I am also working on a method to have the English and French site rolled into one where PHP works out if it should serve the end user English or French content.

Mac binary stripping guide

Hey all. Mac users will know that a lot of new apples come with both i383 and ppc executable. If you’d like to save space you can strip one of them from the program. Here is how I did it to Safari 3.1:

First you open up Terminal.app under Utilities in the Applications directory.

Last login: Sun Mar 23 22:04:19 on ttyp1
Welcome to Darwin!
$ cd /Applications/Safari.app/Contents/MacOS/
$ ls
Safari
$ file Safari
Safari: Mach-O universal binary with 2 architectures
Safari (for architecture i386): Mach-O executable i386
Safari (for architecture ppc): Mach-O executable ppc
$ lipo -remove i386 Safari -output Safari
$ file Safari
Safari: Mach-O universal binary with 1 architecture
Safari (for architecture ppc): Mach-O executable ppc

For Intel users:
$ lipo -remove ppc Safari -output Safari

Explained:
The first two commands move you into the Safari.app binary and show you the contents of the folder. The file command shows you that the binary is a fat binary, IE it contains two arches.

Now lipo is the key to all of this. This is a command line tool that creates or operates on a universal files.

The binary you want to edit is located in Contents/MacOS inside the .app file. It is normally the only file in there.

Notes:
Backup the .app file before you begin just incase you make a mistake.
In firefox it’s called firefox-bin.
Tab-complete is your friend Continue reading “Mac binary stripping guide”

Still some SPARC left

Last week I decided to start working on my Sunblade 100 that I got back in November. It has been sitting on my stack for about the last two months without even being turned on once. The main reason for this was the lack of networking and my knowledge of Sun’s Solaris OS. After hearing that some people had Ubuntu server running on these machines I decided to download and try it. I now have Ubuntu 7.10 installed with networking and a Linux environment that I’m used to. After disabling the built in speaker because it frustrated me to the point of smashing some keys off of my keyboard with it’s beeping when using the console. Now only thing that annoys me now is the loud hard drive but as I use it via SSH I don’t have to been in the same room as it.

Sun Blade 100

The Blacklist

In case you’re not familiar with the term “blacklist” I will elaborate. There are three colours representing different kind of list; White, Black and Red. White is a free pass with no questions asked, Black doesn’t let you in the club and Red puts you in a headlock until the cops arrive and take you away.

My blacklist is very small at the moment only consisting of one email address and one IP address. I have some anti-spam measures in place but they don’t stop everyone getting through so I look for a patten from the IP and email address marked as spam. Any that turn up a lot go on the blacklist and are never heard from again….hopefully.

Cosmo version 9 and Server

I managed to get Cosmo version 9 online at midnight but there was a problem with IE6. Thankfully it was only IE6 and it was fixed within half an hour after I woken up and had breakfast. The site is controlled by one single PHP page that calls in the content and updates the blog each month automatically. It has in place functions that make the site more secure such as checking that the page trying to be loaded is a real page and not an off site link or an incorrect date.

The server that hosts all my websites is now running my own home brewed Linux OS called Blue Square Linux. The server has also had an extra 500GB fitted via a RAID SATA controller. It was a little bit of a problem at first because the kernel was custom compiled a long time ago without support for SATA.

Cosmo v9 – www.cosmo1847.co.uk
Blue Square Linux – www.bluesquarelinux.co.uk

RAID and extra storage

Something I have been thinking of doing for a while was to upgrade the server’s hard drive storage. At the moment it has a 200GB hard drive that is about 80% full. As I have a linux shop and the server is sometimes used as a backup for other computers on the network I have decided to by a 500GB hard drive. To make the new upgrades to the server future proof so that when the time comes to upgrade to a new server I will be able to use some of the parts from the old, I have bought a SATA hard drive. Due to the server not having any SATA ports on the motherboard, or for that matter most other I/O ports, I have bought an Adaptec SATA RAID card to go in the server. This will allow me to add 2 SATA hard drives to the server and these should preform just as fast, if not faster than the current IDE hard drive.

This will mean that at some point, probably next week, the server will be down while I upgrade the kernel and install the new SATA controller and hard drive.