Posted by: mattmole | November 16, 2010

Funny Dilbert comic

I’ve known people in the past that this fits rather nicely!

Dilbert.com

Posted by: mattmole | October 15, 2010

Microsoft video (anti-openoffice.org)

After watching that, does anyone else feel like that Microsoft is a little worried at the popularity of OpenOffice.org?

One of the things to consider is that a number of these comments may well have been from older version of openoffice. Versions where some of the recent tweaks have not taken place.

The other important point is that Microsoft has had a monopoly for many years with office products (not even mentioning Windows). This means that a huge number of users will be familiar with the Microsoft way of doing things. By only spending a small amount of time using openoffice, of course people will consider switching back to the more familiar! I use openoffice for about 90% of the time I write documents, I find it as easy to use, and easier in some cases.

Personally I prefer the way openoffice deals with styles in the word processor application. While creating a spreadsheet for a work project Excel rather ambiguously implemented one function I was using whereas openoffice spreadsheet worked flawlessly!

Having said all that openoffice word processor can certainly learn from Microsoft Word and all the rotation of graphics natively.

Posted by: mattmole | October 2, 2010

Playing audio files as part of a layout with Xibo

For a time now I have wanted to use Xibo to play audio files as either a background track for a layout, or as part of a layout.

After chatting to one of the developers I realised that it would probable be possible.

THIS IS NOT AN OFFICIAL FEATURE / MODIFICATION. ANY QUESTIONS SHOULD BE MADE TO ME AND NOT THE DEVELOPERS.

First of all a small change needs to be made to the DB. This is in the modules table and is to include mp3 as a valid extension for uploading videos. We use the video region type for this:

After this it is as simple as creating the video region on a layout and uploading the mp3 file. Because media player is embedded into the player, when playing mp3 files the embedded player displays a visualisation of the track. This is not ideal and can be changed by making the region 1×1 pixels in size. The region is still easy to alter, drag and change the timeline.

This by no means answers the question of background music playing throughout multiple layouts etc, and it does not solve the problem of multiple tracks playing audio at the same time, but for my purposes, it is useful!

Posted by: mattmole | September 18, 2010

Muse and Biffy Clyro at Wembley Stadium

Last Saturday I travelled down to wembley stadium to see the final date in muse’s tour.

We arrived in time to see White Lies. They were very good and finished with the anthemic fairwell to the fairground. As with the other tracks it Has a distinctive 80s sound and the singing style sounds very similar to that of the Editors.

Second on stage Were Biffy Clyro. They opened with the enormous sounding ‘that golden rule’. I was a little disappointed that there were no strings in the song, but it was still very good. The rest of their set was very good with all tracks being excellent to sing along to.

After the Biffy set we had a 30ish minute wait before muse came on. After about 25minutes the spherical display screen high above the stage was switched on and The video of an eye was shown looking over various parts of the audience.

To continue the conspiracy theme, the set started with mock protesters carrying ‘they will not control us’ banners.

We were treated to 150 minutes of near constant music. The performance was absolutely incredible. Matt Bellamy’s voice was as brilliant as on the recordings. The drumming was really good and probably made the concert.

Muse played the majority of ‘the resistance’ and Some tracks from ‘black holes and revelations’, ‘absolution’ and ‘origins of symmetry’.

The first encore saw exogenisis part one performed with added visuals. The inflatable UFO was pulled around the pitch and part way through a female acrobat performed on a wire while hanging from it.

The show ended with an amazing rendition of ‘knights of cydonia’.

I will certainly see them again!

The muse, biffy and white lies set lists are below (respectively)


1) Uprising
2) Supermassive Black Hole
3) MK Ultra
4) Map of the Problematique
5) Bliss
6) Guiding Light
7) Interlude
8) Hysteria
9) Citizen Erased
10) Nishe
11) United States Of Eurasia
12) Ruled by Secrecy
13) Feeling Good (Leslie Bricusse & Anthony Newley cover)
14) MK Jam
15) Undisclosed Desires
16) Resistance
17) Starlight
18) Time Is Running Out
19) Unnatural Selection
20) Exogenesis: Symphony, Part 1: Overture
21) Stockholm Syndrome
22) Take A Bow
23) Plug In Baby
24) Knights of Cydonia
1) That Golden Rule
2) Living Is A Problem Because Everything Dies
3) Glitter And Trauma
4) Bubbles
5) Who’s Got A Match?
6) God & Satan
7) Mountains
8) Born On A Horse
9) Shock Shock
10) Many Of Horror
11) The Captain
1) Strangers
2) To Lose My Life
3) Streetlights
4) Bigger Than Us
5) Death
6) Farewell To The Fairground

