All posts by erk

I love writing, computers, puns... and can sometimes be spiritual, or mindful.

Euro English

The European Commission has just announced an agreement that English will be the official language of the EU – rather than German (the other possibility).

As part of the negotiations, Her Majesty’s Government conceded that English spelling had some room for improvement, and has accepted a 5-year phase-in of new rules, which would apply to the language and reclassify it as Euro-English.

The agreed upon plan is as follows:

In year 1, the soft ‘c’ would be replaced by ‘s’. Sertainly,this will make the sivil-servants jump with joy. The hard ‘c’ will be replaced by ‘k’.

This should klear up konfusion and keyboards kan now have one less letter. There will be growing publik enthusiasm in the sekond year, when the troublesome ‘ph’ is replaced by ‘f’. This will reduse ‘fotograf’ by 20%.

In the 3rd year, publik akseptanse of the new spelling kan be expekted to reach the stage where more komplikated changes are possible. Governments will enkourage the removal of double letters, which have always been a deterent to akurate speling. Also, al wil agre that the horible mes of the silent ‘e’s in the language is digrasful and they should eliminat them.

By year 4, peopl wil be reseptiv to lingwistik korektions such as replasing ‘th’ with ‘z’ and ‘w’ with ‘v’ (saving mor keyboard spas).

During ze fifz year, ze unesesary ‘o” kan be dropd from vords Kontaining ‘ou’ and similar changes vud, of kors, be aplid to ozer kombinations of leters (i.e., ‘ea’).

After zis fifz yer, ve vil hav a reli sensibil riten styl. Zer vil be no mor trubls or dificulties and evrivun vil find it ezi to understand ech ozer.

Roger and Elaine

A guy named Roger is attracted to a woman named Elaine. He asks her out to a movie; she accepts; they have a pretty good time. A few nights later he asks her out to dinner, and again they enjoy themselves.

They continue to see each other regularly, and after a while neither one of them is seeing anybody else. And then, one evening when they’re driving home, a thought occurs to Elaine, and, without really thinking, she says it aloud:

“Do you realize that, as of tonight, we’ve been seeing each other for exactly six months?”

And then there is silence in the car.

To Elaine, it seems like a very loud silence. She thinks to herself: Geez, I wonder if it bothers him that I said that. Maybe he’s been feeling confined by our relationship; maybe he thinks I’m trying to push him into some kind of obligation that he doesn’t want, or isn’t sure of.

And Roger is thinking: Gosh. Six months.

And Elaine is thinking: But, hey, I’m not so sure I want this kind of relationship, either. Sometimes I wish I had a little more space, so I’d have time to think about whether I really want us to keep going the way we are, moving steadily toward… I mean, where are we going? Are we just going to keep seeing each other at this level of intimacy? Are we heading toward marriage? Toward children? Toward a lifetime together? Am I ready for that level of commitment? Do I really even know this person?

And Roger is thinking: So, that means it was… let’s see… February when we started going out, which was right after I had the car at the dealer’s, which means…let me check the odometer… Whoa! I am way overdue for an oil change here.

And Elaine is thinking: He’s upset. I can see it on his face. Maybe I’m reading this completely wrong. Maybe he wants more from our relationship, more intimacy, more commitment; maybe he has sensed, even before I sensed it, that I was feeling some reservations. Yes, I bet that’s it. That’s why he’s so reluctant to say anything about his own feelings. He’s afraid of being rejected.

And Roger is thinking: And I’m going to have them look at the transmission again. I don’t care what those morons say, it’s still not shifting right.

And they better not try to blame it on the cold weather this time. What cold weather? It’s 87 degrees and this thing is shifting like a garbage truck, and I paid those incompetent thieves $600.

And Elaine is thinking: He’s angry. And I don’t blame him. I’d be angry, too. I feel so guilty, putting him through this, but I can’t help the way I feel. I’m just not sure.

And Roger is thinking: They’ll probably say it’s only a 90-day warranty… scumballs.

And Elaine is thinking: Maybe I’m just too idealistic, waiting for a knight to come riding up on his white horse, when I’m sitting right next to a perfectly good person, a person I enjoy being with, a person I truly do care about, a person who seems to truly care about me. A person who is in pain because of my self-centered, schoolgirl romantic fantasy.

And Roger is thinking: Warranty? They want a warranty? I’ll give them a warranty. I’ll take their warranty and stick it right up their…

“Roger,” Elaine says aloud.

“What?” says Roger, startled.

“Please don’t torture yourself like this,” she says, her eyes beginning to brim with tears. “Maybe I should never have… Oh God, I feel so…” (She breaks down, sobbing.)

“What?” says Roger.

“I’m such a fool,” Elaine sobs. “I mean, I know there’s no knight. I really know that. It’s silly. There’s no knight, and there’s no horse.”

