Pickled object is still not ASCII-safe with Protocol 0

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Today, Last Tweets run into another issue. It's about the encoding

d = {'msg': u'Is still rather 17\xb0 in Auckland.Brr'}
print d['msg']
# Is still rather 17 in Auckland.Brr
print pickle.dumps(d, 0)
# "(dp0\nS'msg'\np1\nVIs still rather 17\xb0 in Auckland.Brr\np2\ns."

As you can see \xb0 is not in ASCII. If you assign the pickled result to a db.TextProperty[link], you will see an track back like

pickle.dumps(d, 0).decode('ascii')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'ascii' codec can't decode byte 0xb0 in position 34: ordinal not in range(128)
TextProperty will try to decode with ASCII decoder if you assign a str.

A bigger character set can resolve this issue:

print pickle.dumps(d, 0).decode('latin-1')
# u"(dp0\nS'msg'\np1\nVIs still rather 17\xb0 in Auckland.Brr\np2\ns."
to_db = pickle.dumps(d, 0).decode('latin-1')
print pickle.loads(to_db.encode('latin-1'))
# {'msg': u'Is still rather 17\xb0 in Auckland.Brr'}
print pickle.loads(to_db.encode('latin-1'))['msg']
# Is still rather 17 in Auckland.Brr

An working code should look like:

model.my_text = db.Text(pickle.dumps(my_dict), encoding='latin-1') 
When this model try to set my_text, it sees a type db.Text object. It won't try to decode. I think you can also give an type unicode object directly (not tested):
model.my_text = pickle.dumps(my_dict).decode('latin-1') 

ATI Driver for X Server 1.5 and Fedoras X server on VT1

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
This week these two things caught my eyes. Actually, both are not latest news, but I noticed them just now.



ATI Driver for X Server 1.5 (X.Org 7.4)



Since Fedora 9 -- IIRC, started shipping with X Server 1.5RC5 -- I started to use Mesa not ATI's driver since Mesa works normally with Desktop Effects. Few days ago, I installed WINE again. My repos include livna and freshrpms. Yum also installed ATI Driver from freshrpms as dependency, but the driver failed to build at booting.



Later, I finally tried to find out what is going on, and realize Linux users do not have a working ATI driver for X Server 1.5 for months. Until two weeks ago,

Canonical Publishes ATI Catalyst 8.10 Beta. Note that you can not download it from official page, which still support up to X.Org 7.3 only.



That driver doesn't seem to work properly on Fedora 9, even with a patch, you can read this thread.



Fedora's X server would be moved to VT1?


This may happen on Fedora 10. I read this firstly on LWN.net. It sure started flame wars (X on tty1 in Rawhide/F10 and Reasons to preseve X on tty7 ). But I really don't mind, when I use a Linux distro, I don't want to change default settings too much or too many. Distros are usually heavily moded, even they provide some degrees of custom abilities. As long as I can live with default settings, I would stay.



This decision seems to be made already and 2008-10-28 is the day of Final Development freeze, you can see a task in BetterStartup:

If rhgb is in the kernel commandline, switch mode in initrd, use drmfb and then GDM on vt1
I don't mind. Just give me a stable and fast Fedora.

Small Problem when Installing IE6.0 with CrossOver Professional

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Yes, I got it free on 10/28. I have installed Steam with CS:S using CrossOver Games, but WINE seems to need ATI's driver in order to support Open GL, the opensource Mesa doesn't seem to work. And right now, only, officially, Ubuntu has a working ATI driver for X.org 1.5. Hope Fedora 10 will have that, too.



Anyway, I tried to install IE6 on x86_64 today, and CrossOver didn't aware that there is a 32 bit library missing. I got the following log when installer tried to install Windows OLE components (part2) , instead:

err:module:load_builtin_dll failed to load .so lib for builtin L"winex11.drv": libXxf86vm.so.1: cannot open shared object file: No such file or directory
It's easy to resolve, just yum install libXxf86vm.i386, or whatever command to install 32 bit library of libXxf86vm on your distro.



By the way, I also tried the CrossOver Chromium. That is really a garbage to me. Some buttons or input box is ugly and transmission via HTTPS isn't functional.



With CrossOver, you almost only need to click on the Next or OK buttons.