While researching large scale imaging for a new set of laptops where I work I came across FOG. This is a server based system that can be run on top of most Linux distros, although installation scripts exist for fedora and ubuntu.

FOG uses a number of open source projects and ties them all together using a really good user interface. At the lowest level clients boot using PXE from the FOG server. They then run a Kernel and us a RAM disk to contain a filesystem image. This filesystem is copied from the FOG server and is the init image.

The init image is a byte for byte copy of a basic Linux filesystem including executables, libraries and config files. This is then gunzipped to shrink the filesize.

The first thing to do is to use the gunzip tool to uncompress the image. The image can then be mounted to a point on the filesystem where it can be worked on:

mount -o loop /path/to/file /path/to/mount

To make any changes to the filesystem then the normal shell techniques can be used. To make any changes to the image where a script / executable needs to be run, then you will need to create a chroot “jail” for the filesystem.

Now to the point regarding the SIS191 ethernet adapter. The laptops I want to image all have the SIS191 ethernet card. I could use FOG to upload an image to the server from a completely prepared machine, but it would not deploy. After trying all sorts, using other live disks to mount the NFS share from the fog server and trying this I determined that the problem was definitely the ethernet card.

The fix turned out to be the MTU size. This was documented online as a problem with the driver, that the default size of 1500 caused some sort of problem. I still cannot fathom out how to change the MTU size automatically but I wrote the following simple script that changes the ethernet adaptors MTU and then launches the deployment software

ifconfig eth0 mtu 1000

fog

Please let me know if anyone knows how to add scripts to init without invoke-rc.d!

Posted by: mattmole | July 1, 2010

Creating a recovery partition using open source tools

I decided to do the research for this post for a number of reasons.

Firstly at work I look after a huge number of laptops. We recently decided to buy are bones laptops and install the operating system etc manually. This has result in a huge cost saving, but of course it does mean that it takes more time to setup initially. There is an obvious PXE booting and imaging point to be made here, and that will be addressed in another post. The reason I want this set up is so that at anytime when Windows system files are corrupted I can boot into a “recovery” mode and recreate the laptop from the original image.

Secondly I have used this sort of system before both at work and on various personal computers that I have rebuilt for people. I have often wondered how this sort of system worked and decided that as I knew the sort of things to use I should put them all together and get something to work.

While I have stated that Windows can be imaged, that is true, but it is not the only sort of operating system that can be cloned. The tool used (clonezilla) supports a large number of filesystems, including NTFS, FAT??, EXT3, EXT4, HFS+, reiserfs, etc.

I will try to make it clear the steps that can be ignored if you want to boot clonezilla from a linux machine running grub rather than a windows machine using the ntloader.

Recipe

Ingredients:

Clonezilla

Grub4dos

Method

  • We will need a separate partition to store any images. I have also chosen to store the recovery software (clonezilla) on this partition. Windows 7 creates a small (100Mb) partition for boot purposes. The scheme I used for Windows 7 was to use all primary partition, 100Mb NTFS for Boot, 280Gb NTFS for Windows 7 and 30GB NTFS for the clonezilla recovery information and clonezilla itself. For this I used the partition editor built into Win 7 but of course gparted, partedmagic would do the job easily as well.
  • The second step is to add the grub4dos bootloader to the Windows HDD and to call that from the Windows bootloader. There are two separate sets of instructions for this
  1. Windows 7 / Vista – These OSs seem to have some sort of registry (what the hell is wrong with text config. files) for storing the boot loader options. Instructions are available here. These instructions require a number of commands to be called. Also this section of the webpage talks about the files to copy for Windows 7 to use. NB: The files needed are slightly different to that when booting from the XP bootloader.
  2. Windows XP – This OS uses a text file. Instructions can be found here

The following instructions apply when booting from GRUB. Grub4dos uses the same configuration scheme as GRUB1, so if you use GRUB2 these instructions are not quite correct!

  • The menu.lst file copied from the grub4dos archive needs to be edited with the following:

================================================
title Clonezilla live on harddrive
root (hd0,3)
kernel /live-hd/vmlinuz boot=live union=aufs vga=788 ip=frommedia live-media-path=/live-hd bootfrom=/dev/hda4 toram=filesystem.squashfs
initrd /live-hd/initrd.img
boot

================================================

The Kernel line should be edited to point to where the vmlinuz file is. The hda4 reference should be changed depending on which partition the clonezilla files are stored on.

