Archive for October, 2006

Halloween 2006

Angie and I had a little shindig on Saturday to celebrate Halloween, her birthday, some random celebrations which I can’t spell at 23:15 and our moving into our new flat.

Neither Angie or I planned on getting drunk however we ended up totally wasted, probably due to not eating much that day and not drinking for some time. One large bottle of vodka + lots of Blue Charge = lots of fun. And mess 😀

Highlights include:
The fireworks (inc when Maffu lit one and realised he couldn’t let it go…), Angie falling straight back whilst playing with a sparkler (injuring herself quite badly as it turns out), the spaghetti fight and other things we won’t go into here 😉
Around a third of the pics taken turned out insanely blurry but I’ve uploaded the clear ones over at Flickr. I of course have the worst costume, but in my defence it only cost £3 from Asda. And was for ages 11-13.

Angie ended up in hospital today because of her fall. She’s done some nasty damage to her back and neck muscles and has to be constantly dosed up on pain killers and do back/neck exercises every 15 minutes. She’s blaming Maffu and Rob for this, claiming it was my turn to be in the hospital but it’s passed over me in some Final Destination type way 😛

Using Critical Sections with Delphi

Delphi makes threading a very easy process, I’ve used it on numerous projects however there’s always room to learn new tricks.

When multiple threads want to access the same shared data you have to lock it to avoid complications, in my projects I use a TCriticalSection.
The Delphi docs and even my Mastering Delphi book were very vague on the use of this and so I’m hoping that this post will help others avoid the pitfall of misuse I did:

I assumed that I could use a Critical Section like so:

//vars, I use them as part of a class
cs : TCriticalSection;
anInt: integer;
aList: TList;

//create the CriticalSection when my class is created
cs := TCriticalSection.Create;

//thread wants to access the int

//thread want sto do something to the TList

This is very wrong for the following reasons (and probably more):
1) I should have use a TThreadSafeList with auto locking built in for thread safe use
2) Using the same CriticalSection on two different sections of data is completely wrong. Each data that needs locking and is used in different routines or accessed at different times should have it’s own CriticalSection like so:

//Global vars
iCS : TCriticalSection;
lCS : TCriticalSection
anInt: integer;
aList: TList;

//create the CriticalSection when my class was created
iCS := TCriticalSection.Create;
lCS := TCriticalSection.Create;

//thread wants to access the int

//thread wants to do something to the TList

Again, I must stress that if you need to use a TList with threads a much saner and safer option is to use a TThreadSafeList which locks the contained TList for you. If you need to access the internal TList of a TThreadSafeList the following code works great:

with threadedList.LockList do
for x := 0 to Count – 1 do begin

However simple actions such as adding an item are like so:


A simple unit containing a class that spawns several threads and uses TCriticalSections to protect the data would look like so:

unit myClassUnit;


myClass = class
anInt: Integer;
aWord: word;
intCS: TCriticalSection;
wordCS: TCriticalSection;
Constructor Create;
Destructor Destroy;
Procedure IncInt;
Procedure IncWord;
procedure decInt;
Procedure spawnThread;


{ myClass }

constructor myClass.Create;
anInt := 0;
aWord := 0;
intCS := TCriticalSection.Create;
wordCS := TCriticalSection.Create;

destructor myClass.Destroy;

procedure myClass.decInt;

procedure myClass.IncInt;

procedure myClass.IncWord;

procedure myClass.spawnThread;
aThread : TMyThread;
aThread := TMyThread.Create(False);


Usage would be as simple as

theClass : TMyClass;
x : integer;
theClass := TMyClass.Create;
for x := 0 to 3 do begin

with the threads calling the inc or dec procedures like so:


with no risk of data corruption being caused by multiple or conflicting calls to the procedures by different threads.

Tags: , ,

Sometimes too simple?

I noticed this interface for a machine at my work the other day, I wonder just how many technophobes are gonna freak out when it stops working and all they have is two buttons and an LED next to a question mark…

Trapped in the (water) closet

So I go to meet a friend on saturday for a coffee at Cafe Latino’s in town.

As we order our drinks I let my friend know I’m just nipping to the toilet and will be out shortly. Upon entering the spacious unisex toilet I notice the door hasn’t shut properly behind me so I pull it harder. Only to pull the handle a clear inch away from the door! It’s still attached (barely) but I’ve not moved the mechanism so I push it back on, lock the door and go about my business.

Upon trying to leave, the handle moves only half way and as much as I push, kick and barge the door it’s not moving.

A small grin crosses my face. It’s a ridiculous situation to be in but the surroundings aren’t too bad, it’s spacious, there’s water, a coat hook, a mirror, somewhere to sit and if I need the loo I’m not gonna be in trouble am I.
Anyway, I decide to ring my friend to come open the door from the outside. So he answers, and I explain my dilema. Silence……

I hang up, assuming he’s on his way and wait… and wait…
So I ring again…
He says hello, and I tell him to get a move on.
So I hang up and start sending him a txt. he calls just as I’m sending it, none the wiser to my situation. Seems that his phone crashed everytime I called him, so along he comes and opens the door. I go up to the counter and call the manager bod over and say..
“Excuse me mate, I’ve just been in your toilet and got trapped inside, my mate had to come let me out”
The guy get’s the biggest shit eating grin and goes “Oh yeah….”

Thinking to myself that he’s a first class idiot I go out and chat to my mate only moments later I realise I need more sugar, so I head back inside to get some.

Only to see the toilet door handle waggling furiously and a small kid outside wondering what to do. He opens it and a lady comes out. The manager then calls over to the kid with “Oh yeah, the toilet doors not working…”

Absolute idiot. Couldn’t even make the time to put an out of order sign on the door or indeed to inform anyone who headed that way. I wonder just how many people got trapped inside that day….

GooTube and things that make me mad

Today I dealt with a query that nearly made me bang my head against the wall:

Driver: Hi. Errrr… you sent me a speeding fine notification
Me: Yup.
Driver: But I was only doing 53mph in a 40mph….They can’t do me for that can they?
Me: Yes, it’s THE LAW. Speed limits are legally enforcable and if they catch you on camera they get you for it…..

Cue discussion about how much the fine is and how many penalty points he’ll get on his licence. He could barely believe he’d get points let alone a fine for breaking the law. Some people are just too stupid to be let loose on the roads…..

Google bought YouTube for $1.6 billion today. (The service will now only be referred to as GooTube around these parts)
My friend and I often discussed YouTube and how it could possibly make any money. We came to the following conclusions several months ago:
* It was started to host videos of people lighting their farts. And
* the only way it could make money would be to be bought out by another company such as Google.

How accurate can you be……

Talking of Google, I was doing a search at work and decided to use Google’s cache feature to help me find the relevant info faster only to get myself presented with a huge warning screen informing me that the site I had tried to access was blocked and my details logged. Cue a mispelling of a url shortly after and MSN search tied to kick in (not by my choice) and again! Another warning screen! I totalled 4 in 5 minutes.
Of course I phoned tech support…
Me: You’ve blocked Google Cache!
IT support: Yes.
Me: But that’s like tearing out half the pages of the dictionary and telling me to get on with it!
IT Support: Yes. Umm…Sorry?
Me: You’ve blocked Google Cache! I use that feature of the search engine.
IT Support: You could talk to your director(!) and ask for access….

Turns out that their web filter is
a) shit
b) badly configured

so because people have been abusing these two issues they decided to make it block everything and unblock things on an ‘as asked by a director of the company’ level.
It took them 2 weeks to issue me with a password to login to the system and 2 months to get back to me about accessing a shared folder I urgently needed for work. A ‘new starter’ that’s been in the company for 6 weeks is still waiting for a PC to use…
I can tell you now that if I were to ever run that department they’d be a lot of changes and even a few sackings…

Tags: ,

Two new arrivals

We got some new fish today, 2 female guppys. We’re hoping that they might interest the two males we’ve got who have been acting suspiciously gay…

The bathroom got a small decoration as well, thanks to Matt and Maffu at Fat Face we have this funky wall deco up now 🙂

And of course, Mr Cotton’s Parrot to finish it off nicely 😉

Scams a plenty

My day job colleague told me about a new scam hitting the British motorways, I believe it’s called “shunting” and it goes like this:

Two cars work in tandem, they pick a victim, usually a lorry and set to work. One drives in front of the lorry whilst the other drives behind. At a suitable point the second driver overtakes the lorry and pulls into position behind the first car. The first car shortly after slams on the brakes causing the second car to do the same and the lorry to attempt to do the same, causing it to crash into the second car. Cue lots of insurance claims for personal injury and the like against the lorry.
Apparently people are even doing this with children on board, I could never do that, the safety of my child (if I had one) would be far more important than the money gained fom such a stunt.

This other scam is very impressive, it’s always been rumoured that ATM’s have hidden back doors known only to the programmers and now there’s the video proof. I wonder if there is no option to reset the machine back to it’s normal operations or if he left in a rush and forgot or simply left it that way with a Robin Hood gleam in his eye.

I wonder how many people when given a larger amount of money than requested but not charged for would say anything, especially considering how much the banks make in profit each year….

Saying that, this is going to be traced back to the firm/person who coded the ATM software and someone is in for one hell of a bollocking when they’re caught. Kinda reminds me of Office Space in a way 🙂