If asked the question, “What is the difference between UTF-8 and Unicode?”, would you confidently reply with a short and precise answer? In these days of internationalization all developers should be able to do that. I suspect many of us do not understand these concepts as well as we should. If you feel you belong to this group, you should read this ultra short introduction to character sets and encodings.
Converting a mysql database from latin1 to utf8
This week I successfully converted Virtual Managers mysql database from latin1 (aka. iso-8859-1) to UTF8. Since I guess I’m not the last person to do this, I’ll here share how I did it.
Excluding gems in Textmate
I’ve been playing around with Rails 3 lately. Rails 3 uses Bundler which installs all your depending gems inside your app. This does not work very well with Textmate’s default behavior. Textmate will have to search through all gems each time you perform a “Find in project” (Command + Shift + F) or “Go to file” (Command + T) because the gems are inside your project. Due to the many files this is pretty slow, and makes it harder to find what you are looking for.
One simple way to solve this is, is to ask Textmate to exclude the vendor dir. You can do this in Preferences > Advanced. Here, just add ”|vendor” to “Folder pattern” and restart Textmate.
Textmate will now disregard the vendor directory entirely. Problem solved!
If you know a better way of doing this, please drop me a line :)
CSS naming based on logical entity
Too many web developers decide CSS class names based on what style the class is representing. This is wrong, and should be avoided! Let me explain why.
Pressure kills creativity
You may call me a nerd or anti-social all you want, but I just love spending an entire weekend coding away while immersing myself in my favorite technologies. The primary reason being, that it is one of the absolute best way to lure out my creativity!
Unobtrusive Javascript in Rails using Prototype
The idea with unobtrusive Javascript in to separate markup (HTML) from behavior (Javascript), just as CSS help us separate styling from markup. By disallowing Javascript in your markup, you gain a better overview of where to find what in your code base. Behavior goes to static javascript files and markup goes to template files! There are several other benefits to this technique that I will not be covered here.
As you might have heard Rails 3 is actually adopting this idea, which will spare us for lots of ugly repeating Javascript code when using Rails form and link helpers. The release of Rails 3 is still far away, so in this article I’ll show you how to implement the technique in Rails 2.
Javascript Bubbling
While working on my new game I’ve been doing a lot of Javascript code. In my quest to keep everything modular and decoupled my javascript objects often delegates some kind of responsibility to child objects, which in turn might delegate the responsibility to their child objects forming a kind of tree structure. I’ve made sure that the child objects do not know anything about their parents to decouple even more. This is implemented via the observer/subscriber pattern. The child objects just send out a notification when a certain event happens and the parent receives this if they’ve subscribed to the sending child. This results in a very flexible decoupled design – yummy!
However, this design turned out to yield quite some code duplication which needed to be cleaned up.
Ruby's ERB templating system - how does it work?
All Rails developers have used the ERB templating system. That is what enables us to mix html and ruby in our view files. But how does it actually work? I found out today, and thought I’d share my findings.
Teach to learn
In the world of software development technology is pushed forward at an extreme pace. Of this reason, all clever developers acknowledge the significant value of continuous learning (which I talked about in Known your weaknesses). Those who are the best learners, eventually ends up being the best in their field. Simple.
In this article, I want to share a thought about why teaching optimizes your learning.
Loving your job
An old friend contacted me the other day and told he was about to implement a new business idea he had for a web app. He asked me whether he should implement the app using an older weaker programming language he knew well, or use a new cool interesting technology he did not knew well.
Fighting broken windows
In the book “The Pragmatic Programmer” Andy Hunt and Dave Thomas applies The Broken Window Theory to software development. The idea is that your code base has a much higher probability of rotting, if you do not fix all “broken windows” (poor code, bad design) as fast as possible. The Pragmatic Programmer suggests you should fix broken windows immediately after discovering them. This is hard to do without suddenly having too many balls in the air. In this article I will share a very simple, yet extremely useful idea on how to fight broken windows easier.
Know your weaknesses
In this post I will go through some of the bad characteristics of the typical programmer stereotype. By being aware of our weaknesses, we stand a better chance of reducing them. If you are not a programmer, I encourage to read on anyway. The basic principles apply to most professions.