Fruits of my Labour

October 30, 2008

PHP has been an annoyance to work with, although I somehow managed to write something vaguely (useful?) with it – a ‘predictions league’ thing commissioned by a friend (whose site I somehow got roped into hosting). I actually managed to write this in a few hours as a first PHP/MySQL project which in my opinion is pretty fast considering I had to learn my way round PHPMyAdmin for a good half hour setting up the DB then start learning PHP starting from the MySQL end, learning the hard way that die(…) literally means the script, well, dies.

The requirements for the program was that people would log in / register and be able to predict scores on upcoming matches. Their predictions end up in a database, and when a match finishes, admin enters the results into another table in the database, at which point a script runs to compare each person’s predictions against the real result. A formula works out the number of points they get based on similarity to the actual score, and their points accumulate over the whole season.

Apart from some teething problems it seems to run OK. I only managed to work out cookies after it was launched, and a logout link was created a day after that. But overall, I’d consider it a fairly successful first project in PHP. The URL to follow if you’d like to make a prediction is http://gedanken.we.bs/wordpress/predictions/

Being not very (or even remotely) interested in Football probably didn’t help, but the writing of this did alert me to some nice things about web programming: a lot of different languages are at your disposal all at once. Javascript if commonly used in conjunction with PHP to optimise user interfaces (UIs) and java applets with parameters, generated using PHP, passed are the best way I am cognisant of to display anything dynamic – no I haven’t yet delved into Flash. Apart from these, it is possible to write some scripts in Perl, although it has to be admitted that it sucks at life. Odd that that page is a CGI script… Another nice thing is the fact that server-side scripting can be audaciously typed straight into a page, making security so much less of a headache. Theoretically one can write passwords in plaintext in the script and have it still fairly secure – *theoretically* – Although getting cavalier about security tends not to be a good idea.

By far the worst part of my experience coding this was the discovery that PSPad, a program I’ve had on my machine all this time but haven’t realised its potential PHP-wise, is an awesome editor for PHP. Oh well, bye then Notepad.


<?php Mein Kampf ?>

October 22, 2008

Don’t worry, I haven’t turned into Hitler. But I’ve been struggling for some time now to learn new programming languages and my most recent struggle is PHP. I’ve finally taken it upon myself to learn it, one of the most important languages to know since the internet practically runs off it, and I had to be persuaded by, of all people (as always with these matters) someone who has no idea about programming but has an idea for a program he wants written; for some reason I’ve ended up as the techie authority in my year even though I’m relatively unskilled so I was the first, and only, unfortunate soul to be roped into it. I’m pretty pleased though in the end that I learnt PHP – it’s probably going to end up a valuable life skill; meanwhile here’s what I think of it…

The Bad

1. Variables are disgusting – the concept of variable types is transparently non-existent which should send shivers up the spine of any programmer.

2. $. The entirely of PHP variables revolves around the Dollar Sign, which is actually rather nice (easy to see what’s going on) but it does mean that I’m constantly hitting shift+$ every time I want a variable, and I invariably end up hitting shift+% or some other key nearby.

The Good

1. String concatenation looks very neat, like Perl: “string1″ . “string2″ – it just makes code look so much less messy (and no need to press shift)

2. The script is run server-side so security is good and nobody can steal your code (among loads of other useful things about server-side scripting)

3. Even with server-side scripting, PHP can be inserted straight into web pages – just go

4. It’s a curly bracketed language, like C#, Java and C++, rather than Python (yuck) – personal pet preference / hate respectively

5. It’s a Recursive Initialism (PHP: Hypertext Preprocessor)!

Overall I find it a fiddly language to work in, and the two ‘bads’ listed here are almost enough to turn me off forever, and no doubt I will find more problems as I continue my quest to master PHP. Don’t laugh, I will do it … some day.


My PC Collection: in pictures

October 14, 2008

I begin to wonder whether I have too many computers at home. At the last count, my family uses four computers on a regular basis, which of course begs the question of exactly what the other 6.5 are doing… I’ve decided to make an attempt to justify to myself my possession of the 10.5 computers living (in some cases not) alongside me, a technophilic teenager.

First of all, the family computer – 5-6 years old, Windows XP. It’s used on a daily basis by my parents, and occasionally by myself. It seems to have become the central computer since all our DAS is connected to it, and it’s the one physically closest to the router (interestingly it’s also the only computer which is linked to the main router via a single cable – just about everything else is connected through an ethernet switch).

My own desktop is probably about 4 years old now and still serving me pretty well – when we bought it, a config with 1.5GB RAM and an Intel Pentium D 2.8GHz processor was pretty impressive. I use it for just about all my Windows software and it’s rigorously maintained, using the likes of TuneUp Utilities and CCleaner. It’s also running XP, arguably the most compatible and programmed-for OS around. I’ve optimised it quite heavily for performance – relatively minimal yet pleasing visual effects and faster, more efficient free software alternatives to default crapware such as foobar, Pidgin, the Mozilla suite and AVG Free.

