La Vita è Bella
Friday, January 26, 2007
MySQL collation charset problem and patch for NucleusCMS and WikkaWiki
First of all, I must say MySQL sucks!
As from MySQL 4.1, if the database default charset is UTF8 but the default charset setting in my.cnf is not UTF8, you must do a "SET NAMES UTF8" query after connection, to make sure that in this mysql connection, all query will be handled as UTF8. otherwise seems that it will use latin1 as default.
If the "SET NAMES" isn't queried, the articles and comments won't be malformed, but the data that stored in MySQL database isn't actually in UTF8 encoding, so that for example mysqldump, or phpmyadmin, won't get the right data.
So what we need to do is check database's charset setting, and send a "SET NAME" query to ensure we're using the database's charset setting.
I've found that LifeType did this thing, so I copied its detecting code and made patches for NucleusCMS and Wikka Wiki (and also my custom homepage for LifeType, of course!).
But before downloading the patches, I should tell you that:
First, you MUST convert your database. Cause before you patch NucleusCMS or Wikka Wiki, your articles, comments, etc. that already posted, was stored in the old way in the db.
To do that, follow the following steps (this is in case the my.cnf indicate "latin1" but your database was in "utf8", if you're using other charsets, modify them):
- mysqldump -h host -u username -ppassword database --default-character-set=latin1 > dump.sql
- Edit dump.sql, on Line 10, replace "latin1" with "utf8"
- mysql -h host -u username -ppassword database < dump.sql
Second, you must ensure that in your database, ALL charset settings are set to "utf8". The word "ALL" means databases, tables and fields.
Finally, here're the patches: for nucleus, for wikka, released under GPL. WARNING: Use it on your own risk, and make backup before patching.
tags: wikka, wiki, nucleus, blog, utf8, mysql, patch, charset, use, names
22:47:17 by fishy - opensource - Permanent Link
Tuesday, January 23, 2007
A patch for Gecko based browsers on Mac for buttons
Gecko based browsers, including Mozilla Firefox, Mozilla Camino, Mozilla Seamonkey, optimized 3rd-party builds of Firefox and etc. , didn't display buttons on webpages well on Mac OS X.
For aqua buttons, that shown in Camino and some optimized 3rd-party builds of Firefox, the CJK buttons often be malformed and cause you can't see the text on the button well. For common buttons, they're just ugly.
I've found a hack through the internet, and I'm not so sure what did it actually do (seems to be some dirty tricks), but it works. So I cut off some unnecessary codes and made this patch. To use it, just execute the following command under terminal (Terminal.app or iTerm.app, replace "/Applications/Camino.app" to the path of the app you want to patch):
cd /Applications/Camino.app/Contents/MacOS/res/
patch -i /path/to/moz-forms.patch
And it's done.
I didn't write this patch. I just found it and made it easier to use.
tags: mac, osx, patch, cjk, button, gecko, firefox, camino, seamonkey
20:04:14 by fishy - opensource - Permanent Link
Sunday, January 21, 2007
Trying Camino
Camino is superb fast. Much much faster than Firefox and maybe a bit faster than Safari.
Compare to Firefox, it comes with some good system integrations, including Address Book integration, Keychain Access integration, etc. And compare to Safari, it's much closer to Firefox, it also have a "about:config" thing (though a little different from Firefox), and a powerful ad-blocking engine.
So I'm going to give it a week's trial, to see if I can be used to it.
Although it's close to Firefox, it didn't have extensions. So there's something I missing in Firefox:
- It can't force links that open a new window to open in new tab. I can use about:config to set "browser.link.open_newwindow" to "1" to disable links that opens a new window, but can't use a new tab instead. Anyway, this is acceptable. At least they won't open lots of new windows to annoy me.
- I can't type a site name (e.g. "google" ) and press cmd+enter to automatically surround it with "www." and ".com", this will open it in new tab and use "I'm feeling lucky" search. So I must type more words to input a address.
Keyboard short-cut is different from Firefox, it mixed some Firefox short-cuts and Safari short-cuts up. I don't like this. I prefer a configurable keyboard short-cuts. Maybe I can configure it in System Preferences?UPDATED: Oh yes, I can configure them in System Preferences. This makes me feel much better.- I can't specify the text encoding of the keyword in the search tool-box. Some search engines in China only accept GBK keywords but Camino can only encode keyword in UTF-8.
- Lack of spell checkers. It can't use the system spell check for standard text editors (cause it didn't use the standard text editor?), nor the spell checker provided by Google Toolbar for Firefox or Firefox 2.
Anyway, a impressive thing is that the build-in ad-blocking engine is powerful, and the default black-list is very useful that it filtered out almost all the ad from the pages I visited. And if the black-list isn't powerful enough, I can edit it myself.
tags: camino, firefox, mac, osx, safari, adblock
02:48:09 by fishy - mac - Permanent Link
Thursday, January 11, 2007
Mac is for geeks?
Or at least, Skype for Mac is for geeks? There are some cool stuffs in Skype for Mac, but not available on other platform versions of Skype.
- In the chat style tweak window, the chat example is from George Orwell's 1984. Maybe because of Mac begins from 1984?

- In the newest beta (currently) version, the history events was brought on and off with a cool effect, similar to the water wave effect of dashboard.

tags: skype, mac, 1984
22:09:34 by fishy - mac - Permanent Link
Friday, January 05, 2007
Selective unlink script (to uninstall TeXLive)
In fact, to uninstall TeXLive should be very easy: "rm -Rf /usr/local/texlive", that's all.
But things are sometimes not so easy. If you've chosen to make symbolic links to your system path (/usr/bin) during the installation, like I had, then you have to unlink all the links TeXLive created.
It's hard to do that manually, so I wrote the following script. You just need to run it under your /usr/bin directory and it will unlink all links that pointed to /usr/local/texlive.
1 #!/bin/sh
2
3 tlprefix="^/usr/local/texlive/"
4
5 for file in *; do
6 if [ -L ${file} ]; then
7 link=`readlink ${file}`
8 tllink=`echo "${link}" | grep "${tlprefix}"`
9 if [ -n "${tllink}" ]; then
10 echo "going to unlink \"${file}\" that links to \"${link}\"..."
11 unlink ${file}
12 fi
13 fi
14 done
It unlinked 240 symbolic links from my /usr/bin directory, horrible! I'll never choose the "make symbolic links to your system path" option again during the installation of TeXLive.
tags: texlive, unlink, bash
23:59:57 by fishy - latex - Permanent Link






