Asking questions

Stupid questions aren't a myth. They do exist and they aren't even rare. I'm pretty sure it's more likely you get asked a stupid question than you get hit by a car.

There are stupid questions

So what qualifies as a stupid question? A question:

  • to which you can deduce the answer yourself by applying logic.
  • outside of the area of expertise of the person you are asking.
  • for a well-known fact.
  • so broad you already know it will have a sophisticated answer.
  • that you've already asked, but forgot the answer to.

Continue reading...

CakePHP's array datasource

The ArraySource is a read-only datasource for CakePHP's ORM which uses an array of records inside the Model classes. It was originally created by Juan Basso a couple of years ago. Since then it has been moved to the official CakePHP Datasources plugin and is compatible up to version 2.4.

It is pretty useful for things like statuses, genders or countries for example. These things are usually static and therefor ideal to move out of the database. Using the ArraySource you would still be able to use them in associations and they will be merged in when you do a find. It works with Containable as well. So it's a good replacement for ENUMs, which aren't supported by CakePHP.

Continue reading...

GIT commit messages

It often happens that I read through GIT logs. It is a great way to check how a project is progressing. You can easily see when features were implemented and bugs were fixed. Unfortunately the logs are pretty useless when commits are randomly done and messages are too fuzzy to make something out.

I recently saw a list of 5 commits by the same author. All with the same commit message: "Modified files.". All had a bunch of files changed without any indication what was really going on. This is obviously wrong and it pisses me off. Not everybody seems to understand the value of a proper commit with a proper message. So I am going to explain some things and give a few tips.

Continue reading...

Our outdated time system

Time is a strange thing. It is derived from the position of Earth relative to the Sun. Among other time definitions we have a minute that is 60 seconds, we have an hour that is 60 minutes and a day that is 24 hours. For the longer measurements we have weeks, months, years, etc.

It sounds all very obvious. There are three problems with our current time system though. The first problem is that it is stitched together with tie wraps and duct tape. The second is that it isn't universal. The last problem (and the most important one) is that your clock is wrong 99.99884% of the time. I'll explain that later.

Continue reading...

Routing isolation in CakePHP

We always preach (in the IRC channel #cakephp) to add routing when you are done developing your application. In reality though, it isn’t always that easy if you are following the book. Routing isn’t just changing the routes, sometimes it is also changing the links across your site. It could even be worse if a value is needed in the URL that isn’t yet available. You will end up changing your model code as well to get it from the database. You know routes and links like these:

<?php
Router::connect(
    '/post/:slug',
    array('controller' => 'posts', 'action' => 'show'),
    array('pass' => array('slug'))
);
?>
<?php
echo $this->Html->link('Routing isolation in CakePHP', array(
    'action' => 'show', 
    'slug' => $slug
));
?>

Another problem with this is that you have values in your links that when removed from the route turn into named parameters. You will get something like /post/slug:routing-isolation-in-cakephp. So you end up changing your views again. The problems don’t end here though.

Continue reading...

Complaining about money

Yesterday I was waiting at the register at my local supermarket. There was this woman in front of me. I estimate she was 65-70 years old. She unloaded her cart and waited until the girl behind the counter was done scanning. The total amount summed up to about 71 euro.

On that news the lady freaked out. She said she had only 70 euro. The girl behind the counter offered to keep the groceries separated so the lady could get the money. Instead, she started digging through her groceries to find something she could leave. It seemed to be a hard choice, because it took ages.

Continue reading...

Being called a programmer

Let’s start out with the definition of a programmer.

pro•gram•mer [proh-gram-er] noun

  1. a person who writes computer programs; a person who programs a device, especially a computer.
  2. a person who prepares program schedules, as for radio or television.
  3. a person who prepares instructional programs.

The latter two definitions aren’t really relevant in this context. The first is the one I want to talk about. A person who writes computer programs is what I am. That doesn’t quite cover it though. I like to call myself a software developer, because I’m not coding day in, day out. Most of the time I solve problems. Some problems are simple and others need a bit more thought. For example, instead of programming, I first find the right tool for the job. That makes sense, but how often does it happen someone picks something they have experience with, without looking at the options?

Continue reading...

The blog you are reading

After a couple of years I finally decided to start blogging again. This new website is the place to do it. The subjects of the posts will not only about tech stuff. It will be about anything really, whatever comes to mind.

Initial blog sketch

The picture shows a sketch of how I had it in mind when I began. The right side is currently empty. That side will remain empty until I have a bit more posts. Then the older posts will be listed there. Clearly I am not a designer, so forgive me if it isn't photoshopped enough for you. To be honest, this is the best I can do without messing it up completely. I think it is acceptable for now.

Continue reading...