Life important lessons

I just came accross the last issue of Hacker Monthly. There was an article by Derek Sivers, about the Meaning of Life. It is actually the transcript from a video of one of his talks. I highly recommend you click that link and read the text.

It made me realise that there are things that may seem obvious in retrospect, but that we often forgot in the heat of the action of living. Here are a small list of those that resonate with me.

Be future focus. Try to do things to make life easier for the future you. Learn new skills, put some money aside, prepare for when you'll be older and would like things to be easy.

Try to get in "the zone" as much as you can. We call "the zone" that moment when you're focused on what you do and everything is nor too easy, nor too hard. You have the feeling that everything goes well, you know what you're doing, you know where you're heading, and you know why you're doing it. Avoid work that gets you away from the zone, and look out for those that gets you in that state of mind.

Remember that our brain has had billion of years to evolve. From bacterias to fish, to monkeys, to us. The new parts of our brain, the one that differenciate us from other animals are the one about prediction, language and logic. But the old ones are all about fear, gut feeling and instinct. Our old brain has been here forever, the new one is still in beta. Even a $5 machine can beat as at Math. But no machine is yet able to have instinct or gut feeling. Trust the part of your brain that has been in production since the dawn of time.

Choose what is important over what is urgent. Important is learning new skills, keeping in good shape, giving undistracted attention to the one you love. Urgent are emails, text messages, tweets. It begs for being done right now, but won't give you much after. Important things won't yield results in a forthnight, but they will last forever.

Change routine often. In a few years, when you'll look back at your past, you won't remember the simple days. You'll remember the changes, the moment you took important decisions. Changing job, moving away from you appartment, going abroad. Change course often, change routine and break monotony. You'll have more, better, memories.

And don't let others tell you what your good or bad at. No-one is ever good at anything the first time. You have to try, fail, work, practice and succeed. No more "I'm not good at math" or "I'm naturally good at that". Everything can be learned given enough time and practice.

This are all important lessons that one should not forget.

UTF-8 encoding for nginx

I just realised that my very own website wasn't correctly returning UTF-8 in its Content-Type response headers.

As my new server is only one ssh command away, I could easily log in and edit my nginx config. I also added a security measure of not exposing the nginx version I'm using.

# Set default encoding as utf-8
charset utf-8;
# Do not expose nginx version in headers
server_tokens off;

AnkiDroid

A colleague of mine, which is as interested in life hacking and getting more of the human brain as I am, showed me an Android application named AnkiDroid.

This is technique to easily memorize list of things. The kind of thing you might need to know by heart but never took the time to actually learn. Like countries and capitals, the bones of the human body, HTTP codes, vim motions, anything.

The idea is to present you each day with a list of 20 things to remember, represented as cards. It will first show you the front of the card (a country name for example), and you'll have to guess the matching capital. When you think you know it, you can reveal the answer by flipping the card.

You then press Yes or No, depending if you found the correct answer or not. You then go to the next card. If you were wrong on a card, it will pop up again soon in the deck. The more often you are wrong on a card, the more often it will pop until you memorize it. On the other hand, if you were right, you won't be asked this same card until tomorrow, and if you are still correct tomorrow, it will wait 3 days before asking, then 7, a month, and so on and so on.

Things you already know won't pollute the list of cards, but things you're not totally sure about will come up regularly and you'll then remember it just by the repetition of it.

In the end it makes a very addictive game, and I learned a lot of things in no time. I'm doing about 20mn of it every morning, while commuting, and I'm now able to place on a map much more countries than before.

You can even create your own decks easily, and learn whataver you want. I wish an app like that existed when I was still studying, it would have made things much much easier to remember.

Migrating to Jekyll

You might have noticed that the skin of the website changed. Actually, I've updated pretty much every aspect of the stack underneath.

This was a cakePHP blog, it is now a static site generated through Jekyll. This was a custom skin, this is now heavily based on Hyde. This was versioned using Mercurial, and is now using Git (and the source code is available on GitHub). And finally, it was hosted on a shared host on Dreamhost and is now served by a private ks-3.

No more mysql database for the posts, everything is now simple markdown files. This is much more easier to commit and backup, and it is also much more easier for me to write posts, as I only need a text editor.

I had to create an nginx config file to handle all the redirects from the previous urls. At first I thought of hosting it on GitHub Pages, but as my Jekyll install is quite personalized (tags, archives, etc) I needed more flexibility, so in the end I build the website locally and rsync the output to the server.

One of the main features missing from this new version is the ability to leave comments. I'm working on it.

UTF-8 encoding for included .jsp files

Today I had to split a gigantic .jsp file into several smaller files. I used the <@include file="./path/to/file.jsp"> syntax in order to do this.

Unfortunatly, all the included files were displayed with garbage instead of UTF-8 characters.

So I ran the list of usual suspects :

  • Content-Type:text/html; charset=utf-8 is correctly returned by my server.
  • <meta charset="utf-8"> is the first element of my <head>.
  • No data is being fetched from a database, so it cannot come from there.
  • All my files are correctly encoded in UTF-8.

Also, I added a <%@ page contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> as the very first line of my main index.jsp. I also added the following code to pom.xml to make UTF-8 the default encoding : [...] UTF-8

Any UTF-8 in the main index.jsp was fine, but as soon as it was in an included page it was displayed as garbaged. At first, I manually added <%@ page pageEncoding="UTF-8"%> to every included page and it fixed the issue. But as I was dealing with dozen of included files, I needed a more generic solution.

Turns out that I had to edit my web.xml file and add the following configuration :

<jsp-config>
  <jsp-property-group>
    <url-pattern>*.jsp</url-pattern>
    <page-encoding>UTF-8</page-encoding>
  </jsp-property-group>
</jsp-config>

And it worked !