dotfiles or easily manage your shell environment

Like many terminal geek, I have a bunch of dot rc files allowing me to configure my environment. While this is a very powerful way to setup an environment, it is painful to log in a machine and set it up like you are used to, you often discover too late your favorite alias is missing.

I found a nice way to manage this thing by browsing the github account of one of a man coming frequently to the Tours Java User Group meetings. It is commonly called dotfiles and can not be better named I found.

I forked the repository to customize it to my needs, it is now possible to define aliases and to configure the shell on a per machine basis.
To install, you will only need ruby and rake (manual install is also possible by symlinking the files) :

  • cd; git clone git://github.com/CedricGatay/dotfiles.git .dotfiles
  • cd .dotfiles; rake install
  • logout and login, or source your .zshrc / .bashrc

  • Please notice that I am a zsh user, the bashrc file provided should work but it will surely need some fixes. There is no better way than digging into the source to understand and adjust it.

Convert a mySQL Database from latin1 to UTF-8

A frequent problem when it comes to internationalisation is proper handling of different charset. When you’re using Java and Maven it is relatively easy to set up source encoding to UTF-8, but the frequent point of failure is in the SQL database.


If you use mySQL, and you have latin1 tables, but you should have UTF-8 instead, use this little script to convert from latin1 to UTF-8 :

mysqldump --user=${USER} --password=${PASS} --default-character-set=latin1 --skip-set-charset ${DATABASE} > dump.sql;
sed -r ‘s/latin1/utf8/g’ dump.sql > dump_utf.sql
mysql --user=${USER} --password=${PASS} --execute=”DROP DATABASE ${DATABASE}; CREATE DATABASE ${DATABASE} CHARACTER SET utf8 COLLATE utf8_general_ci;”
mysql --user=${USER} --password=${PASS} --default-character-set=utf8 dbname < dump_utf.sql

Generally speaking, don't hesitate to always put the --default-character-set=utf8 on all the mySQL commands you execute.
Don't forget to add at the end of your jdbc connection url the following parameters : "useUnicode=true&characterEncoding=UTF-8" to ensure you connect using UTF-8.

Alerta-JUL – Elegant log tailing

Classic tailing

In my day to day activities, there is one thing I do everytime and I think every developer does : I tail the logs. The problem with logs checking is that you are rapidly facing a huge file, and the classic tail -f is not enough. The sad part of log tailing is that you only have monochrome logs, without any colouring of any kind helping you identify critical lines against more common ones.
Continue reading

OS X Lion – Remove an app from Launchpad

General Launchpad thoughts

I continue my tips regarding OS X Lion. As I said in my OS X Lion walkthrough, Lion come with a very iOS-ish application launcher : Launchpad. Out of the box, it is automatically populated with every application you have and application you download from the Mac App Store are added there too.

Although I keep on thinking it is a useless feature for power users, newcomers will surely find this useful, and it will help switchers to find their applications. As I was cleaning my machine I tried to rearrange Launchpad by making folders and then I discovered that you can’t easily remove a shortcut to an application (except the ones coming from the Mac App Store which are uninstalled when you remove their icons).

Let me remove things !

By digging around, I found that Launchpad stores its preferences in a SQLite database, that you can explore and manipulate using the sqlite3 command line program.

Please notice that the steps described here might make your Launchpad unusable, so please backup every file you change in case something goes wrong !

Update ! Easy technique, use Launchpad-Control which is a preference pane allowing to visually hide / show icons on Launchpad. I detail here the step involved for the records.

Continue reading

OS X Lion – disable special char popup

One thing annoying in Lion is the popup appearing when you long press a key (similar to the one present in iOS showing special characters).

I found a way to disable this by issuing a simple Terminal command :

defaults write -g ApplePressAndHoldEnabled -bool false

Replace false with true in this command if you want to bring it back, you might need to exit and relaunch an app for the parameter to take effect.
If you want to discover more parameters, don’t hesitate to dig into built-in properties, that’s the way I found this tip (the -g flag tells to lookup in the globaldomain)

defaults read [-g]