ADAM'S WEB PRESENCE

23 September 2006

Cheap Batteries

Filed under: Bizarre Stuff — adam @ 12:54 am

Really cheap batteriesI bought some AAA batteries, $2 for a pack of 24. At that price you just know they have to suck.

Check out the colour scheme. We wouldn’t be trying to imitate a well known battery brand here by any chance ?

And look! they even have a fake battery tester strip. It’s just printed on the side.

And no, they did not last very long. I don’t think they are even alkalines.


17 September 2006

Dumb Remote Controls part 2

Filed under: Bizarre Stuff, General — adam @ 1:39 pm

Quick, the boss is coming!If that last remote control wasn’t stupid enough for you, look at this one. It has a Boss Key !


12 September 2006

CRON got me a beauty this week

Filed under: Nerd Notes — adam @ 12:17 pm

Why don’t I have a simpler hobby like gardening or matchbook collecting? Computers can drive me insane some days.

I have this script on my Debian server which is supposed to run every day but every morning when I check my logs, I find it has failed to run. The script works fine when I run it manually. I have put it in the /etc/cron.daily directory with the correct permissions, but CRON just ignores it – what is going on ?

I was determined to find the problem today. And I did. You see CRON uses another program called run-parts to handle the process of scanning the directory and running each file contained within. After reading up a little and doing some tests, I found that run-parts will ignore any file which has a dot in it’s name. Coming from a DOS/Windows background, naturally I had named my file adam-daily.sh because it is a shell script. Removing the “.sh” fixed the problem.

This is the price I pay for not sufficiently dedicating my life to the UNIX way.


5 September 2006

Enumerating Network Interfaces on Linux

Filed under: Nerd Notes — adam @ 1:34 pm

Here is some C code which will list the network interfaces on your Linux box and also the IP and MAC address associated with each interface. I put it together because I couldn’t find an example on the net of exactly what I wanted to do – so now here it is.

/*
  Example code to obtain IP and MAC for all available interfaces on Linux.
  by Adam Pierce <adam@doctort.org>

http://www.doctort.org/adam/

*/

#include <sys/ioctl.h>
#include <net/if.h>
#include <netinet/in.h>
#include <stdio.h>
#include <arpa/inet.h>

int main(void)
{
	char          buf[1024];
	struct ifconf ifc;
	struct ifreq *ifr;
	int           sck;
	int           nInterfaces;
	int           i;

/* Get a socket handle. */
	sck = socket(AF_INET, SOCK_DGRAM, 0);
	if(sck < 0)
	{
		perror("socket");
		return 1;
	}

/* Query available interfaces. */
	ifc.ifc_len = sizeof(buf);
	ifc.ifc_buf = buf;
	if(ioctl(sck, SIOCGIFCONF, &ifc) < 0)
	{
		perror("ioctl(SIOCGIFCONF)");
		return 1;
	}

/* Iterate through the list of interfaces. */
	ifr         = ifc.ifc_req;
	nInterfaces = ifc.ifc_len / sizeof(struct ifreq);
	for(i = 0; i < nInterfaces; i++)
	{
		struct ifreq *item = &ifr[i];

	/* Show the device name and IP address */
		printf("%s: IP %s",
		       item->ifr_name,
		       inet_ntoa(((struct sockaddr_in *)&item->ifr_addr)->sin_addr));

	/* Get the MAC address */
		if(ioctl(sck, SIOCGIFHWADDR, item) < 0)
		{
			perror("ioctl(SIOCGIFHWADDR)");
			return 1;
		}

	/* Get the broadcast address (added by Eric) */
		if(ioctl(sck, SIOCGIFBRDADDR, item) >= 0)
			printf(", BROADCAST %s", inet_ntoa(((struct sockaddr_in *)&item->ifr_broadaddr)->sin_addr));
		printf("\n");
	}

        return 0;
}

UPDATE: Adam Risi has been kind enough to publish an updated version to handle IPv6 on his website.

UPDATE: Eric supplied some extra code to also list the broadcast address for each interface


3 September 2006

Yes you can fit a full-size ATX motherboard into an AT case

Filed under: Homemade Creations — adam @ 4:40 pm

Jigsaw Weilding ManiacI guess normal people don’t spend their time doing this kind of thing but you know I had an old desktop case which was for an AT motherboard and I wanted to make myself a new web server and a tower case would be too big to fit into my server cupboard. So the old desktop case went under the knife – a power jigsaw that is, with a metal cutting blade.


The ATX connectorsAfter butchering the back panel, I neatened it up a bit with a hand-held hacksaw blade and a metal file. After that, I vacuumed the case out thoroughly to make sure there were no metal shavings inside.

As you can see, the bigger motherboard fits now. Removing a large chunk of the back panel allows the connectors for the keyboard and other ports to be accessible.


Everthing fits. Phew!Unfortunately, the CPU cooler sticks up too high so I could not fit in the PSU. However, I am a computer nerd and always have plenty of odd spare parts lying about such as a Micro-ATX PSU which fitted in just nicely after I drilled a few new mounting holes.

Once I put in the hard drive, CD-ROM, PCI cards and everything, the box is getting rather full but it does all fit.


My server roomAnd here it is in my server room – uh, I mean server cupboard. It’s running a PIII 667 overclocked to 750MHz with 384MB of RAM and a 250GB hard disk. Debian Linux of course (if you have been reading my blog, you must realise by now its my favourite OS). And it is all working great. After all, it has just served this web page to you!

Now all I need to do is enter the new machine into the Linux Counter.


2 September 2006

Subversion recovery

Filed under: Nerd Notes — adam @ 11:38 pm

I’ve been using Subversion for a while now to manage the source code for my hobby projects. I like it, it is easier to use than CVS and it doesn’t trash your files like Visual Source Safe does. Also there is the very excellent Tortoise GUI to make it even nicer.

However, Subversion has one REALLY annoying problem. About once a month it just freezes up solid and refuses to commit any files. It has never lost any of my data but I think I’ll stick to CVS for my professional work.

Anyway before this turns into a rant, the purpose of this post is to write down the magical incantations to un-wedge Subversion so that next time it freezes I can just read my own blog rather than spending half an hour trying to figure it all out again

First shut down the web server

# /etc/init.d/apache2 stop

Then run either the Berkely recovery utility or the Subversion recovery utility depending on which component has frozen – or just run both. Here’s the commandline for Subversion recovery:

# svnadmin recover /home/subversion/<project-name>

and here’s the Berkely recovery commandline:

# db4.2_recover -c -v -h /home/subversion/<project-name>/db

Then adjust the permissions on all the files so that the web server can read and write them

# cd /home/subversion/<project-name>

# chown -R www-data.www-data *

And finally we can fire up the web server again.

# /etc/init.d/apache2 start

PS. I’m running Debian Etch Beta and using Apache2 as my web server. This procedure may be slightly different on other configurations. YMMV.


MultiComp 1.5 Released

Filed under: Products — adam @ 8:53 pm

I’ve just released an update to my freeware data verification utility. This is a bugfix release, I found it would not give an accurate comparison if you ran it on any files larger than 2 gig. But now it is fixed.

Click here to go to the MultiComp page where you can download it for free.


Powered by WordPress