The antithesis of my desktop, so to speak, is my Laptop: if my desktop is D, my laptop is D’. Optimisation goes straight out the window immediately as it was shipped with Vista and I was too lazy to install something decent, and besides it’s a Toshiba Satellite A300 with 3GB RAM and a speedy Intel Core 2 Duo T8100 processor so it can theoretically cope with pretty much anything I might care to throw at it – including Vista, excluding games. I use it, obviously, for all mobile computing needs, and also as a ‘programming computer’ – it’s the only machine at home with C#.NET installed.

The last of the regularly used computers is my Debian server – the white Compaq. An ancient machine, it boasts about 500MB RAM and a processor whose clock speed is probably best measured in tens of MHz, but it does the job of hosting a WordPress blog with the help of the wonderful stress-reliever XAMPP.

Next to it is the Dell Optiplex workstation (WinXP), which is used for road testing software and port scanning other computers on my network using Nessus in search of security holes.

Compaq: This one runs Windows 2K and is the same model as the Debian server. I tend to use it occasionally to test software in a Win2K environment and experiment with LiveCDs.

Huge server: A wonderful piece of history, definitely worth the ~0.25 square metre of floorspace it occupies. It unfortunately has no HDD and seems to use nothing but SCSI and tape drives (oh the days of tape drives…), neither of which I possess, so only boots off liveCDs – Sabayon Mini and Knoppix are therefore its OSs of choice.

Our old computer was a Time, and was built for Windows 95. That pretty much says it all – the wires protruding from its rear end are testimony to its current function: its PSU provides DC for my electronics projects.

Toshiba Tecras used to look like this…

…and HPs used to look like this. The HP is the only computer downstairs so is used as an excuse for a home entertainment system – it just about managed to install XP so can’t be all *that* bad.

And finally, the half computer: the picture really says it all. I think it was made by Time.

You may now be wondering how rich I must be to own so many computers. Allow me to surprise you – we only spent money on four of the above: my desktop, the family computer, my laptop and the old Time computer (the PSU one). Both Compaqs (including my server) and the old Dell were given to me by the school as old machines when they replaced the computers, my dad’s company also threw out some machines: the huge server and the HP, and my friend also contributed 1.5 computers to my collection – the Tecra and the, erm, box of components.


Big site on my server

September 28, 2008

Now my über-powerful </sarcasm> Compaq machine is running Debian, a proper server distro of Linux. It’s very efficient and much easier to use as a server than Ubuntu, especially when combined with my new-found favourite server software, XAMPP, which sorts out all the apache / SQL / PHP headache for me, without even the need to install: the simple ‘tar xvfz’ command and the 5 minutes of reading a magazine as it ran was all it took, and was far less hassle than the hours of waiting for apache to compile and install and the head-bashing as mod_ssl refused *yet again* to work alongside apache.

Now that my Compaq has all the functionality of a proper server, I’m venturing into scripting and application territory and have taken the plunge to install WordPress. The site I’ll be hosting (temporarily at least) is my friends’ one: The Beautiful Game. The URL of my wordpress installation is: http://gedanken.we.bs/wordpress/.

The blog (originally here) gets several hundred hits per day and has over 30 writers. It is jointly managed by four of my peers, and in essence, is pretty big. The reason for my hosting it is to provide better functionality from an admin point of view, and also the possibility of displaying Google ads as a source of revenue.

The site isn’t yet finished as yet – there’s lots of work to be done on design, and the import was a bit dodgy. But once everything is fixed, this little lump of whirring metal sitting next to me will be spitting HTML into the Interweb like a real server. Watch this space…


Mirror Apache Server gets domain

August 26, 2008

As you may remember, I set up a web server under my desk to mirror my site. I’ve now decided to give it a free domain name: http://gedanken.we.bs.

I’m currently trying out a cgi guestbook script and may want to make it a permanent feature. Since ifastnet probably won’t let me do anything interesting like run cgi scripts, I may end up hosting my site myself entirely on the Apache server under my desk.


Old computer becomes Apache server

August 15, 2008

ifastnet has been a fairly poor host. They ‘upgraded’ my server without telling me which for some reason took over 14 hours, and my site is frequently down for no apparent reason and with no warning. I guess with them you really get what you pay for: in my case, nothing; I’m using their free hosting service. So I decided to set up an old Compaq computer to run as a server.

It was originally running Mandriva Linux which was hardly ideal since I was for some reason not able to run apt-get… So I installed Ubuntu 8.04.1 Server on it and apt-get installed Apache. It’s now mirroring my site at http://82.44.63.76:100/ and running a tor relay at the same time. A bad idea on a 4Mb connection perhaps, I’ll just have to wait and see…

View full story and pics here