“There’s no horse?” says Roger.

“You think I’m a fool, don’t you?” Elaine says.

“No!” says Roger, glad to finally know the correct answer.

“It’s just that…it’s that I…I need some time,” Elaine says.

There is a 15-second pause while Roger, thinking as fast as he can, tries to come up with a safe response. Finally he comes up with one that he thinks might work. “Yes,” he says.

Elaine, deeply moved, touches his hand. “Oh, Roger, do you really feel that way? ” she says.

“What way?” says Roger.

“That way about time,” says Elaine.

“Oh,” says Roger. “Yes.”

Elaine turns to face him and gazes deeply into his eyes, causing him to become very nervous about what she might say next, especially if it involves a horse. At last she speaks.

“Thank you, Roger,” she says.

“Thank you,” says Roger.

Then he takes her home, and she lies on her bed, a conflicted, tortured soul, and weeps until dawn.

When Roger gets back to his place, he opens a bag of Doritos, turns on the TV, and immediately becomes deeply involved in a rerun of a tennis match between two Czechoslovakians he never heard of. A tiny voice in the far recesses of his mind tells him that something major was going on back there in the car, but he is pretty sure there is no way he would ever understand what, and so he figures it’s better if he doesn’t think about it.

The next day Elaine will call her closest friend, or perhaps two of them, and they will talk about this situation for six straight hours. In painstaking detail, they will analyze everything she said and everything he said, going over it time and time again, exploring every word, expression, and gesture for nuances of meaning, considering every possible ramification. They will continue to discuss this subject, off and on, for weeks, maybe months, never reaching any definite conclusions, but never getting bored with it, either.

Meanwhile, Roger, while playing racquetball one day with a mutual friend of his and Elaine’s, will pause just before serving, frown, and say, “Norm, did Elaine ever own a horse?”

And that’s the difference between men and women.

/Author Unknown

Iterating a list, and deleting from it, Java vs .NET

Or how I came to realize I could live a life time without .NET and be just as happy.

I’m just fresh from having tried to iterate a list… and delete items from it while iterating.  In .NET with C#.

It turns out a statement like:

void deleteFromList(IList<X> list) {
     foreach (X x in list) {
        if (x.DeleteMe) {
            list.Remove(x);
        }
    }
}

Will throw an InvalidOperationException stating you cannot perform a foreach and delete at the same time.  This is actually not that big of a surprise, or it shouldn’t be…  the same happens in Java if you delete and iterate at the same time.

This is how I would have done this in Java:

void deleteFromList(List<X> list) {
     Iterator<X> itr = list.iterator();
     while (itr.hasNext()) {
	X x = itr.next();
        if (x.DeleteMe) {
            itr.remove();
        }
    }
}

It’s simple, clean and it does not throw exceptions. If you believe the code may be run asynchronously, slap on a “synchronized” and you’re home safe.

So, how to do this with .NET?  Well, you can’t use Enumerators (which are the .NET “equivalent” of iterators), they don’t have a remove method.  Further worse, if you are unlucky enough to run version 1.1 your only option seems to be some unholy concoction like:

void deleteFromList(IList<X> list) {
    IList<X> toBeDeleted = new List<X>();

    foreach (X x in list) {
        if (x.DeleteMe) {
            toBeDeleted.Add(x);
        }
    }

    foreach (X x in toBeDeleted) {
        list.Remove(x);
    }
}

Don’t even start a conversation on synchronization with this mixup.  Anyway, those who are “lucky” enough to code .NET 2.0 can do something like:

myList.RemoveAll(delegate(X x) { return x.DeleteMe; });

Now, if you’d like to base the “DeleteMe” calculation on some external paramter like input to the deleteFromList method or if you’d like to do more than just delete x you’ll have to experiment, it’s probably possible… with a solution like the double lists above perhaps?

Regardless.  Someone said it was old news to be a Java programmer, I can only guess because of the lower hour wastage when you program Java systems, which in turn means lower bills to the clients and finally lower wages to the programmers.

It costs to be on top…

Moblock traffic blocker

Moblock (moblock-deb) is a so called traffic blocker. It prevents connections from certain IP numbers (defined in block lists) to gain access to your computer. The whole purpose is that the blocked IP numbers usually belongs to this or that organization that wishes to find out more about your Internet habits and other information they have no reason to get their noses into.

Moblock has a big brother called Peerguardian by Phoenixlabs but development on this program seems to have been discontinued, and unfortunately at a stage where the program doesn’t work (at least for me it doesn’t). I am also sure there are some Windows variants of an IP-blocker (I’m guessing Bluetack is the right place to go).

Installing Moblock on Ubuntu turns out to be a very simple affair. Mainly do two things: Add moblock’s repository to your repository list, and run an apt-get command. (Here’s an even better instruction for installing Moblock on Ubuntu).

