Creating a GUI Application Using Glade and Ruby

Creating GTK based applications using Glade and Ruby is very easy indeed. Firstly, get yourself hold of a copy of Glade from somewhere, I used aptitude on my Ubuntu 7.04 desktop:

sudo aptitude install glade

I used aptitude because it gets the recommended files as well as the bare program. Fire Glade up and you should be greeted by 3 windows – one called the “palette” which contains many of the widgets which we will be using to put into the application, the “Properties” window which is where we handle labels and signals and the project manager. Read more »

Unleash the Inner Nerd

Well, I admit to the world – I AM A NERD; I love learning, the thought of learning something interesting really excites me and I love it. I love sitting around on my computer discussing nerdy stuff with my fellow nerds online on IRC, I love the stuff and the fact is that most of the time that I’m sitting around talking to them I’m checking the news or looking at some weird sciency or computerty thing. The one thing that I think really makes me nerdy is that I hate dumb and plastic people – I only like people who are nice to me or clever or both. I am a nerd. I always get high marks in every test that I do even if I don’t revise and it’s great! The fact is that I don’t want to be thin, attractive or rich – all I want is a few good friends, good food and knowledge.

The one thing that I don’t like about it though is how quick everyone is to put you down about it; get a question wrong “haha, Rob got it wrong”, someone beats you in a test (even if you’re shit at the subject) “haha, YES! I beat ROB! YES! HAHA!”. The sad fact is that these people want us to be dumb as hell and they don’t understand how we can enjoy the stuff that we do. A plastic came up to me yesterday in Physics and asked me for an answer to a question, I naturally told her where to get off and told her to go and learn something different to what she reads in exams – she replied with “at least I have a life”. The outstand fact is that I don’t want to have a life like hers, mines not bad.

Seaweed – The fuel of our future

Well, I was going to write a boring thing about Wikipedia’s 11 meals of the day, but I thought of something much better! Seaweed! This brilliant and ingenious idea was developed as an argument in how we could help stem CO2 emmisions. The idea goes as follows:

  1. Make some kind of protected bed of them underneath the water (not too deep) and plant it – so that we can mass manufacture it easily.
  2. When the seaweed is ready, harvest! (no we’re not going to eat it). Seeing as how we planted this seaweed in protected beds, raise them to the surface and harvest it (like a real farm! just out to sea).
  3. Take back to land
  4. Distill the oil out of the seaweed (you know, lower it’s boiling point by using water or something)
  5. Yes, you have your oil now!

Stop importing oil now and grow your own! It’s carbon neutral (yes, it gives off as much as it takes in from the environment), It helps de-acidify the seas – takes excess CO2 out of them meaning more fragile life can continue living! and lets face it, it’s cool and could work out to be cheaper for us than that middle-eastern oil we import.

Go green! Go seaweed!

I’m a Mac, I’m a Windows and We’re Linux

Well, seeing the new Mitchell and Webb “I’m a Mac, I’m a PC” adverts I thought that I’d have a go myself.

Mac: I’m a Mac

Windows: I’m a Windows

Linux: And We’re Linux!

Mac: I’m a bit tubby around the waist but I can get away with it because all of the machines I run on are expensive and have some muscle behind them.

Windows: I’m very fat; I can’t run, I sometimes even find it hard to walk. I’m designed to run on all kinds of machines, but I just can’t do too much. When I get a cold virus I’m really bad, my immune system just can’t cope.

Linux: We’re all kinds of shapes and sizes. You’ll find the right one of us for you and your machine. Make it as fast as lightening or fully featured; just pick the one looks the best to you.

Well don’t blame me that it turned out crap!

Simple XML in PHP Tutorial

Simple XML Parsing in PHP

The Boring Introduction
Parsing XML in PHP can be really confusing at times; but what about if we only want to do something really simple? SIMPLE XML to the RESCUE!!!

Simple XML, as it’s name surgests is a really easy way to access XML elements through PHP.

How does it work?
Well, first we start the PHP document…
<?php

Now we create the instance and assign it to a variable…
$xml = new SimpleXMLElement(“<?xml version=’1.0′…. blah blah blah”);

That can be really usefull if we want to write the XML inside the PHP document – but what if we don’t?
$xml = new simplexml_load_file(“myfile.xml”);

Great, now we’ve opened up a nice xml file and now we want to suck it dry! Firstly we need to know what the XML file contains. :/
<?xml version=”1.0″?>
<street>
<house>
<bedrooms>3</bedrooms>
<toilets status=”true”>365</toilets>
<metresofcable>2</metresofcable>
</house>
<house>
<bedrooms>4</bedrooms>
<toilets status=”false”>1</toilets>
<metresofcable>45</metresofcable>
</house>
</street>

Now that we know what out XML file looks like, we can start to parse it.

I want to find out how many toilets the first house has and print it out:
echo $xml->house[0]->toilets;

This would print out the number “365″. That was really simple wasn’t it? And equally if I wanted to print out the number of toilets in the second house I would write:
echo $xml->house[1]->toilets;

Explanation:
$xml is the variable to which we assigned the XML parser class so we access all the information through this.

$xml->house[0]
You will notice that the first tag in the xml document is “<street>” not “<houses>”. This is because the PHP XML parser skips the first tag in the XML document.

$xml->house[0]->toilets
This is pretty self explanitory. The tag “<toilets>” is inside the “<house>” tag and so we access the toilets tag through the house one.

As you will have noticed, we do not use quotation marks to encase the tag names. This is the standard way in which it is done.

What about if we want to print out all of the number of toilets in each of the houses in the street?
We use the foreach() function. Here is an example of it in use:

foreach($xml->house as $house){
echo $house->toilets.”<br />”;
}

