Category Archives: General

The Python Challenge – Warming Up

My nephew is doing The Python Challenge and my daughter has just started Python at school.  I thought that it might be fun to have a play.  I know nothing about python really, other than there are annoyingly two subtly different versions, version 2.x and 3.x

So I thought I would have a play and try doing the challenge in both languages.

Warming Up

OK, so this looks like you need to replace the 0 in the URL (http://www.pythonchallenge.com/pc/def/0.html) with 2 to the power of 38.  Even I could do this I thought.  It didn’t take long

A quick google on how to launch the browser, and the small problem of changing a LONG in to a STRING and it was done.  This works in both 2.7.5 and 3.0

import webbrowser
new = 2
warmingupurl = "http://www.pythonchallenge.com/pc/def/" + str(2 ** 38) + ".html"
webbrowser.open(warmingupurl,new=new)

WordPress notes

Change the depth of the top menu in the header php file:
‘primary’, ‘menu_class’ => ‘nav-menu’, ‘depth’ => ‘2’ ) ); ?>

Add submenus with the Advanced Sidebar Menu.

Dell Inspiron 1210 (Mini 12), dead hdd meets Ubuntu 12.04

So, my dad’s Dell Inspiron 1210 (Mini 12) finally died after years of service.  I had moved it from Ubuntu to Windows a few years ago, but now it was properly dead.  Dad’s friend had diagnosed a dead hard disk.  And after much work I decided I agreed, though the BIOS was behaving badly.  I used Clonezilla to boot to DOS and refresh the BIOS, and this helped, but in the end it was the disk.

I dismantled the laptop using Dell’s own instructions and found a disk I’d not seen before, a ZIF (zero input force) 1.8″ drive.  I’d never met ZIF before and had no clue how to release it.  Eldest daughter suggested pull it out, so I did, but I later found on youtube that there is indeed a clamp you release.

Anyway, I tried a large variety of methods to make a functioning machine.  I wanted it to boot of an SD card and bought a 16GB in town.  But booting from USB or making an image on the SD card was endlessly frustrating.

In the end, I sought out (with wife’s help) an old USB DVD.  This got me moving forward, and I finally got Mandriva installed, though the display looked awful.  Ubuntu 10.10 then worked, and I then thought I would go the whole hog and go for the latest version of Ubuntu LTS (Long Term Support).

Installing was interesting.  Booting from a USB gave me weird display issues, but booting from the DVD was fine.  I installed to the SD card but the install failed at “install bootloader”.  I figured all the files would be in place and I just needed to get a bootloader working.  Thanks to it being an SD card it was easy to whack it in my main laptop.  Much searching got grub installed , I just had to find where it was mounting (/media/:

sudo grub-install –root-directory=/media/ /dev/sdb

This got the sd card in the 1210 to boot to the grub prompt.  More searching found three commands to get it booting:

grub> linux (hd0,1)/vmlinuz root=/dev/sda1 
grub> initrd (hd0,1)/initrd.img 
grub> boot

Then I was in and it booted fine – all the files were there.  Sadly the display was a complete disaster, a known problem.

So ctrl+alt+f1 got me a command prompt to get grub working properly, which was as simple as:

sudo grub-install /dev/sda
sudo update-grub 

Then I needed to work on the display issues (it was booting to a blank screen or half a screen of garbled nonsense, depending on its mood.  Back to ctrl+alt+f1 (the dist-upgrade took a while)

sudo apt-get dist-upgrade   # this takes a while
sudo shutdown now -r        # this reboots

The last stage was to follow the Ubuntu wiki for the problematic Intel gma 500 graphics card.

sudo service lightdm restart

I was just following the wiki by now:

Ubuntu 12.04

With the default settings, Ubuntu 12.04 boots to either a black screen or or top half screen.
There are several potential solutions: console=tty1, disable splash, or 915 Resolution

Option 1 – console=tty1

Perhaps the easiest method is to use “console=tty1” as a boot option.
  • gksudo gedit /etc/default/grub

Find the following line: GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash”
Add console=tty1 in between the quotes, the end result looking as follows
  • GRUB_CMDLINE_LINUX_DEFAULT=”quiet splash console=tty1″
save and exit, then update grub with

sudo update-grub

 And now it works perfectly and seems very smooth.

Arduino

Mum bought this for my nephew for Christmas.  It looks fun so I bought a kit.

http://www.arduino.cc

I had a play for a little while and came up with a button that when pressed plays out SOS on a red LED.  I suspect I am not the first to try this, but it looks interesting and the possibilities are enormous.  I initially had problems because in the dim light of my sitting room I had plugged the 5V lead in to the 0V (GND) hole. But I got there.

My masterpiece

I’m still not *quite* sure why I bought this, but if/when I make a go of going it alone in Primary school eduction it might make a fun little project.

This is the board I have:
http://www.arduino.cc/en/Main/arduinoBoardUno

All purchased as a kit from www.earthshineelectronics.com