O2 PAYG Mobile Broadband

Having Googled unsuccessfully for the settings needed to use wvdial or a Solwise 3G router with O2 Pay-As-You-Go Mobile Broadband, I thought I would share the correct settings here. In order to connect you need the following details:

APN: m-bb.o2.co.uk
Username: o2bb
Password: password

The URL to visit to buy credit is:

https://mobilebroadbandaccess.o2.co.uk/

Happy surfing! :-)

{lang: 'en-GB'}

Better image quality from UMTS using Privoxy

If you are a mobile broadband user you will notice that your image quality is degraded by UMTS. Firefox can overcome this problem by virtue of the Modify Headers plugin. Essentially you need to add two headers to your outgoing request:

Pragma: no-cache

Cache-Control: no-cache

The same effect can be achieved for Internet Explorer and other Windows applications by running Privoxy and adding the following rule to the actions file:

{+add-header{Pragma: no-cache}\
+add-header{Cache-Control: no-cache}}
/

More details here: http://sourceforge.net/tracker/index.php?func=detail&aid=2913535&group_id=11118&atid=211118

{lang: 'en-GB'}

One free week of StarTiger

Coupon Code: FREE-5DDC-A48A

Just follow these steps:

  • Go to http://www.startiger.com
  • Click on “Join Now”
  • Enter the coupon code in the coupon code field
  • Enter your valid e-mail address and click on “Next”
  • Select your username and password on the following page and click on “Next”.
  • Enjoy your free week at StarTiger!
{lang: 'en-GB'}

Tesco Internet Phone + Linksys PAP2

So the good news is that Tesco Internet Phone have started letting people use SIP to access their service. This means that I can now set up the second line on my PAP2 to connect to it. All well and good until I tried to access my voicemail by dialling *123.

It turns out the dial plan on the PAP2 is set to only allow 2 digit numbers following the * symbol (mostly used as command codes to the PAP2 itself).

The default dial plan reads:

  (*xx|[3469]11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.)

but to allow calling *123 it needs to be adjusted to:

  (*xxx|[123469]11|0|00|[2-9]xxxxxx|1xxx[2-9]xxxxxxS0|xxxxxxxxxxxx.)

After contacting their customer services it also turns out that the current version of the onscreen TIP will not work properly with Windows Vista. In order to retrieve your voicemail when running on Vista you need an updated version, available here:

http://www.tescointernetphone.com/images/tescoip-3.3.2.8126-live-setup.exe

{lang: 'en-GB'}

Wooden Puzzle Box

A couple of days ago I found a Wooden Puzzle Box on Firebox.com. It works on the same principle as a plastic version bought for me a few years back by a relative (I think it was bought from a Hawkins Bazaar). When you don’t know the answer it is fiendishly difficult to open.

Wooden Puzzle Box

{lang: 'en-GB'}

GameCube Animal Crossing Floating Presents

At long last I have figured out how to get floating presents down from the sky in Animal Crossing on the GameCube. In the later version, “Animal Crossing: Wild World” for the DS, you can use a slingshot to pop the balloons the presents are attached to. Alas, in the original version on the cube there is no slingshot. The answer is infuriatingly simple (and logical if you think about it)… all you do is follow the present until it floats directly over a tree, and then shake the tree. Voila!

{lang: 'en-GB'}

Shopping Cart for CodeIgniter

Despite much Googling, I haven’t been able to find a ready made shopping cart for the CodeIgniter PHP framework. Unfortunately one of my current projects requires such a thing, so I decided to roll my own. Starting from the code here: http://v3.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart, I made a few changes to fit the CodeIgniter way of doing things.

The revised version looks like this:

