Archive for May, 2007

The word “should” at workplace

2007-05-27

Blogging in English seems to be closely correlated with using English. Despite living in Ireland, I don’t use as much English as I wish to. Luckily, it is getting better. Every single coffee break with Irish people makes a difference.

There’s one word which has started to annoy me lately: “should”.

“This should go there.”
“One should do this.”
“You should avoid that.”

The word itself seems to be innocent; the annoying thing is the way it’s being used. Especially, when the information that “something should” is the only thing one has been told, without explanation of any reasons behind it or a chance to express one’s views on the matter.

(more…)

Code over the phone

2007-05-24

Two weeks of waiting for it have built it up pretty much. When the phone finally rang, for some reason it felt surprising. No more waiting? Interview begins?

“I would like you to dictate me some code” said the engineer. He was describing tasks and asking me to write code that solves them. They were not daunting; could be easily decomposed into basic operations. Recruiters surely understand that people get nervous when being interviewed. The fact that one is being interviewed, not “just” asked to write some code, makes them make stupid mistakes all the time. Interviewers try to give simple tasks to people. It’s also interesting that the questions were not strictly theoretical, but more like “how would you…” followed by something to find out or to calculate.

(more…)

Slugify in a shell script

2007-05-21

When constructing nice file names or URLs, it’s often nice to “slugify” a string, so it has a form of alphanumerics separated by dashes. For instance, you may have a string like this:

Linux clover 2.6.19-gentoo-r5 i686 Genuine Intel(R) CPU T2050 @ 1.60GHz

It has uppercase and lowercase letters, digits, brackets… you need to remove all but alphanumerics while retaining readability. Basically, you may want for instance:

linux-clover-2-6-19-gentoo-r5-i686-genuine-intel-r-cpu-t2050-1-60ghz

If you append “.html” to it, it makes a very nice URL, doesn’t it?

Here’s a part of a pipe chain that slugifies strings:

sed -e 's/[^[:alnum:]]/-/g' | tr -s '-' | tr A-Z a-z

If you have a shell script and you want to slugify variable content, you can:

SLUGIFIED="$(echo -n "${VARIABLE}" | sed -e 's/[^[:alnum:]]/-/g' \
| tr -s '-' | tr A-Z a-z)"

Note that wordpress likes to mess up quotes. They are meant to be plain, double ones.

Mindset

2007-05-20

When in front of a new task, do you believe that you “have” it and you only need to use or show it? Or do you believe that it’s the matter of effort you put into it?

Parallel programming course

2007-05-19

I have spent this whole week in the Computer Science and Informatics building. I wonder how did “informatics” creep into the English language; I was taught in 2002 that there is no such thing as “informatics”. There’s only Computer Science. Term “informatics” was supposed to be used only by mistake. German has “informatik”, Polish has “informatyka”, it’s probably those non-native English speakers who just kept using it until even English people started believing that it’s a legitimate English word. A lie told a thousand times… well, what was I… yes, the course.

The main topic was parallel programming, harnessing multiple processors to solve a single, computationally-intensive task such as a weather forecast or a car-crash simulation. There’s more than that, there are many more problems that you can solve and lots of money you save by simulating things for you instead of doing them for real.

(more…)

Prisoner’s dilemma and bullying

2007-05-12

Prisoner’s Dilemma is one of the classical games in game theory. It’s an interesting abstraction of a whole class of situations, where two parties can choose between cooperative and non-cooperative behavior. It’s a kind of game where win-win and lose-lose result can be achieved. It doesn’t apply to situations like negotiating a price, where one party’s loss is another’s gain; prisoner’s dilemma applies to situation where two parties form a team and work together.

(more…)

I’m now 0×20

2007-05-11

That’s right, today is my birthday. I’m 0×20 years old now. In hex, of course.

In binary, it’s 100000. Helluva round number, isn’t it?

Surviving at workplace

2007-05-09

I managed somehow to survive 4 months with an enemy at the workplace. There are two more coming, so I need to stay alert.

When I started the new job, I thought that D. would become my best friend; that we’ll share interests and work closely together, designing and writing great software.

(more…)

Screen for gnome-terminal users

2007-05-02

I have noticed that gnome-terminal doesn’t handle bold fonts properly. Instead of using a bold version of given font, gnome-terminal displays a kind of widened regular font.

Not really a bold font

In contrast to gnome-terminal, xterm uses the bold variant:

Bold variant is used here
This is enough for me to want to use xterm instead of gnome-terminal, but there’s one problem: tabs.

Everyone who uses Firefox , knows how addictive tabs can be. There are no tabs in xterm, but there is a program called screen, which can do the same job of handling multiple terminals in one window. The only problem with screen was that it uses CTRL+A, N and CTRL+A, P keystrokes to switch the terminals. I am used to do the same thing with CTRL+Page up, CTRL+Page down not only because gnome-terminal uses that, but because it appears to be a standard key shortcut for tab switching in GTK applications. Fortunately, it is possible to configure screen to use those shortcuts. It’s enough to add the following two lines to ~/.screenrc file.

bindkey ^[[5;5~ prev
bindkey ^[[6;5~ next

Another problem with (unconfigured) screen is that there is no status bar showing the list of currently open terminals. This can be configured too, as explained on Gentoo Wiki. This configuration allowed me to switch easily from gnome-terminal to xterm + screen.