La Vita è Bella

Tuesday, August 12, 2008

Note: how to delete an error calendar in Lightning

As Bug #428274, I can't accept any meeting requests sent to my work mailbox, and have to add the meetings into Lightning manually. This is really annoying. As the bug got fixed, I decided to upgrade Lightning to a 0.9pre nightly to get it working.

After upgrading, the following error dialog will greet me every time I start Thunderbird:

The error message after I upgrade Lightning to 0.9pre nightly

I googled this error message and found that it was caused by the incompatible extension ThunderBirthDay. OK, delete the calendar should fix it. No! The calendar was hide from Lightning's calendar list!

Fine, downgrade Lightning and then remove the calendar should work. But unfortunately, Lightning 0.9 have changed the storage format and can't downgrade to 0.8 anymore.

So how to delete that calendar? Maybe I should delete the calendar direct from Lightning's storage. According to the official FAQ, it's stored as an SQLite database file.

Under Thunderbird's profile directory, I got a "storage.sdb" file. I tried to use the command line sqlite to open it, and it works:

$ sqlite3 storage.sdb 
SQLite version 3.5.0
Enter ".help" for instructions
sqlite> .tables
cal_attachments              cal_metadata               
cal_attendees                cal_properties             
cal_calendar_schema_version  cal_recurrence             
cal_calendars                cal_relations              
cal_calendars_prefs          cal_todos                  
cal_calmgr_schema_version    cal_tz_version             
cal_events                 

The "cal_calendars" table seems to be the one I'm looking for:

sqlite> select * from cal_calendars;
1|storage|moz-profile-calendar://
2|thunderbirthday|moz-abmdbdirectory://abook.mab

Yes it is! so I need to know how to delete that record:

sqlite> .schema cal_calendars
CREATE TABLE cal_calendars (id INTEGER PRIMARY KEY, type TEXT, uri TEXT);

OK, then this should work:

sqlite> delete from cal_calendars where type = "thunderbirthday";
sqlite> select * from cal_calendars;
1|storage|moz-profile-calendar://

It DOES work!

Now my Thunderbird is quiet on starting.

But, the guys in Lightning really should give a chance to delete calendars that aren't compatible. I should file a bug for it. I've filed Bug #450121!



tags: , , ,

00:51:44 by fishy - opensource - Permanent Link

2 comments - no trackbacks yet - karma: 2 [+/-]

Monday, May 26, 2008

Miao cancelled

I've started the Miao project one year ago, aim to build a smart pinyin input method for Mac. But I just got a new job 2 weeks after I started this project. This is quite a busy year, and I haven't really wrote much code for it.

A month ago Yong Sun from Sun begin to port SunPinyin to Mac, and now it's more than just works. I'm satisfied with the Mac port and use it everyday. As the Miao project is scratching my own itch, and I'm not itchy anymore, I should call it a day.

Sorry for anyone who waits for Miao, but I'm not going to reinvent the wheel.



tags: , , , , , ,

20:29:46 by fishy - opensource - Permanent Link

1 comment - no trackbacks yet - karma: 0 [+/-]

Sunday, December 02, 2007

Yet another NP_Trackback hack

I've got an email from my host administrator to warn me that one of my MySQL table consumed lots of system load, and the table is nucleus_trackback.

But I haven't got any "real" trackbacks, so they are all spams, and more accurate, crazy spams, that simply too much to overload my DB.

So I have to wrote this patch to add an option to NP_Trackback: drop blocked trackbacks directly. After enabled, trackbacks that blocked by NP_Trackback (failed spam test or no link) will not be stored into the DB.



tags: , , , , , ,

12:35:40 by fishy - opensource - Permanent Link

no comments yet - no trackbacks yet - karma: 3 [+/-]

Sunday, September 16, 2007

Patches to make NucleusCMS plugins multi-blog ready

I was struggling to find a good multi-blog system to replace LifeType used on buddie5.com in the past few weeks. I've tried Movable Type but didn't feel satisfy with it. Finally I found that NucleusCMS, which is used here, have good support for multi-blog, so I think it's the solution for me.

