Monthly archives: June, 2006

A bad day

Yesterday was one of those days where it’s better to not wake up. Maybe the whole week was bad!

At the office the bosses were complaining about everything (from timetable to holidays to our time to have lunch) . They are making a lot of changes, and it seems this company is not going to have a nice and friendly ambience anymore. They are growing and maybe they want to be more productive, but it’s a wrong idea to tell the workers to work hard and more hours (and of course to make them angry). It’s not the way to obtain the best from the workers.

At home the washing machine pass away. Yesterday the main cilinder went out of axis and a big oil stain appeared on the ground. So I have to look for another one.

I’m fed up this week. I want to stop the train and jump out on to the grass. Where is the stop-handle?

Metaphysics on programming

Mirror by Jesús One of those things which sometimes made me crazy while programming are quotes (single ‘ and double ” quotes). Let me explain…

Most of the modern programming languages include a way to manage strings, normally it’s surrounding them with quotes (for example, in PHP: $response=”Hi there!”). The question arrives when you want to add a quote as a part of the string… because every language has its own way (and it’s a little problem if you usually program in different languages). For example, in PHP this is correct: , but this doesn’t work: (instead, you must directly use ), and it’s not exactly the same in Javascript. Next, the real problem happens when the user of your program starts to write lots of quotes as part of the input… you have to be really careful, programming some filters.

I imagine a string looking at itself, thinking “is this quote a part of myself or my end?” ;-), like the mirror in the clever drawing made by Jesús (he is a really fantastic artist, you should take a look at his new drawings). What happens when the limit of something is a part of itself? What happens when you see your limit is a part of yourself? Then you can change it, openning it!

By the way, most programmers do the laziest focus: to not allow the user to introduce quotes. But I think it’s the wrong solution, because it’s not a solution at all, but a patch. The professional way to do this is to implement a real solution, so the user can do what he/she wants. You are the person who has to spend time thinking, and not the opposite. This is the reason of this post: I spent the whole day trying to solve this problem in the most elegant form, in a AJAX-powered CMS I’m working on.

Update: At Sunday night I got it. Now I have an “edit in place” system with support of quotes marks, with an easy plus elegant code :-)

How many words?

Yesterday I thought about this question: “how many english words do I have in my mind?” . How vast is my English vocabulary?

So I have had an idea: to program a small script in PHP which counts words from my English posts here.

At the moment, with only 14 entries, the statistics are:
· 3234 total words.
· 1094 different words.

Top 5:
the (177)
to (97)
a (96)
i (83) [it’s actually “I” lowercased]
and (71)

I’m happy because “nice” it’s not even in the top 50. My teacher is always complaining about the excessive use of this world ;-)

Programming while I’m in the sky

In my last flight I discovered something with my laptop. It was the first time I used it inside the plane. Normally I prefer to sleep (or try to). But in this case I was trying to program some ideas (specifically a CMS using AJAX), and suddenly I discovered my usual text editor didn’t fit all my needs without a mouse. Normally I use a modern editor to implement web pages, Notepad++, but without a mouse it’s not so comfortable. Then I remembered an “old friend”, Vim.

Let me introduce Vim. Some decades ago, in the old Unix times, somebody created a clever text editor called Vi. Later, in 1991, another person improved it, so Vim (Vi improved) was born. It was a weird editor for the newcomers, but really effective for the experts. I used it at the university, but later I forgot it, because it was a text IDE, without the new and modern options it should have (windows system, mouse use, friendly interface and such things). However some weeks ago I read they are still improving it, and I installed it in my laptop (for curiosity). And it was amazing, because I discovered it fits perfectly for my needs when I’m programming in a plane, only with the keyboard of my laptop. So I’m learning, again, all about it. Programming with Vim in a plane! I’m sure the inventor never dreamed about it, three decades ago!