This is quite simple. In the foreach function we assign the marker of each house to the $house variable. Inside the statement we can access $xml->house now as $house; so we can access the attributes as $house->toilets.

So, now we can output all of the information at once!
foreach($xml->house as $house){
echo “This house has “.$house->toilets.” toilets, “.$house->bedrooms”. bedrooms and “.$house->metresofcable.” metres of cable.<br />”;
}

Using Attributes
These are easy too….
foreach($xml->house as $house){
switch((string) $house->toilets['status']) {
case ‘true’:
echo “This house has “.$house->toilets.” toilet(s)<br />”;
break;
case ‘false’:
echo “This house does not have “.$house->toilets.” toilet(s)<br />”;
break;
}
}

For the attributes of the object e.g. the status value in “status=’true’” we simply select the tag, in this case “$house->toilet” and then use it as an array to select the attribute: “$house->toilet['status']“

Extra Information

When tags start to come up with names like “string” and “array” which are variables in PHP we still need to access them. This can be done with this:

echo $xml->{“array”}->house->{“string”};

The {“”} lets the simple xml function regard it as plain text and simplifies the matter.

Free TV!

I was surfing the web the other day and came across this excellent website with links to loads of free TV stuff online!

FreeTVLinks.Net :: TV Shows

And another good link that I came across when scouring the spam in my Inbox. Easy to use online payment via SMS for your website:

OneBip – Everybody can pay

Happy Surfing!

Pinnacle PCTV Hybrid Pro – Ubuntu Edgy 6.10 installation

A rough guide to installing the Pinnacle PCTV Hybrid Pro on Ubuntu Edgy 6.10. I’m not going to beat around the bush with this – I’m just going to tell you how I did it. This tutorial will probably help install other tv cards based on the em28xx chipset but I cannot be sure.

1. Now open a terminal (Application->Accessories->Termial in Ubuntu).

2. I hate all this messing around with sudo at the front of every command put yourself into root with:
sudo su

3. Now you need to install some stuff first so do this:
apt-get install mercurial linux-headers-$(uname -r) gcc g++ make xawtv kaffeine dialog

4. Change Directory by executing this command:
cd /lib/firmware
5. Download the firmware for this specific product:
wget http://konstantin.filtschew.de/v4l-firmware/firmware_v3.tgz
6. Extract it here:
tar xvzf firmware_v3.tgz

5. Change Directory again:
cd /usr/src/
6. This downloads the necissary V4L drivers:
hg clone http://mcentral.de/hg/~mrec/v4l-dvb-experimental
7. Change Directory:
cd v4l-dvb-experimental/

8. This one takes some time, it compiles the drivers – I think it took me about an hour on my slow laptop:
make
9. And then:
make install

The drivers are now installed but we need to reboot

10. Make sure you bookmark this page so that you can return to after you restart.

– reboot now –

11. Open a terminal and get into root again:
sudo su

12. Type these 3 lines into the terminal one by one; if any error occurs then something has gone wrong and I can’t help you.
modprobe em28xx
modprobe em28xx-audio
modprobe em2880-dvb

13. If all went well type:
gedit /etc/init.d/bootmisc.sh

14. Copy and paste these lines into the bottom of the file and then save it.
modprobe em28xx
modprobe em28xx-audio
modprobe em2880-dvb

Everything should now be running smoothly.

15. Open Kaffeine from Applications->Sound & Video->Kaffeine

Digital TV

A new “Digital TV” icon should have appeared – Click that and being the wonders of digital TV. Or if you want to watch Analouge TV hang on a second.

Analogue TV

To view analogue TV in Ubuntu, open XawTV (Applications->Sound & Video->XawTV)

Video: To change channels in XawTV use the up and down arrow keys on your keyboard until you come to something that looks somewhat like an image. There are other applications for this kind of thing but I won’t go through them with you – instead I shall palm you off onto http://www.linuxtv.org

Audio: Audio is a strange affair with this.

  1. 1. Open XawTV and make sure that the region is set correctly. For the UK use PAL-I from the selection; this makes sure that the audio will work properly.
  2. 2. Find a channel in XawTV (In the UK I have found that the analogue channels are in the range of channels 20 to 40 in XawTV).
  3. 3. Download this file and save it in a nice place so that you will remember it.
  4. 4. Open a Terminal.
  5. 5. Run this command: sudo su
  6. 6. Now, Change Directory to where you saved the earlier downloaded file. (e.g. cd /home/rob/Downloads or wherever you stored the file)
  7. 7. Run this command: chmod +x v4l-scripts-usbaudio_setup.sh
  8. 8. And finally run this command: ./v4l-scripts-usbaudio_setup.sh

     

WARNING: You will have to do steps 5, 6 and 8 each time you chose to watch analogue TV with sound.

Usefull Links – Stuff that helped me install it

edit 12th May 2007: some updates have been made including the repository change

Nandos

I take time out of my busy friday evening to say that Nandos is great! It serves really good hot and spicy chicken (or lemon and herb for the less adventurous). The atmosphere in the place is really relaxing too and its an all round great experience!

GO TO NANDOS FOR GREAT CHICKEN!

REVISION!!!

Yes, i know that its the totaly wrong time of the year to be revising, but i have GCSE Biology and Chemistry modules in November :’(. Our school has no idea what they’re like so is making us revise loads!

I’m also working on a new UI for SNOSS, i think it’ll be cool: DHTML + Cool graphics.

Chemistry and Biology here i come!

powered by performancing firefox

powered by performancing firefox

Sexual Favors on the Job

I thought that this was a great post:

Ok, now I have your attention. Recently on Craigslist someone posted an ad advertising that they will fix computers in exchange for sexual favors. Here is a screenshot of the Craigslist ad.

read more | digg story