Again on Python and unicode

Yes, there are numerous good articles on the subject, but still every time I am stumbled upon infamous

UnicodeEncodeError: 'charmap' codec can't encode character u'\u0306' in position 50: character maps to <undefined>

and I have to research it again. Somehow it does not stick. Perhaps because it just should have worked “out of box”. Anyway. Hereby a small recipe that “shuts the unicode nagging” in Python 2 when enumerating all the files:

import sys
import codecs

sys.stdout = codecs.getwriter('utf-8')(sys.stdout, 'strict')
for root, folders, files in os.walk(unicode(path), 'utf-8'):
    print u'%s\r' % root,
    <do whatever you want with the files></div>

Missing article in Joomla! Article Manager

“Suddenly” missing an article in Article Manager in Joomla!? Try selecting “All” in the “Status selection”. Apparently by default it will filter out e.g. archived articles. I have accidentally clicked on the “Archive” button having one article selected and then spend good 15 minutes looking for that article.

PayPal Facebook action bug

Funny enough, but PayPal’s Facebook action to gather "Like"s and get information on users has a bug when you select not to accept providing them all information (yes, that is too much to my understanding, giving a "Like" may have been OK):

System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Facebook.JsonObject.get_Item(String key) at EnterContest.Page_Load(Object sender, EventArgs e) in d:\var\httpd\PayPal-Benelux\htdocs\default\www\facebookactie\EnterContest.aspx.cs:line 41

PayPal, you could have done better!

Happy New Year to everybody!

Backing up DVD on MacOSX

Having a screaming child who wants yet another cartoon every half-an-hour which does not work due to little fingerprints and simply takes time to put into DVD, etc I finally was fed up. Am I lazy or not? I definitely am! A solution to this problem is hooking up a PC (laptop) and getting all DVDs be played from the single source.

Having a screaming child who wants yet another cartoon every half-an-hour which does not work due to little fingerprints and simply takes time to put into DVD, etc I finally was fed up. Am I lazy or not? I definitely am! Therefore I took my old Inspiron 5160 with broken LCD (who needs the screen if you have a TV? :)) and hooked it up to the TV. In this way I have one source for all children zombie-pleasures (if you even seen a two years old watching the infamous ‘Dora The Explorer’ or something similar you know what I mean :)).

The next thing was to install xbmc, which surprisingly worked, although required some tweaks like disabling animations to avoid P4 2.8 Mhz hanging (I thought it was rather advanced when I have bought it some years ago :)).

But the next thing was getting the DVDs to xbmc. Logically, you need to rip them and then convert to something like .avi to let xbmc do the rest.

Getting DVDs to .avi

Get the MacTheRipper or a similar tool. This will give you the DVD content on you hard disk. The second step is to convert the .vob files to something that can be played and won’t take that much space, so e.g. .avi. To encode to an .avi you have a one-for-all library called ffmpeg.

Building ffmpeg under MacOSX (I took the latest stable 0.5.1) failed for me with the following error message:

    make(9876) malloc: *** vm_allocate(size=4273000448) failed (error code=3)
    make(9876) malloc: *** error: can't allocate region
    make(9876) malloc: *** set a breakpoint in szone_error to debug
    make: *** virtual memory exhausted.  Stop.

thank to this post, the solution is simple, and installing make 3.81 will resolve the problem.

Finally, perform

sudo rm /usr/bin/make
sudo ln -s /usr/local/bin/make  /usr/bin/make

To install the new version.

The rest is pretty straightforward, so doing the standard

./configure
make
sudo make install

will get theffmpeg install done.

Conversion itslef is done by using e.g. the following command:

ffmpeg -i VTS_01_1.vob -f avi -vcodec mpeg4 -b 800k -g 300 -ac 2 -bf 2 \
    -acodec libmp3lame -ab 128k -s 704x384 -deinterlace -vtag divx Movie_1.avi

This has to be repeated for each VOB, so you end up with several .avi files which have to be merged using e.g. the D-Vision.

Alternatve
There is also ffmpegX available, but seen the last update in 2008 it felt a bit outdated.

p.s. the DVDs were legally bought, and the copies were only meant for the family viewing.

Subversion 1.6.3 on Ubuntu 9.02

Since installing subclipse I’ve got same problem I’ve already had on MacOSX when my subversion command line client (1.5.x) started to complain that the repository was already used with a newer version. Downgrading repository version works, but not a very nice solution, so I have decided to get the latest version. Apparently this is not just an aptitude command, but a little more. This is what have worked for me finally:

Download the source code for 1.6.3 (or later when it becomes available) and the corresponding dependencies from http://subversion.tigris.org. You have to have the following files in the case of 1.6.3:

  • subversion-1.6.3.tar.gz
  • tar xvf subversion-deps-1.6.3.tar.gz