Unpickling with Google App Engine

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
While I was developing Last Tweets, I encountered a problem on production server, which is never happened on development server. The traceback looks like

Traceback (most recent call last):
File "/base/python_lib/versions/1/google/appengine/ext/webapp/__init__.py", line 499, in __call__
handler.get(*groups)
File "/base/data/home/apps/lastweet/1.12/index.py", line 77, in get
'tweets': u._tweets_,
File "/base/data/home/apps/lastweet/1.12/lastweet/user.py", line 47, in _get_tweets
return pickle.loads(self.tweets)
File "/base/python_dist/lib/python2.5/pickle.py", line 1367, in loads
return Unpickler(file).load()
File "/base/python_dist/lib/python2.5/pickle.py", line 852, in load
dispatch[key](self)
KeyError: '\x00'
Where u._tweets_ is a property of data model class, defined as
_tweets_ = property(_get_tweets, _set_tweets)
A side note: when you need your own property (method or attribute), you need to prefix with an underscore _. Or GAE treats it as part of data. Even you have prefixed an underscore, if the name (_tweets) is same as a data field (tweets) and with property functions (_get_tweets), that may cause endless calls.

This error happens on when I use _get_tweets on production server, it does things like:
import pickle
...
return pickle.loads(self.tweets)
Then I got KeyError. I resolved this with:
return pickle.loads(str(self.tweets))
It's dirty. I still don't know what Google did to pickle module. I got the pickled data and tried to unpickle on my computer, the result is correct. So that may only be something in unpickling. By the way, the tweets is a TextProperty.

Where is the CAT?

This post was imported from my old blog “Blogarbage” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
This is a real experience, happened last afternoon. Here is how it goes:
I went out of my room and tried to make some food for lunch. Later, I took my lunch and sat on a stool by table in the living room. I need to sit on stool in order to eat comfortable. If I sit on sofa, then the table would be too low. There is a small space between me (where I sat on stool) and sofa.

While I was eating, I wonder where is the cat? You know cat is quite good to hide. After finished, I couldn't resist finding him. So I checked up his eating place, top of washer, kitchen, small spaces between plants, and my wardrobe.

That cat is really like my wardrobe. I know this time he didn't have a chance to sneak into there, but I have to check again. Cat is good, you know.

But I can't find it anywhere, at least I believe I had searched all places which he have hidden.

I sat on the stool again, just thought how I couldn't spot it? Somehow, I turned my head back and looked down. Yea, he was right there and sleeping in that small space! Unbelievable! I missed seeing it twice. Every time when I sit on the stool, I faced towards where the cat is. Must be his fur color.
He beat me again

Cat:1, Human:0

Last Tweets

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.


Last Tweets is my latest Google App Engine application. Basically, it will try to find out your last tweets (@reply) to your friends. You can also subscribe to the results via email, then you no need to check up every a while. BUT this is new, you could encounter an ERROR very easily, please send me the errors you see.



Please keep these in mind:

  • an Twitter with 100 friends, currently needs nearly 10 minutes to update at least., please be patient.

  • Twitter account can't not be protected.

The code is open source (GPLv3), you can read more at LasTweet.



Tweet often to your friends!

A note of GAE Mail API about Sender and Recipient addresses

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
On Development Server

When I use Mail API with sendmail using the example as in Sending Mail doc, the recipient has to be pure email address:
cannot be
User <[email protected]>
Or sendmail complains:
INFO     2008-10-29 06:57:53,884 mail_stub.py] MailService.Send
INFO     2008-10-29 06:57:53,884 mail_stub.py]   From: [email protected]
INFO     2008-10-29 06:57:53,885 mail_stub.py]   To: User
INFO     2008-10-29 06:57:53,885 mail_stub.py]   Subject: Your account has been approved
INFO     2008-10-29 06:57:53,885 mail_stub.py]   Body:
INFO     2008-10-29 06:57:53,885 mail_stub.py]     Content-type: text/plain
INFO     2008-10-29 06:57:53,885 mail_stub.py]     Data length: 261
/bin/sh: -c: line 0: syntax error near unexpected token `newline'
/bin/sh: -c: line 0: `sendmail User <[email protected]>'
ERROR    2008-10-29 06:57:53,927 mail_stub.py] Error sending mail using sendmail: [Errno 32] Broken pipe
I think this can be fixed by patching the mail_stub.py.