Although NucleusCMS itself have good support for multi-blog, as it's mainly used as a single blog system like WordPress, nearly none of the plugins considered the multi-blog situation.

So I made patches for the plugins I used, to make them multi-blog ready.

These patches generally move some option from global to blog, so that every blog can have its own setting. And for some plugins that have an admin area, I also filtered the things it can admin to avoid security risk.



tags: , , , , , , , , ,

22:06:35 by fishy - opensource - Permanent Link

9 comments - no trackbacks yet - karma: 14 [+/-]

Sunday, June 10, 2007

Farmr

farmr is a GreaseMonkey script.

It's purpose is to recover some image source URL that was f'ed by some firewall, with the URL with web proxy.

I used the web proxy code from gladder, credit to gneheix.

For Camino users that can't use GreaseMonkey directly, you can use GeekMonkey.

Enjoy it and f' back.



tags: , , ,

11:43:18 by fishy - opensource - Permanent Link

no comments yet - no trackbacks yet - karma: 8 [+/-]

Saturday, May 19, 2007

Add emacs mode line support to vim, and call for help

Different editor configurations, especially tabstops are always pain for co-work. So if everyone uses vim, you can specify some vim instruction to override one's vim configuration in your file, just like:

// vim:tabstop=4:

And if everyone uses emacs, you can also specify emacs mode line like:

// -*- tab-width: 2 -*-

But what about make vim to read emacs mode line? I've wrote a script to do so.

As I didn't use emacs at all, I don't know which instructions can be specified in the emacs mode line. I just wrote a handler for "tab-width" as an example. If you are familiar with both emacs and vim, please help me to add more handlers into this script.

After more handlers added, I'll submit this script to vim.org.



tags: , , , ,

02:25:41 by fishy - opensource - Permanent Link

2 comments - no trackbacks yet - karma: 46 [+/-]

Monday, May 14, 2007

Miao: (will be) a new smart pinyin input method for Mac OS X

Why another pinyin input method?

The answer is simple: the current pinyin input methods on Mac doesn't satisfy me. I'm going to scratch my own itch :P

ITABC (comes with Mac) and Pinyin Module in OpenVanilla isn't a smart input method; QIM is smart but it's a shareware, and a expensive shareware (USD 19.99 or RMB 69.00, but only for one major version free update); FIT is smarter than ITABC and free (for charge), but is not smart enough and I don't like some of its feature but can't turn them off.

Miao will be a smart pinyin input method, designed for people who likes to input a whole sentence once. It will learn user's accustoming and finally become a essential tool in inputing (after some training).

The idea and feature

I won't focus on pre-train dictionaries, just like Sogou Pinyin or Google Pinyin. My focus will be on "learning"

For each sentence you input, it will record the words within the sentence, including continuos words and non-continuos words, and calculated for probability.

Continuos word probability will be used to auto-learn new words, that is, if there's a high probability that two known words will comes together, they will be formed as a new word.

Non-continuos word probability will be used for candidate word sorting. The word with the highest probability will get ordered first. As a instance, for the pinyin word "yaoming", if the sentence comes with "huojian"(火箭/Rockets), "maidi"(麦迪/McGrady), it's more likely to be "姚明"(Yao Ming the NBA player); If the sentence comes with "can"(惨/misery), it's more likely to be "要命"(Kill me!).

The license

It may be licensed under GPL or BSD license, it's not decided yet. But I can assume that it will be certainly free, as freedom!

About the name

"Miao" is the pinyin of the Chinese character "", which just like "meow" in English, is "the characteristic crying sound of a cat" (from Oxford American Dictionaries).

It's a pinyin input method, so I choose a pinyin word as its name :P

Other informations

I should write it as a module for OpenVanilla, instead of stand-alone. The reason is that I'm not going to reinvent the wheel. I want to focus on the learning algorithm, but not the system interfaces. And this may make it easier to port into other platforms, for example Linux.