Download the OpenSSL from http://openssl.org/source/ if you need https support:

  • openssl-0.9.8k.tar.gz

Then perform the following commands:

sudo apt-get install libssl-dev
sudo apt-get install zlib1g-dev


tar xvfz subversion-1.6.3.tar.gz
tar xvfz subversion-deps-1.6.3.tar.gz
tar xvfz openssl-0.9.8k.tar.gz


cd openssl-0.9.8k
./config
make


cd ../subversion-1.6.3
./configure --with-openssl=/usr/local/ssl --with-ssl --with-zlib=/usr/include --without-berkley-db
make
sudo make install

Having all this I’ve got working subversion (client) 1.6.3 under Ubuntu 9.02 .

TIP: If you done all above and typing svn --version still shows the default 1.5.x try another console. The installation of subversion apparently adds a new path which not picked up on the fly.

Chello (ISP) frustration

Yesterday was a nig eye-opener / frustrating night for me. After getting really fed up and even more convinced that my 30/7 kbps download/upload is not a common practice I have started with an investigation on who is doing this to my internet connection. Well, it took my laziness almost two years to get to this point, which also says how much I use my internet connection, but anyway…

First, I assumed it is me. What’s new, a techie that has more devices at home than braincells can definitely screw things up. I am one of those types. Here is the original setup:

  • Arris TM502B/220 cable modem provided to me generously by my ISP Chello (The Netherlands);
  • Linksys WRT54GL with Tomato formware (upgraded to 1.25 as one of the actions below);
  • Numerous devices eventually connecting to the router to get their (drops of) Internet connection.

The last drop was when a friend of mine who had presumably cheaper internet connection claimed higher upload speed than what I had. Let’s nail it down… Well, after hours of googling and changing the settings of my router’s firmware I’ve got zero result. Next step – hardware.

First, I have tried to connect to the modem directly excluding the router (which was my initial suspicion due to QoS settings and who-knows-what-else). This didn’t improve things even a bit. Still the same frustrating numbers (ses below).

Second, the most crusial step. Change the modem itself. Luckily I still have an old Motorola modem (no VoIP phone connection, but I don’t use it anyway). When I’ve got my new modem they didn’t take away the old one, so why not to try. This time luck was definitly on my side, since connecting the old modem worked like a charm, so additional setup was needed. Direct connection didn’t work though, so I had to connect to the router. So be it, it is the desired setup in any case. And then…

TADAA!!!

I run the speedtest.nl and I gt the numbers which raised my eyebrows in a huge frustration. Ok, first of myself that I have waited so long to get to this point, but second because of my ISP sending me crap. So here it is:

Setup with Arris modem, the results of speedtest.nl, (<laugh>):

  • Download 0.25 Mbps
  • Upload 0.06 Mpbps

(</laugh>)

With the old Motorola modem:

  • Download 15.57 Mbps
  • Upload 1.45 Mpbps

Feel the difference!

I immediately put back QoS to make sure I (or my wife :)) don’t eat up the whole bandwidth with one download and forced myself to put back the Arris modem back on the shelf carefully not breaking it in pieces.

Conclusions
The new modem (Arris) was cutting my connection ridiculously while the only added feature (phone connection) was not used by me at all. I will be cancelling my subscription(s) soon I think and reshaping my package to higher internet only. This costed me too much waiting time and frustrations to keep it like this for the last TWO YEARS!

p.s. Both modems provide basic information on http://192.168.100.1 and the old Motorola with firmware copyrighted in 2002 has even settings like enabling DHCP (which I don’t need and even don’t want) configurable, while Arris’es settings are kept behind the (unknown to me) password.

CherryPy + MySQLdb

After hours of searching and hitting the walls with the following error:

File "build/bdist.macosx-10.3-i386/egg/MySQLdb/__init__.py", line 19, in
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 7, in
File "build/bdist.macosx-10.3-i386/egg/_mysql.py", line 6, in __bootstrap__
ImportError: dlopen(/Users/oleksii/.python-eggs/MySQL_python-1.2.2-py2.5-macosx-10.3-i386.egg-tmp/_mysql.so, 2): image not found

I finally decided just to look on what actually was in the .python-eggs folder. Rrrriiight:

-rw------- 1 oleksii oleksii 123024 Sep 20 2008 _mysql.so

Isn’t this just beautiful? I don’t get why it is created under my user anyway while Apache2 is running under different user, but since the created library was only readable by me myself… Well, Apache just couldn’t get to it. Damn. What a loss of time (simply not mentioning all previous frustrations with installs, etc).