Why Programmers Work At Night

An interesting article that I just discovered. And it looks like I’m on my way to a short night again 🙂

…programmers work at night because it doesn’t impose a time limit on when you have to stop working, which gives you a more relaxed approach, your brain doesn’t keep looking for distractions and a bright screen keeps you awake.

via Why Programmers Work At Night – Business Insider.

Use WordPress as an Evernote replacement

I discovered Evernote a few months ago. A lot of people are using it for saving all kinds of notes, pictures etc.  Obviously they are happy with it, and are writing and talking about it. I decided to give it a try and although I thought it was a nice service, I didn’t have much use of it, and I forgot about it.

It’s only a few days ago that I that I thought it would be nice to have a central place where I can save all my notes, instead of having them in paper format or small files in different parts of my hard drive. A remote access would be nice to have too.

So I thought again about Evernote a few days ago. I started to use it, and I liked the use of notebooks and tags for organizing the notes. But something bothered me: I didn’t own my data.

Continue reading

Less is more: a little tips for reading log files with less

I tweeted about that recently but a tweet is not read by a lot of people so I write a short post here.

Have you ever wondered how to read a log file from the end?

Well, there is tail -100 logfile.log for instance, but if you haven’t find what you look for you must try with tail -200 logfile.log and so on (I don’t talk about tail -f logfile.log here).

No, I you want to read a log file but want to start from the end and search for a specific message, you can try less +G logfile.log. Life will be much easier then 🙂

Fixing Ubuntu 11.04 after a problematic installation

As I wrote earlier, I had problems installing Ubuntu 11.04 on my laptop, but after som fights I managed to have a computer running Natty Narwhal.

But not everything was fine though: there was no time-out in GRUB2 and starting daemons like Apache didn’t work.

For the first issue, my laptop could display GRUB until I pressed the enter key. Setting the timeout in /etc/default/grub was useless. Obviously the install wasn’t fine so I corrected this by reinstalling GRUB:

I’m not sure the last line is necessary, hopefully apt-get takes care of updating GRUB, but it’s better to write one line too much than having a system which can’t start.

The other issue was starting daemons. Ubuntu doesn’t use anymore the System-V init but another system called Upstart. But Apache and MySQL didn’t start at boot time, and when I wanted to start them I got Warning: Fake initctl called, doing nothing. As above, the install was corrupted and I had to reinstall upstart:

My computer is better now, but I might reinstall more packages as soon as I have other issues.

Transparently compressing JS and CSS files with PHP

When I develop a web site, I usually configure it to compress the content before sending it to the end user. Downloading resources such as HTML, CSS and JS files is then smaller and thus faster.

It is possible to configure this in the .htaccess file (in case the server runs Apache) as well as it is possible to program it in PHP.

Unfortunately, it looks like my web hosting company doesn’t allow the former, so I had to take the PHP way for compressing resources in geo:truc.

The PHP code for doing this is rather simple:

This works fine: write a PHP script, put the code above in it, and it’s done! It works with HTML files, and it’s possible to use it as well with JS ans CSS files, although they need to start with this snippet and have a .php extension.

But how to do when using different JavaScript libraries that are now commonly used? A new .php file for every new version of jQuery? It sounds fastidious. And how to make it transparent, i.e. not passing a URL like http://www.example.com/js/compress.php?file=jQuery.js ?

Continue reading

An Ubuntu 11.04 install story

Two days ago Ubuntu 11.04 was released. I didn’t want to upgrade my system that day, but this silly box announcing a new Ubuntu release when I logged into my system tempted me a lot and yes, I clicked on the upgrade button.

The process began, and obviously I wasn’t the only one upgrading because the download speed was very slow. I stopped it and I downloaded the install CD via Bittorrent instead. That was quickly finished. I made a live USB and rebooted my computer. I didn’t want to try Ubuntu live, so I clicked on the install Ubuntu button, and after answering a few questions the installation upgrade began.

When I went back my screen was black with a lot of system messages and it was freezed, which is of course very unpleasant when you’re installing/upgrading your system. I could reboot and this went fine. But when I came to GDM, my usual username wasn’t listed and after a few tries I had to admit that I couldn’t log in. I rebooted again the LiveUSB, and reinstalled Ubuntu. Then I could come into the system but I had no wireless. I rebooted again in Ubuntu live, in which I could access the Internet.

I looked for this issue of freezing installation and I found that I wasn’t the only one. But I found also this page, which was very useful. So I did this:

sudo mkdir /media/fix
sudo mount /dev/sda6 /media/fix
sudo chroot /media/fix su

Then I checked that everything was correctly downloaded, since the installer freezed:
apt-get update
apt-get upgrade
apt-get dist-upgrade

apt-get was happy so I supposed that the system was okay.

I rebooted again and well, I could log in, but still no wireless available. Then I realised that my grub menu listed the same kernel as the previous release (2.6.35) instead of 2.6.38. I made a
sudo update-grub
and grub showed me the new kernel. I selected it, booted and now I have a nice Ubuntu 11.04 with the WiFi working 🙂