The installation takes care of setting up cron-jobs to update your block lists every day, installs moblock as a service started every time the machine is started, and makes the first download, after which the program (or in fact, demon) is started and you are safe.

The above link is a very good instruction on installing moblock, and it even have instructions on how to perform some simple troubleshooting.

If you run linux I suggest you take a look at moblock’s home page, or you can check out it’s project page on sourceforge.

BasKet Note Pads – note-taking application

BasKet is a very nice application I just stumbled across. It is a kind of OneNote for Linux.  In Ubuntu (probably Debian and others as well) it can be managed as a regular package.

I’m using it mostly when writing and ordering ideas and the like, but I can see myself doing much more with it…. once I’ve made sure it’s stable enough. Let me get back on that with a more proper review later.

The Selfish Gene

Richard Dawkins discusses in his book “The Selfish Gene” if we are using our genes to propagate ourselves, or if maybe our genes are using us to propagate themselves.

According to Dawkins life may very well have begun a long time ago, in the primordial soup, when simple clumps of amino-acids became self-replicating. This self-replication started a kind of war between competing replicators and who was on top (or in the majority) in the soup probably changed many times until one kind of replicators using a protective layer of matter came out the winner (one cell organisms).

Continue reading The Selfish Gene

How to add a body on load function with Javascript

This is an article on how to add a javascript function that will be run when a web page has loaded. We begin by defining a function for running after a page (or actually window) has been loaded:

function bodyOnLoad() {
  ..
  ..
}

And then we’ll do:

window.onload = bodyOnLoad;

However, we also want to make sure our setting of the load event doesn’t remove some other setting. This is done by also keeping any older events.

We store the previous on load event by doing;

var prevOnLoad = window.onload;

And we redefine our bodyOnLoad function:

function bodyOnLoad() {
  prevOnLoad();
  ..
  ..
}

However, we can make the creation of the function and the setting of the event a little bit more effective by doing:

window.onload = function() {
  prevOnLoad();

  ..
  ..
}

You still need to get prevOnLoad before you do that

This becomes even more obvious once we create a function for adding new load events:

function addLoadEvent(func) {
  var prevOnLoad = window.onload;
  window.onload = function() {
    prevOnLoad();
    func();
  }
}

In this way, we can concentrate on creating the new load event outside of the function for adding it to the window.onload.

function myEvent(){
  ..
  ..
}
addLoadEvent(myEvent);

We might even do:

addLoadEvent(
  function (){
    ..
    ..
  }
);

Notice the difference between curly braces “{}” and parenthesis “()”

Finally, we have to make sure there is a load event set for the window before calling it from the new event, so we need to check for this:

function addLoadEvent(func) {
  var prevOnLoad = window.onload;
  if (typeof prevOnLoad != 'function') {
    window.onload = func;
  }
  else {
    window.onload = function() {
      prevOnLoad();
      func();
    }
  }
}

Programming humor

In case you wondered. Sure, programming can be humorous, but this is more about looking at programming with humor. Or, well, I’ve found a few funny things I’d like to share… XML is like violence: if it doesn’t solve your problem, you’re not using enough of it.

People who make buttumptions about their censoring settings, will be embarbutted when they repeat this clbuttic mistake.

Review: Paycheck – Let the future be untold (4/5)

Paycheck (IMDB, Amazon) is a story about Michael Jennings (Ben Affleck) who is an engineer, or to be more precise a reverse engineer. Michael is paid to take competitor’s work and reverse engineer it into something his employees can make into a products of their own.

Since it would be very bad if information about whose technology was reverse engineered into what, Michael’s assistant Shorty (Paul Giamatti) helps removing all of Michael’s memories of the project once work is finished.

A once in a lifetime opportunity comes along as Michael’s old friend Rethrick (Aaron Eckhart) offers him work that will give him stocks in Rethrick’s promised-to-become-great company. Michael takes on the three year project, even if he risks losing his memory for the whole period, and that of a probably blooming romance with one of Rethrick’s employees, doctor in biochemistry, Rachel Porter (Uma Thurman).

Three years passes, Michael finds himself back where he once begun, in Rethrick’s office, his memory wiped and all that stands between him and his millions, a trip to the bank.

That is however, when problem starts, because Michael finds not only has he switched the personal effects he once had to leave before entering Rethrick’s employee, he has also forfeited a 100 million dollars worth of stocks in Rethrick’s company.

Why did Michael say no to the money and, of significantly less importance, what became of his personal effects? Michael soon realizes his former employees and the FBI are out to get him, and his bag of assorted effects seems to be the only thing that keeps him ahead of the game. A game, that if lost, could cost him his life…

You can read the whole review by clicking the below link, but there may be spoilers in that text…

Continue reading Review: Paycheck – Let the future be untold (4/5)