On Production Server

Sender must be:
The sender must be the email address of a registered administrator for the application, or the address of the current signed-in user.

Setting up a (Git) mirror on github for a Google Code project (Subversion)

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
I created a project on github for mirroring my project on Google Code. I am new to git, so maybe there is a better way to do this.

First clone the Subversion repository and push to the Git:
git svn clone https://foo.googlecode.com/svn/ git-foo
cd git-foo
git remote add git-foo [email protected]:username/foo.git
git push git-foo master
After committing in the Subversion repository, run
cd /path/to/git-foo
git svn fetch
git svn rebase
git push git-foo master

Microsoft Paint{ with WINE,-alternative} on Linux

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Original Paint



I am a GIMP user, wouldn't try Paint or Paint-like before. I read a tweet today about this, so I give it a try.



First of all, let me quote this:

Original is the best -- Yu-Jie Lin.
Yes, I couldn't agree with this any more because that is said by me. Anyway, if you are the MS Paint fan, then run it with WINE. I have done this, the steps is quite easy:

  1. Installing WINE

  2. Copy paint.exe and mfc42u.dll from installed Windows system. Or, extract them from Windows Setup CD. You will need cabextract to uncompress the paint.ex_ and mfc42u.dl_ files.

  3. (Optional) Copy gdiplus.dll to ~/.wine/drive_c/windows/system32. I don't see this on Windows Setup CD. If you don't have gdiplus.dll, then you can only save/load BMP format.


  4. Running paint.exe.

Here is the screenshot of my recent masterpiece :) created in MS Paint:

You can download this PNG image, I wonder if is anyone interested. I run Paint on WINE-1.1.5 and Fedora 9. The dlls are from Traditional Chinese Windows, the paint.exe is from Dell Windows Reinstalling Setup CD. Both are Windows XP. I extracted paint.exe from Setup CD because the Chinese characters can't be display, they all are displayed as blocks and I don't know how to fix that.



Paint-alternative on Linux



Here is a list of Paint-alternative applications on Linux, maybe they are not really like MS Paint. Just give them a try.

None of them I tried, so you are on your own to discover.



Lastly, when I searched for those alternatives, I found this testiminal video via this Uncyclopeida page:



Enjoy it!

I got HACKED (in a dream)

This post was imported from my old blog “Blogarbage” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Not really! :) It's a last night dream. I don't know why would I have a dream like that besides that SXXT happened.

The dream was like this:
I am in a computer class room (not a student for years) and suddenly a jerk sitting next to me shows me his screen. Somehow, he can connect to my computer with VNC and he is messing up my files. He uses a mac and I use a Linux distro.
If I recall correctly, I never ran a VNC server on my current computer, but that may be a computer of the class room not mine.

Do you think that was weird enough? No, that was not the weirdest part.
After I realized the situation, I immediately arrested him with the evidence of hacking and all classmates as eyewitnesses. I reported to the instructor, then I insisted to call police and to file a charge.
Was this dream trying to tell me something?

More about Blip.fm

This post was imported from my old blog “Blogarbage” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
I think I have some misunderstanding about Blip.fm. By its name, it's tend to compare to Last.fm. As far as I know, it's ok to compare Last.fm with Pandora. But it's not the case for Blip.fm.

Twitter, instead! Yes, Twitter. I have strong feeling for the word blip after hours, it's like tweet. How come? On Twitter, you simply tweet what you think with text. On Blip.fm, you can tweet (blip) with text and a song or music as well. So, when you blip, it's not all about the song but why you choose that song and what you think. And that's why Blip.fm also has @reply feature. Moreover, you can blip a song many times.

What do you think?

About Blip.fm

This post was imported from my old blog “Blogarbage” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
I just signed up not long ago. So, what is this "blip" thing all about? I am not so sure but from my understanding by using it, the music you will be listening to are user-uploaded music files. I think if they were not, then there should not be so many duplications.

First you enter artist name or song name to search for songs. You can preview to check up if that is right song you expected. You can also view a blip-stream on front page (just below the search box) which is made of many blips from users.