Also the initrd line needs to be edited accordingly.

The root line should also be changed. Currently this says boot from the first harddisk (disk 0) and the fourth partition (counting from zero remember). This needs to relate to the HDD the clonezilla files are stored on.


Posted by: mattmole | April 3, 2010

Python Object Orientation and Inheritance

One of the main reasons for using Object Orientated coding is being able to reuse code in many different projects. For example, if we created a program to read configuration files, and the code was Object Orientated (OO), then we would be able to use this code in any other program that we would want to read a config. file.

Inheritance is another way to reuse code. We can create a class, and then use variables and functions from it in another class. Thus, this new class (the sub-class) inherits information from the parent class.

The example below was taken from A byte of Python (which is an excellent guide to programming in Python). This example shows how to use inheritance while programming a system for data management within a school. In this very simple piece of code we have each member of the school logging their Name and Age. We then have classes for both members of staff (where their salary is stored) and students (where an average grade is stored)


class schoolMember():

no_members = 0

def __init__(self,name,age):
self.name = name
self.age = age
schoolMember.no_members += 1

def details(self):
print "\tName: %s, age: %s"%(self.name,self.age)

def number(self):
print "Number of members: ",schoolMember.no_members

class student(schoolMember):
def __init__(self,name,age,average):
schoolMember.__init__(self,name,age)
print "Student:"
self.averageGrade = average
schoolMember.details(self)
print "\tAverage Grade: ", self.averageGrade
schoolMember.number(self)

class teacher(schoolMember):
def __init__(self,name,age,salary):
schoolMember.__init__(self,name,age)
print "Teacher:"
schoolMember.details(self)
self.salary = salary
print "\tSalary: %i"%self.salary
schoolMember.number(self)

a = student("Matt",26,78)
b = teacher("El",25,30000)
c = student("Dave",31,42)

From this code sample we can see that the first fourteen lines declare the parent-class which has variables to represent the users name and age, a function to print out details from the variables in the class and a function to print the number of members in the “school”. Also, whenever an instance of the class is created the no_members variable is incremented (see the next paragraph for an explanation of class variable types).

This is an interesting point, where we define variables as self. are instance variables. These variables are “local” to that instance of the class (see later). Any variables accessed using schoolMember. are class variables. This variable can be updated from any instance of the class. In this instance I use it to store the total number of instances of the class. Another example could be an array that can be updated by each instance of a class. This could be used with threading (using locks of course) to update a “global” array with data from many threads.

Lines 16 – 23 are used to declare a class storing student information. This class inherits from the schoolMember class using the class CLASS_NAME(OTHER_CLASS): syntax. We then call the initialisation function __init__ of the parent class with the student’s name and age. We can then set the “local” class average grade variable. We then call the function in the schoolMember class to display the information from that class.

Lines 25 – 32 do not require explanation as they do pretty much the same thing as the previous chunk of code.

The final three lines of code create instances of the student and teacher class and provide them with the information required.

The output of the code can be seen below:

Student:
Name: Matt, age: 26
Average Grade: 78
Number of members: 1
Teacher:
Name: El, age: 25
Salary: 30000
Number of members: 2
Student:
Name: Dave, age: 31
Average Grade: 42
Number of members: 3

Please ask any questions in the comments!

Posted by: mattmole | April 1, 2010

Ubuntu recommended for online banking

I was very pleased last night to read about recommendations to counteract the insecurity of Online banking. The article basically says that using your home PC for online banking (or anything that requires security) is a bad idea.

Instead of needing to use a completely specialist PC a security expert has suggested using an Ubuntu live disk. This means that the Ubuntu distribution is separate to the underlying operating system, and any viruses / malware / key loggers etc should not cause any damage to the user logging into their bank account!

Read the full article here

Posted by: mattmole | April 1, 2010

Dark side of the moon realised using NES(alike)

This is possible the most geeky thing that I have ever seen / listened to. Someone has taken Dark Side of the moon (Pink Floyd) and has created their own version, using an 8bit sound system (like the one used in older Nintendo gaming consoles).

http://www.youtube.com/watch?v=pV7BViKAK1U

Posted by: mattmole | March 19, 2010

Python programming with threads

I’ve used Python for a number of years now, for a number of different tasks. I have used various parts of the standard library of functions, and lots of independent modules.

One thing that I have known about, but never been able to understand is Threading. As we know, in most situations a computer can only do one thing at a time. This is true in Python as at the moment it cannot utilise multiple processor / processor cores.