<?php
// Based on http://v3.thewatchmakerproject.com/journal/276/building-a-simple-php-shopping-cart
class Cart extends Controller {
    function Cart() {
        parent::Controller();
        $this->load->library('session');
        $this->load->helper('url');
    }
    function index() {
        $cart = $this->session->userdata('cart');
        if ($cart) {
            $items = explode(',', $cart);
            $contents = array();
            foreach ($items as $item) {
                $contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;
            }
        }
        if ($contents) {
            $id_list = '';
            foreach (array_keys($contents) as $val)
                $id_list .=  $this->db->escape($val) . ',';
            $id_list = substr($id_list, 0, len($id_list) - 1);
            $query_string = "SELECT * FROM stock_table WHERE id IN(" . $id_list . ")";
            $query = $this->db->query($query_string);
            if ($query->num_rows() > 0) {
                $basket = array();
                foreach ($query->result() as $row) {
                    $basket[] = array('id' => $row->id, 'caption' => $row->caption, 'price' => $row->price,
                        'qty' => $contents[$row->id], 'total' => $contents[$row->id] * $row->price);
                }
            }
        }
        $data = array();
        if ($basket) {
            $data['basket'] = $basket;
            $grand_total = 0;
            foreach ($basket as $item)
                $grand_total += $item[total];
            $data['grand_total'] = sprintf("%01.2f", $grand_total);
        }
        else
            $data['grand_total'] = sprintf("%01.2f", 0);
        $data['page'] = 'cart_view';
        $data['title'] = "Your basket";
        $this->load->view('template/container', $data);
    }
    function add_item($item_id='') {
        $cart = $this->session->userdata('cart');
        if ($cart) {
            $cart .= ',' . $item_id;
        } else {
            $cart = $item_id;
        }
        $this->session->set_userdata(array('cart' =>
            $cart));
        redirect('/cart/', 'refresh');
    }
    function delete_item($item_id='') {
        $cart = $this->session->userdata('cart');
        if ($cart) {
            $items = explode(',', $cart);
            $newcart = '';
            foreach ($items as $item) {
                if ($item_id != $item) {
                    if ($newcart != '') {
                        $newcart .= ',' . $item;
                    } else {
                        $newcart = $item;
                    }
                }
            }
            $cart = $newcart;
        }
        $this->session->set_userdata(array('cart' =>
            $cart));
        redirect('/cart/', 'refresh');
    }
    function delete_all() {
        $this->session->unset_userdata('cart');
        redirect('/cart/', 'refresh');
    }
    function update_cart() {
        if ($cart) {
            $newcart = '';
            foreach ($_POST as $key => $value) {
                if (stristr($key, 'qty')) {
                    $id = str_replace('qty', '', $key);
                    $items = ($newcart != '') ? explode(',', $newcart) : explode(',', $cart);
                    $newcart = '';
                    foreach ($items as $item) {
                        if ($item_id != $item) {
                            if ($newcart != '') {
                                $newcart .= ',' . $item;
                            } else {
                                $newcart = $item;
                            }
                        }
                    }
                    for ($i = 1; $i <= $value; $i++) {
                        if ($newcart != '') {
                            $newcart .= ',' . $id;
                        } else {
                            $newcart = $id;
                        }
                    }
                }
            }
        }
        $this->session->set_userdata(array('cart' =>
            $newcart));
        redirect('/cart/', 'refresh');
    }
    function checkout() {
    }
}

The associated view looks like this:

Basket Total: &pound;<?= $grand_total ?>
<?php
if (isset($basket)) {
    ?>
<?php foreach ($basket as $val) { ?> <?php } ?>
ID: Desc: Price: Quantity: Total: Delete?
<?= $val['id'] ?> <?= $val['caption'] ?> <?= $val['price'] ?> <?= $val['total'] ?> [x]
Empty Cart Checkout <?php } else { ?> Your shopping basket is empty. <?php } ?>

The code also assumes a database “stock_table” with the following structure:

	--
	-- Table structure for table `stock_table`
	--
	CREATE TABLE IF NOT EXISTS `stock_table` (
		`id` int(10) unsigned NOT NULL auto_increment,
		`caption` varchar(20) NOT NULL,
		`quantity` int(10) NOT NULL default '0',
		`price` float NOT NULL,
		PRIMARY KEY  (`id`)
	) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;

This code has yet to be put to the test in a production environment, so use it entirely at your own risk. You will also notice that the checkout function has not been completed. This is a project for another day, and it’s worth looking at the CodeIgniter PayPal library http://codeigniter.com/wiki/PayPal_Lib/ to help you.

{lang: 'en-GB'}

My Caffeine Level for Today

LJRICH posted a cool link on Twitter that tells you how caffeinated you are. 153 clicks in 30 seconds earned me the rating of “Very High – Productive Worker, Jittery”. Bear in mind that this is not an entirely scientific test, but I do drink PG Tips by the gallon. ;-)

The Caffeine Click Test - How Caffeinated Are You?
Created by OnePlusYou – Free Online Dating

{lang: 'en-GB'}

MS Week 2009

ms-week-banner

Although many people have heard of MS, few people understand the complex, unpredictable, and potentially debilitating effects of the UK’s most common neurological condition affecting young adults.

During MS Week, as well as aiming to generally raise awareness and understanding of the condition, the MS Society is organising a number of national and local events which we need your help to make a success.

MS Week gives organisations working with people living with and affected by MS the opportunity to raise their profile in the public eye for one special week in the year.

Users of social networking websites are being asked to change their avatar to help promote the cause. There are a selection of avatars on the following page:
http://www.mssociety.org.uk/get_involved/campaigning/download_gallery.html

{lang: 'en-GB'}

Ubuntu, VirtualBox USB devices “unavailable”

After a brief return to Windows XP (surely it can’t have been that terrible… oh yes it was), I am now back on Hardy Heron once again. For those few essential Windows apps that I can’t live without I’ve recreate a VM in VirtualBox. All fine and dandy, except all of my host’s USB devices were showing as “unavailable”. Strange indeed. The host could access them perfectly well, but not the guest VM.

After a quick Google, I found the answer on this page:

http://ubuntuforums.org/archive/index.php/t-541195.html

Basically, I had to set up a “usbfs” group, add myself to it, and then create an entry in /etc/fstab that read:

# 1001 is the USB group ID
none /proc/bus/usb usbfs devgid=1001,devmode=664 0 0

Hey presto, USB device can now be connected to the VM. Bizarrely, this didn’t need to be done the last time I had a flirtation with Hardy.

*** UPDATE ***

VirtualBox 2.2 doesn’t actually need you to do this. All you need to do is add yourself to the vboxusers group.

{lang: 'en-GB'}

WordPress Themes