What does this "Blip" mean? You can blip a song, which is like a announcement saying you have listened to the song. Of course you don't have to, but that would be strange, wouldn't? Okay, when you decide to blip a song, you also have to write a message within 150 characters, whose content is about the song. Note that you must blip a song in order to put the song into your Blip.fm profile (For example: http://blip.fm/livibetter) a.k.a. Blips list at the sidebar. For the sake of social thing, you must blip some songs, or who would be interested in an empty profile page?

However, you can put any song into your Favorite list, just click on the star-shaped icon at a blip.

Blip.fm supports integration with Twitter, FriendFeed, ..., and Last.fm. Although, some are not really ready. But most important thing is it can scrabble Last.fm and Last.fm scrabble your music. No need to reinvent the wheel. Pretty clever, isn't? You can then blip those songs.

So far, it doesn't have many song. But it's quite stable, no, I haven't activated the beta testing.

Did anyone know if it has something about blip.tv? and when will FriendFeed officially support it?

Backing up your Blogger templates

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
I wrote a simple Python script which utilizes gdata-python-client to download the layout templates of your Blogger blogs. You can read and download BackupTemplate.py.



It is easy to use, just make sure you have gdata-python-client on you computer. You will be prompted for your email and password. Here is a screenshot how it is working:



Layout templates of all blogs will be saved in current directory with filename like

blogId-blogName-YYMMDD-HHMMSS.xml
Any suggestions to this Python script will be welcomed.

When SXXT happens

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
When SXXT happens, it's time to change your password.

How so? Yesterday, I happily committed my code, which is for backing up layout templates for blogs on Blogger.com. After committing done, I saw my Google password when switched back to editor. Anyone who is in normal mental state would loudly yell with "SXXT!" or "FXXK!". I did. I forgot to empty the strings, which have my gmail and password before committed. Actually, I thought I did, because I got prompted for my email and password, therefore I believed that I had emptied two strings. Obviously, I didn't.

The Subversion repository is at Google Code hosting. I deleted the project (sort of making project private) and requested a reset to my repository. Meanwhile, I used svnsync to retrieve all revisions to my computer. After resetted, I tried to sync back without the idiot revision, but I can't get the job done. Later, I manually re-committed the rest of revisions.

From this incident, I have learnt:
  • Never allow to put password or other sensitive contents in source, must use a configuration file with secured permission in home directory or similar way if needed
  • Always check status and diff before committing
  • Always grep the diff before committing
  • If SXXT still happens, do not reset if there is only one password involved. Changing the password, instead, would be much easier; and removing the SXXT and committing again
Even you can perfectly "rollback", you still can not assure that no one has checked out your SXXT as their juicy fruit or no bots has crawled your SXXT and indexed it.

When SXXT happens, you can appreciate it for reminding you of changing password and the opportunity to have new blog post to share your SXXT mood.

Webmaster Tools Developers Guide - Python (Contributed Doc)

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
About this documentation

Since this documentation is not written by Google neither is the Python client package for Webmaster Tools API, you may encounter problems. Please leave you comments here, if they are for this documentation; for the Python client package, you can discuss at Issue 176 or this group.

More information you can have:
The author of this documentation and the Python client package is Yu-Jie Lin. This documentation is in the public domain.

Last updated: 2008-10-20

Getting started

Using this Python client library should only need one import:

import gdata.webmastertools.service

Authenticating to the Webmaster Tools service 
All requests are sending via a GWebmasterToolsService object.

AuthSub proxy authentication
(Untested)

ClientLogin username/password authentication
The following example shows how to use ClientLogin:

client = gdata.webmastertools.service.GWebmasterToolsService()client.email = '[email protected]'
client.password = '12345678'
client.source = 'Google-PythonWebmasterToolsSample-1.0')
client.ProgrammaticLogin()

Read more about Account Authentication for Installed Applications.

Managing sites
Retrieving a list of sites

To get a list of sites, invoke GetSitesFeed method of GWebmasterToolsService object. For example:

feed = client.GetSitesFeed()
for entry in feed.entry:
    print entry.title.text

The return value is a SitesFeed object.

Adding a site

To add a site, invoke AddSite method of GWebmasterToolsService object with being added site URI as the only parameter. For example:

entry = client.AddSite('http://www.example.com/')
print entry.title.text

The return value is a SitesEntry object.

Verifying site ownership

To verify a site's ownership, invoke VerifySite method of GWebmasterToolsService object with parameters, site URI and verification method. Accepted verification methods are htmlpage and metatag. For example:

client.VerifySite('http://www.example.com/', 'htmlpage')

In order to verify, the requirement of verifying must be done before invoking VerifySite method, which is creating a html page with specific name or adding a specific meta tag to the response at site URI. For what to create or add, check the entry.verification_method in SitesFeed.entry object.

Deleting sites
To delete a site, invoke DeleteSite method of GWebmasterToolsService object with being deleted site URI as the only parameter. For example:

client.DeleteSite('http://www.example.com/')

Managing site settings
Managing site settings require the site verified.

GeoLocation
Accepted locations are listed in here. Example code:

client.UpdateGeoLocation('http://www.example.com/', 'US')

Read More information about setting a geographic target.

Crawl rate
Accepted rates are slower, normal, and faster. Example code:

client.UpdateCrawlRate('http://www.example.com/', 'normal')

Read More information about crawl rate.

Preferred domain

Accepted preferred domain setting are none (default), preferwww  (www.example.com) and prefernowww (http://example.com). Example code:

client.UpdatePreferredDomain('http://www.example.com/', 'preferwww')

Read More information about setting your preferred domain.

Enhanced image search

Accepted settings are true and false. Example code:

client.UpdateEnhancedImageSearch('http://www.example.com/', 'true')

Managing Sitemaps
Retrieving a list of submitted Sitemaps

To get a list of sitemaps of a site, invoke GetSitemapsFeed method of GWebmasterToolsService object with site URI as the only parameter. For example:

feed = client.GetSitemapsFeed('http://www.example.com/')
for entry in feed.entry:
    print entry.title.text

The return value is a SitemapsFeed object.

Adding Sitemaps
Add a regular sitemap
To add a regular sitemap to a site, invoke AddSitemap method of GWebmasterToolsService object with parameters, site URI and being added sitemap URI. For example:

entry = client.AddSitemap('http://www.example.com/', 'http://www.example.com/sitemap-index.xml') 
print entry.title.text

The return value is a SitemapsEntry object.

Add a mobile sitemap
(Broken) To add a regular sitemap to a site, invoke AddMobileSitemap method of GWebmasterToolsService object with parameters, site URI, being added mobile sitemap URI, and format name. Accepted format name are XHTML, WML, and cHTML. For example:

entry = client.AddMobileSitemap('http://www.example.com/', 'http://www.example.com/sitemap-mobile-example.xml', 'XHTML')

The return value is a SitemapsEntry object.

Read More information about Mobile Sitemaps.

Add a news sitemap
(Untested) To add a news sitemap to a site, invoke AddNewsSitemap method of GWebmasterToolsService object with parameters, site URI, being added news sitemap URI, and publication label(s). Publication label can be a string or a list of strings. For example:

entry = client.AddNewsSitemap('http://www.example.com/', 'http://www.example.com/sitemap-news-example.xml', 'Label')

The return value is a SitemapsEntry object.

Read More information about News Sitemaps.

Deleting Sitemaps
To delete a sitemap from a site, invoke DeleteSitemap method of GWebmasterToolsService object with parameters, site URI, being deleted sitemap URI. For example:

client.DeleteSitemap('http://www.example.com/', 'http://www.example.com/sitemap-index.xml')

g - Quick Directory Switcher

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
You can use this to save some frequently used directories and easily switch to one of them by choosing from a list or by Bash completion.

I have been using this script since last year. Until days ago, I finally rewrote it with Bash completion functionality. You can read the source code on Google Code.

Current revision is r17 (also the download link). Licensed under the GPLv3.

Usage & Installation

There are two ways to use this script:
  1. Run it as a normal Bash script
  2. Source it and use the Bash function g() inside this g script.
I prefer latter, because you can use it with Bash completion and you don't need to prefix a dot when switching direcotry. I will explain how to use in either way.

Bash Script Way

Firstly, download this g script to a place you like, say /path/to/g. You can run /path/to/g -h to see what options you have. Here is a sample:
Commands:
  g dir        : change working directory to dir
  g (-g|g)     : get a list of directories
  g (-a|a)     : add current directory
  g (-a|a) dir : add dir
  g (-r|r)     : remove a directory from list
  g (-h|h)     : show what you are reading right now
Before you can really use this g script, you need to save some directories. Use cd to one of the most used directories. Then, run /path/to/g -a to add current directory to ~/.g_dirs (default file). Once you have added some, run
. /path/to/g g
That dot at beginning and g letter at tail are very important. You will see a list of directories, which you have just added. Choose one, enter the number and hit Enter key to switch directory.

If you want to remove just run
/path/to/g -r
The dot above is doing sourcing a Bash script, which is necessary to let directory changing takes effect in Bash shell when you want to do that by running a script.

Bash Function Way

I assume that you want to use Bash completion with this g script. You need to do few things first:
  1. Install the Bash completion package for your distro. On Fedora, run yum install bash-completion.
  2. Save this script to /path/to/g.
  3. In you home directory, run ln -s /path/to/g .bash_completion. If you want to make it system-wide, switch to /etc/bash_completion.d, then run ln -s /path/to/g .bash_completion as root.
  4. (Optional) Normally, TAB is the key to get the list, but usually you still need to type some more. You can make it to cycle the options in the list. You only need to have TAB: menu-complete in ~/.inputrc. Once again for system-wide, put that in /etc/inputrc.
More about inputrc, I don't want to change the behavior of TAB , so I have
"\e[6~": menu-complete
#TAB: menu-complete

set completion-ignore-case On
\e[6~ allows me to use PAGEDOWN to cycle options, and TAB still gives me a list.

After you finishing steps above, open another terminal. Type g and hit ENTER key, you should see a help menu like the one in Bash Script Way. If not, there is something wrong.

Then you will need to add some directories, run g -a to add current directory. After you add some, run g again, you should have a list of them. You can choose one from them to switch directory.

Now, type g and a space, hit TAB or PAGEDOWN (if you have same ~/.inputrc like mine). The directories should be cycling, press ENTER when you get the one you want.

In this way, you run a Bash function not a script. Here is a screenshot of using as a function:

A Bug in FlickrFS

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
This post is a repost for http://thetinybit.com/Blog/2008-06-02 [not accessible]
Yesterday I saw a conversation on FriendFeed, that is about migrating photo from Picasaweb to Flickr. I don't have such need, but I immediately had an idea by using PicasaFS and FlickrFS. Before that, I had never tried out PicasaFS and FlickrFS. FlickrFS has a bug that makes me can't have /sets in FuseFS. After searching for hours, the resolution is extremely simple.

The cause is:
 When Fuse.main() invoked, the process goes into daemon mode. Threads would be ended if there are some created before. The correct way to create threads is to add fsinit() (See this post) method in your fuse class, then create threads in that method. The fuse FAQ also mentions this issue.

I still don't know how to ask fuse running in foreground like PicasaFS does.

The patch for CVS:
Index: flickrfs.py
===================================================================
RCS file: /cvsroot/flickrfs/flickrfs/flickrfs/flickrfs.py,v
retrieving revision 1.9
diff -u -r1.9 flickrfs.py
--- flickrfs.py    31 Jan 2008 19:32:33 -0000    1.9
+++ flickrfs.py    1 Jun 2008 23:49:45 -0000
@@ -206,6 +206,9 @@
     self._mkdir("/tags")
     self._mkdir("/tags/personal")
     self._mkdir("/tags/public")
+
+
+  def fsinit(self):
     background(timerThread, self.sets_thread,
                self.sync_sets_thread, sets_sync_int) #sync every 2 minutes
This patch actually is one line only.

The versions of softwares I used:
  • flickrfs 1.3.9 and cvs (retrieved on 2008-06-01)
  • fuse 2.7.3
  • fuse-python 0.2.8
  • Imagemagick 6.3.8.1
  • python 2.5.1

linuxwacom 0.7.9.8

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
I followed my own steps to set up wdaemon for my Intuos 3 on Fedora 9, but I can't even start X server. The log said the InputDevice's Type is incorrect. The Type should be one of stylus, eraser, pen and pad, but it already is one of them. I guess this may be an problem with X.org 1.5?



I don't want to compile latest source, so I found a newer package on Koji, 0.8.0.3-2-fc10. Upgraded with this version, the problem is gone.

Twitter Tracker

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Months ago, when Twitter still worked normally, there is a Twitter IM, a gtalk bot. Which allows you to track tweets with keywords. Soon, the whale showed up, it ate the Twitter IM.



Few days ago, I suddenly saw the Twitter Seach API. It is not only the tracking, but more powerful. This API provides exactly what you can search via Twitter Search. You can read this search operators explanation.



I just have some progress on my Twitter Python client. It's a Python library, a package. In it, there is a sample called Tracker.py. It can track as if Twitter IM did for us.



Tracker.py actually is just a sample code, but it's enough for me. Here is a quick screenshot, which ran on Linux:



You can start Tracker.py as many as you like. It's a console script and simple one.



What you can track?

  • linux

  • linux OR windows

  • obama OR mccain


  • linux windows (linux and windows)

  • #topic


  • from:livietter (sends from me)


  • to:livietter (sends to me)


  • @livibetter (someone mentions me or reply to me)


  • livibetter (me?)

  • twitter -livibetter (someone says twitter but not from me)


  • scoble OR monaaa (stalk some people)

I suggest that you can use Twitter Advanced Search to compose your query, then paste to Tracker.py.



How to get this to work?

  • Follow the installation step in Twitter Python client.

  • Download Tracker.py if not installed using source.

  • Run Tracker.py.

  • Start stalking, I meant tracking. :)


What did I create this for?



Someone says "anyone" in their tweets. I think if someone needs a hand, they may use "anyone" in tweet. I am seeking people who need help.



What does Tracker.py do?



It will get tweets once a minute.



Final Notes



I only tested it on Linux, but I think it should work on other systems. I know this page probably can not help people who don't know much about Python. If you have any problems, please give related information, I will add supplementation as soon as possible.



Exact phrase, e.g. "search string", will have trouble in Tracker.py. But I am too lazy to fix it.



This Tracker.py and Twitter Python client are just the first release (barely called a release), they may be buggy.



Any ideas, suggestions, or bug reports are welcome!

twitter_client

This post was imported from my old blog “make YJL” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
twitter_client (PyPI) is a Python client for Twitter APIs, currently supports:
Current Version: 0.1a1 (2008-10-12)
License: Apache License 2.0

Dependencies

Getting the Source

Only directly checking out from repository can have samples and unittest files.

Checking out from Subversion repository
svn checkout http://yjl.googlecode.com/svn/trunk/twitter-python-client twitter-python-client
Downloading the source tarball

It can be downloaded on PyPI.

Installation
Using setuptools to install system-wide

Run the following as root:
easy_install twitter_client
The command above will take care of the dependencies. Once it's done, run
python -m twitter_client
If you see nothing, then the package should be installed correctly.

Using setuptools to install other place
easy_install --install-dir PATH twitter_client
Note that the PATH must be in PYTHONPATH environment variable.

From Source
./setup.py install
To install other place, please read the help ./setup.py install --help

Problems or Suggestions?

Leave a comment or create a new issue.

Euro Million lottrey award 2008 and Barack Obama

This post was imported from my old blog “Blogarbage” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
They have nothing to do together. Some awful people just use his name to cheat search engines, I suppose. I got this weekly Google Alerts in my mailbox (Yes, I stalk myself! :>):
That blog's name is Barack Obama, but have posts like "Euro Million lottrey award 2008". Here is the screenshot of the link in alert:

This blog puts Barack Obama's stuff before and after those posts. Note that there are many unreachable mailboxes. Must be a dumb spammer's work. I have flagged that blog, hope it will be taken down and very soon.

I have never seen any spam mail about this in my gmail mailbox, good job gmail!

PS. I just notice there is a spelling mistake (or intended?) in lottrey.

Add Woopra Tracking Code More Easier to Blogger (Blogspot)

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Updated on 2008-11-03: This blog is updated for latest Woopra Tracking Code.



I use Blogger Add Widget API to let us have this form below:













After clicking the button, you will be a page like:



Select the correct blog, which matches the website ID, then click ADD WIDGET. Don't set Title, you can try and see if you don't believe in me.



Once the widget added, you will be in the Layout page of you blog. I suggest that you drag it (Display as HTML/JavaScript widget if you leave Title blank) and drop to the footer.



If you want to see what the code of this form is, you can check it out on Google Code. Problems other than about this form, please ask on Woopra forums. Otherwise, leave your comment.

Tricking computer players in OpenTTD

This post was imported from my old blog “Blogarbage” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
I had played OpenTTD 0.4.X. Few days ago, I downloaded it and started to play it. Trying to find out few ways to fool computer, here is what I did:

Don't violate the traffic regulation!
make a shortcut for computer, then set two one-ways

o, o, and o, still o...
just let them run on my shortcut, close it, then loop the road.

My train is broken! Sorry!

You are surrounded! Resistance is futile! Surrender yourself!
Keep blocking them outside before the all line up, then let them in and hehe...!

How about railway?
I don't know any way can fool computer players after the track is built. While building, I buy langs to block their way of building. That could waste them lots of money until they couldn't afford any more.

Do you know any can fool with fun?

I am back on Fedora 9

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Yes, I am back on Fedora 9. Is something wrong with Ubuntu? Nope, just an idiot Linux user run a script without care. I partially nuked the first part of /dev/sda. My home parition is at last of disk. Actually, I have no idea what the script will do.  That script didn't at first, I then ran with sudo. When I checked the script, I saw dd, I was wondering doesn't this script is to analyse my files (No, it's not), but I still run with sudo. I wasn't aware of what would be done on my disk when I just ran.



Few minutes later, I feel strange why took so long? I read the article for the first time, then imediately switched to terminal and press CTRL+C. At that moment, I only laughed at what I did. I know I got to save my files, those in home dir. I know I can't reboot, or plug this disk to other computer. The very first portion of this disk had just completely wiped out. Partition table is gone. I need to take time when I still can access the disk.



I plugged a USB harddisk, no luck; tried the DVD drive, still no luck. I don't dare to close the terminal which I used to nuke my disk. Almost all programs in /usr/bin were gone. mount was gone. So I think saving via network is possible the only thing I can try since I still can tweet and use Firefox to check emails. Luckily, I have rsync. So I copied my home dir to another computer. However, I didn't copy those configuration files because the command I gave is not complete. But I can accept the loss, it's better than nothing saved.



Then, I think should I install Ubuntu again, or go back to Fedora? I chose going back. Now Fedora is updating, downloading really takes long long time.

Installing Woopra 1.2 beta on Ubuntu amd64

This post was imported from my old blog “Get Ctrl Back” on 2010-09-28. Some stuff in this post may be broken, please leave a comment if you see any, then I will try to fix it.
Firstly, I only took 9 days to get approved by Woopra, some posts on the forums say that may take weeks.



Installing Woopra on Linux is simple and it is a graphical process. Look at the screenshot below.

You can download the installer here and install it with sh woopra.sh. I installed it at my home pathes: /home/username/lib/Woopra for Woopra program, and /home/username/bin for symbolic link.



When I tried to run it, I got an error:

 
My JRE is from Sun and it's 64 Bit, you can check yours by running java -version, which outputs like:

java version "1.6.0_06"

Java(TM) SE Runtime Environment (build 1.6.0_06-b02)

Java HotSpot(TM) 64-Bit Server VM (build 10.0-b22, mixed mode)
The solutions are two, both are easy. First one is to remove sun-java6-bin package and install ia32-sun-java6-bin package.



Second one is easy, too, and better. Install ia32-sun-java6-bin package, first. Then test with this newly install 32 bit JRE with

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/ia32-java-6-sun/jre Woopra
This forces the startup script, /home/username/bin/Woopra in my case, to use specified Java JRE not the one that it can find on your system.



Once Woopra runs successfully and with no error, close it. Find the startup script, if you don't know where it is, you can run whereis Woopra or type Woopra (in Bash). If none of both get result, use find / -name Woopra.



Find it, and open it with editor, and put the following line at second line (an empty line):

INSTALL4J_JAVA_HOME_OVERRIDE=/usr/lib/jvm/ia32-java-6-sun/jre
Now, simply run Woopra in terminal or from main menu.



Here is a screenshot after logging in: