Sunday: 12pm
April 22, 2007 on 11:17 am | In Personal | No CommentsProcrastination is like masturbation: its great fun until you realise you’ve fucked yourself.
Pens of choice
April 18, 2007 on 12:03 pm | In rubbish | 1 CommentDuring revision time, one must be equipped with the very best in terms of writing imlpemi. Remember: it’s not what you write, its with what you write it! I have today spent some considerable time in the union walkway shop researching the very best in modern writing equipment. I present a few pens which have made a difference to my life, in the hope that this will inspire the reader to buy outside their normal “safe zone“.
First off, the classic Parker cartridge fountain pen (blue). Made in the UK this attractive model comes in blue, red and black bases, and takes the ubiquitous parker ink cartridge. Offering smooth, even writing and non-calligraphic lines this is sure to be the mainstay of any concerted revision effort. Having owned mine since I was born I can say that without it much of the exams I have revised for would have suffered.

Next in the line-up is the Pilot VBall Grip. With its superb, refined penmanship and a low cost of £1.99 (Union walkway shop) I couldn’t resist adding one to my collection. Personally opting for the red I cannot honestly say I have ever encountered a line more suitable for highlighting equations not found in the formulae book. The lubricated ball and rubber grip provide a writing experience that leaves one screaming out: “Margaret, can you get me another Pilot VBall Grip in blue please, such that I can write in blue, also.“.

Next is the 0.9mm Pentel P209. This propelling lead pencil was initially made popular by architects and designers in the 80s, but has come on from there to be the pencil of choice for anyone serious about block diagrams and parallel lines. With a good solid infrastructure and a corrugated grip it is unlikely to let you down. Accidentally stolen from Tom Brodrick last week, already this isn’t a pencil I would leave home without - it really is a thorough ravishment each and every time it is employed.

If Tom realises I’ve got his pen and asks for it back, I shall be safe in the knowledge that in my bag is the BiC Matic 0.5mm #2. A considerable upgrade from the acutely miserable world of the #1, which suffered from frequent malfunctions of the main lead riser-gripper - often leading to a stalling of the mechanism.
French, the BiC is very much an entry-level unit for those looking for a gentle introduction into the world of the propelling pencil. The BiC Matic is sold in packs of three (£2.99 from Ryman). Like the Pentel, this attractive yet inexpensive model contains an in-built (although woefully ineffective) hydrocarbon polymer eraser which can be replaced by the user. For more substantial errors, however I would suggest the Ryman Rubber (£0.79). It particularly lends itself to drawing sine and cos waves, but it is also adept at drawing diagrams of communication systems.

Summary
These are just a few of the high-quality pens available from most competent stationers. Anybody with a desire to do so can easily spend a good hour refining their choices until they achieve the perfect combo for any task.
For 2nd Year Electrical Engineers
April 17, 2007 on 3:52 pm | In Programming | 3 CommentsDearest colleagues,
(Further to Pietro’s blog post)
I do hope you are getting on well with your C++ assignment, which from the sounds of it is going down like a lubed anvil. Couple of things id like to get off my chest, if I may be so bold.
1. Hash Maps
A hash map is none of the following:
- A linked list
- A “big” array
- A binary tree
- A balanced tree
- A “happy” atlas
If we store our records in a linked list, we can access them by scanning along and comparing the key until we find the right one. If the list is unsorted and of an unknown length this will take at worse N comparisons (and increments) where N is the length of the list. If the list is sorted and of a known length then it will take Log(N) comparisons (binary cut), but to get to each node one must still traverse the list in that direction, so it in fact takes (I believe… john?) xLog(x) (i.e the order of the integral of log(x)). So sorting a linked list and binary chopping is therefore futile unless you can access elements without scanning. Don’t iterate over list.at(i)!
Enter: the hash map. Let us say we are storing students with a cid and a name. The key will be the id. We know that these are evenly distributed between odd/even so we could construct two linked lists, one with the evens and one the odds. This would cut the average search time in half. Thus the hash function (which decides which list to enter) would be cid%2. Obviously this generalises quite nicely, so if we have 10,000,000 students we could have 100 lists from our table and use cid%100 as the hash function.
However, when running on a computer that has even a marginally faster clock rate than a wall clock, there is no fucking difference - just search the damn list and get on with something more useful.
Here is the only code you need to look for records:
class Record {
int cid;
string name;
};
class Node {
Record* record;
Node* next;
};
class JamesList
{
Node *head;
string lookupNameByCid(int cid) {
Node* runner = head;
while (head != null) {
if (runner->record->cid == cid) return runner->record->name;
runner = runner->next;
}
return null;
}
};
I thank you.
2. Simulating Circuits
Here is a circuit:
(circuit)
The aim is simulate its behaviour using an event queue. There are two different types of entities here, nodes (blob) and gates. Both share common functionality, they have an output value (Vo) and a set (see above) of outward connections. This makes traversing the network in the same direction as the input changes propagate easy.
So:
class Device {
int Vo;
int delay;
JamesList drivenDevices;
};
class Node : public Device {};
class Gate : public Device {};
Good. Some good stuff there. So when the user presses the button for node a to change its voltage to 1, we create an event in the event queue (an ordered list of some kind). Then start the simulation by making the first event happen. The output of a device only changes when the event is actually executed, not when we realise that a change must happen. The time difference between these is the propagation delay of the device (for a node this = 0).
I think the event execution should go something like this:
void simulate(int until)
{
EventListNode *runner;
runner = events->head;
/* FOR EACH EVENT */
for (int i=0; i<events->size; i++)
{
//Check we arent about to overstep the mark
if (runner->event->time > until && until > 0)
{
break;
}
//This event's node
Device *changedDevice;
changedDevice = runner->event->node;
//Actually change the output voltage
changedDevice->setVo(runner->event->Vnew);
//The gate immediately to the right of this node
Set *affectedGates;
affectedGates = changedDevice->drivenDevices;
if (affectedGates != NULL)
{
set<DeviceConnection*>::iterator itr;
itr = affectedGates->begin();
Device *thisDevice; //Gate for which to update output
//Foreach Device which this Device affects, recalculate its output
int vnew;
while( itr != affectedGates->end() )
{
thisDevice = ((*itr)->device);
vnew = thisDevice->Vnew;
//If the voltage has changed make an event
if (thisDevice->Vo != vnew)
{
events->addEvent(thisDevice,
thisDevice->Vo,
vnew,
runner->event->time + thisDevice->delay);
}
itr++;
}
}
runner = runner->next;
}
//We're done, so delete the events.
events->clear();
}
I do hope that makes some sense, since I have personally given up caring.
Its also important that the ordered event list puts new events with the same time as existing events after the current ones, else they will be missed.
Love and cuddles,
James
:: james at jgubby.com
Somebody stole my phone again!
April 6, 2007 on 4:14 am | In Rants | No Commentssome subhuman scum has stolen my phone from my person while i was walking; some thoughts.
how so ever dare you steal my phone you night-felcher of the soul, you vile incumbent crab, you poo munching pavement beast, a fool go with thy soul; whither it goes! you minge clipping fat scab human excrement faced disease that must be cut away, you racoon-rimming grotesque ceiling felcher with a rectangular monkey who deserves to rot so slowly he isn’t initially aware of the problem - show your sheep-biting face, and be hanged an hour! the most infectious pestilence upon thee!
Yours sincerely,
James
In light of this, if you are in possession of my phone and would now like to revoke your theft, please contact me:
:: james at jgubby.com