The project homepage will be http://oaim.yhsif.com. I'll start it soon, any contribution, e.g. codes, ideas or artworks, are appreciated.



tags: , , , , ,

16:30:55 by fishy - opensource - Permanent Link

7 comments - 1 trackback - karma: 5 [+/-]

Sunday, March 11, 2007

My first ever Obj-C hack: Google Reader Notifier

UPDATED: Troels Bay have use another way to do it, please wait for his official build :P

Google Reader Notifier by Troels Bay is a great open source application that provide a desktop notifier for Google Reader, the online feed reader, and also a feed subscriber. As I'm using Camino as my browser, which didn't have a build-in RSS support, I need it even more to subscribe feeds to Google Reader with one click. (not just "notifier" :D )

But when subscribe with preview, if there's a "?" in the URL, the problem is that Google Reader will ignore the part after "?". So that for example my photos on Flickr, "http://api.flickr.com/services/feeds/photos_public.gne?id=76236359@N00&format=rss_200" , will be recognised by Google as "http://api.flickr.com/services/feeds/photos_public.gne".

So I wrote this patch to escape URL before submit to Google.

 1 --- Google Reader copy/GRController.m   2007-03-11 18:45:56.000000000 +0800
 2 +++ Google Reader/GRController.m        2007-03-11 18:49:46.000000000 +0800
 3 @@ -1610,7 +1610,15 @@
 4  
 5         if ([[prefs valueForKey:@"dontVerifySubscription"] boolValue] != YES) {
 6  
 7 -               [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[[NSString stringWithFormat:@"%@://www.google.com/reader/preview/*/feed/", [self getURLPrefix]] stringByAppendingString:url]]];                    
 8 +               NSMutableString * escapedUrl = [NSMutableString stringWithCapacity: ([url length]*3)];   // for the worst case the length will growth to 3 times
 9 +               [escapedUrl setString:url];
10 +               [escapedUrl replaceOccurrencesOfString:@"?" withString:@"%3F" options:0 range:NSMakeRange(0, [escapedUrl length])];
11 +               [escapedUrl replaceOccurrencesOfString:@"&" withString:@"%26" options:0 range:NSMakeRange(0, [escapedUrl length])];
12 +               [escapedUrl replaceOccurrencesOfString:@":" withString:@"%3A" options:0 range:NSMakeRange(0, [escapedUrl length])];
13 +               [escapedUrl replaceOccurrencesOfString:@"/" withString:@"%2F" options:0 range:NSMakeRange(0, [escapedUrl length])];
14 +               [escapedUrl replaceOccurrencesOfString:@"=" withString:@"%3D" options:0 range:NSMakeRange(0, [escapedUrl length])];
15 +
16 +               [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:[[NSString stringWithFormat:@"%@://www.google.com/reader/preview/*/feed/", [self getURLPrefix]] stringByAppendingString:escapedUrl]]];                      
17                         
18         } else {
19  



tags: , , , , ,

21:13:23 by fishy - opensource - Permanent Link

no comments yet - no trackbacks yet - karma: -3 [+/-]

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):

  1. mysqldump -h host -u username -ppassword database --default-character-set=latin1 > dump.sql
  2. Edit dump.sql, on Line 10, replace "latin1" with "utf8"
  3. 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: , , , , , , , , ,

22:47:17 by fishy - opensource - Permanent Link

no comments yet - no trackbacks yet - karma: 7 [+/-]

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.

Before:
A patch for Gecko browsers on Mac: Aqua buttons, before
A patch for Gecko browsers on Mac: common buttons, before

After:
A patch for Gecko browsers on Mac: Aqua buttons, after
A patch for Gecko browsers on Mac: common buttons, before

I didn't write this patch. I just found it and made it easier to use.



tags: , , , , , , , ,

20:04:14 by fishy - opensource - Permanent Link

no comments yet - no trackbacks yet - karma: 6 [+/-]

A blog about open source, patches, thoughts and geeks