Threading therefore gives the illusion of doing more than one thing at once, and in some situations can speed up the execution of a program. Instead of running ten for loops, one at a time we can present the illusion that all ten are running at once. Of course the timing is not ten times less, but if a program is IO blocking, then another thread can run before the IO is presented.

I have wished to be able to thread a GUI program so that the GUI is not blocked when operations take place in the background. The following code should give you an idea of how the threading works.


import threading
import time

class FractionSetter(threading.Thread):
def __init__(self,step):
threading.Thread.__init__(self)
self.stopthread = threading.Event()
self.total = 0
self.step = step
self.count = 0

def run(self):
"""while sentence will continue until the stopthread event is set"""
while not self.stopthread.isSet():
self.total += self.step
self.count += 1

def stop(self):
self.stopthread.set()

array = []
for i in range(1,10):
array.append(FractionSetter(i))

#print time.gmtime()

#START THE THREADS
for thread in array:
thread.start()

#DO STUFF WHILE THE THREAD IS RUNNING
running = True
count = 0
while running:
if count == 60:
running = False
print time.gmtime()
time.sleep(1)
count +=1

info = []

#STOP THE THREADS
for thread in array:
#Stopping the thread
thread.stop()
info.append([thread.total, thread.count, thread.getName()])

#print time.gmtime()

for elem in info:
print elem[0], " ",elem[1], " ",elem[2]

First of all we create a class that inherits from the threading.Thread library. This means that we can have our own class that does whatever we like, but also inherits all of the stuff we need to be able to thread the program – how neat is that?!?!

In the example above, we create a new class and override the __init__ call so that we can set our own class-instance variables. In this case we use a variable to store the total and also the value by which we wish the total to increase by whenever the thread runs. The reason that we use a class-instance variable, rather than a class variable is that we wish to be able to have independent counts using individual instances of the class. Finally, in this __init__ function we need to create a variable used to control the thread. This is the line with the threading.Event() call.

Next, within the class definition we define the run method. In this case, while the thread is set to run we increase the total variable by the amount set when we initialise the class.

The stop function simply stops the thread.

Now we have gotten to this point the hard work is over.

Now we can see the rest of the code using the following steps:

  • Create an array storing all instances of the threading class that we create
  • Start each thread
  • Do whatever we want in the main body of the code
  • Stop the threads

We create an array to store the threads, and then using a <code>for</code> loop create an instance of the class and pass in the step size we wish to use.

In this loop we could also start the thread. Instead I created instances and then went through the array with another for loop and started the threads from there. This is because I didn’t know how much time would be taken between create the instances and starting the threads.

At this point the threads are happily running in the background, and every time around the while loop we add to the total.

In my case in the main body of the code I display the time each time the loop is executed, and I wait a second between runs. Note, this loop is not being executed once every second. If the OS is doing lots of other work then the main loop of the Python code will not run each second. Most OS’s are not realtime!

Finally, we go through our array of thread instances, stop each thread and add to a new array the results from each instance of the thread class.

Very finally, I go through this array and display the elements. The results are shown below:

time.struct_time(tm_year=2010, tm_mon=3, tm_mday=19, tm_hour=20, tm_min=31, tm_sec=57, tm_wday=4, tm_yday=78, tm_isdst=0)
time.struct_time(tm_year=2010, tm_mon=3, tm_mday=19, tm_hour=20, tm_min=31, tm_sec=59, tm_wday=4, tm_yday=78, tm_isdst=0)
time.struct_time(tm_year=2010, tm_mon=3, tm_mday=19, tm_hour=20, tm_min=32, tm_sec=0, tm_wday=4, tm_yday=78, tm_isdst=0)
time.struct_time(tm_year=2010, tm_mon=3, tm_mday=19, tm_hour=20, tm_min=32, tm_sec=1, tm_wday=4, tm_yday=78, tm_isdst=0)

This is showing us that the main loop does not run, reliably every second.

8775774 8775774 Thread-1
10751718 5375859 Thread-2
15286545 5095515 Thread-3
24196180 6049045 Thread-4
38322035 7664406 Thread-5
42976164 7162694 Thread-6
44051672 6293096 Thread-7
54951072 6868884 Thread-8
44892180 4988020 Thread-9

This output shows the following, the total after incrementing the counter, the number of times each thread count was incremented, and the thread name.

The code ran for sixty seconds and nine threads were created.

To conclude, this code runs a certain number of threads without blocking the main code. Then after stopping the threads the output from the threads are displayed.

Ways to improve:

  • Maybe use a dictionary for threads instead of an array
  • Use a class to store output information from the threads
  • Older Posts »

    Categories