Google Reader and Readability, Kindle

Readability has browser extensions for reading current page or sending current web page to Kindle, but I read a lot in Google Reader where many articles are on the same page. It seems that Readability staff considered this feature and did investigate on that. But until now I didn’t find a mechanism for Reader’s native send to feature to work with Readability. So I spent several hours writing this Greasemonkey script, so far very happy with it.

Click here to install. It supports both Chrome and Firefox. After it’s installed, open Google Reader and view any entry, you’ll find Readability’s button on the right of the actions bar below the entry content. Like this:

Google Reader Readability Send To Kindle

If you don’t already know Readability, you should try it. After clicking the button, the article is saved to your reading list in your Readability account, and Readability sends (after some processing to make it “readable”) it to [your name]@free.kindle.com. Then when you connect your Kindle to a WIFI spot, the articles are automatically downloaded.

Basically I utilized the JavaScript from Readability’s publisher tool. Luckily they didn’t obfuscate the code and it indeed has good readability :) Anyway I think Readability should develop a page which can be used in Google Reader’s native send to popup. That would be easy and better than my script, since I have to update it every time Google Reader interface changes or Readability updates their JavaScript library.

A minor issue of readability is that it doesn’t extract the redirected URL so all the articles from blogs using feedburner’s service will seem to be from feedproxy.google.com and in readability’s account you’ll see feedburner’s favicon displaying before most items.

Using ImageMagick for WordPress Thumbnail Generation

When you upload an image in WordPress, the blogging software tries to generate several scaled versions of the images uploaded. So after it’s done, WordPress provides 4 different sizes of the image for you to insert into the post – thumbnail, small, large, original.

I noticed that for my WordPress install, only the original image was available and the other options were disabled. The reason is that the PHP on my server was compiled by me myself and I didn’t compile many of the extensions. WordPress uses GD extension for thumbnail generation. But this time I didn’t recompile PHP with GD (I didn’t know how to compile GD alone as an extension). Instead I used ImageMagick and here’s the whole process.

Continue reading Using ImageMagick for WordPress Thumbnail Generation

Switching to Chrome (from Firefox)

The other day I left my Linux desktop on for several hours and when I came back, it seemed everything hung there. I managed to open `top`, and found the cause being Firefox eating up all the memory. Long ago I complained that and somebody told me that it must be some extension. But anyway I’m considering a switch to Google Chrome seriously. Now, several days later, I’m quite happy with Chrome and here is my summary.

Continue reading Switching to Chrome (from Firefox)

Crontab Command Substitution not Working – Solution

By default crontab sends the cron job output to /var/spool/mail/{username} but this time I wanted one of my daily cron job to write to a different log file each day. So I changed it to something like:

30 2 * * * myscript.sh &> /.../`date +%F`.log

But the next day I found that the script didn’t run at all. I tried to copy the command and execute it directly in shell – it worked. Then I looked at /var/spool/mail/{my username} and found the following error message:

/bin/sh: -c: line 0: unexpected EOF while looking for matching “’
/bin/sh: -c: line 1: syntax error: unexpected end of file

At last I found that it was because of the “%” character. Percent symbol has special meanings in crontab. Escaping it with backslash solves the problem:

30 2 * * * myscript.sh &> /.../`date +\%F`.log

Python Logging from Multiple Processes

We have a server running a Python application in Apache with mod_wsgi. In httpd.conf we configured 4 processes to run this application, each with multiple threads.

This configuration caused us some troubles. We extensively used memory to cache some results from very complicated and time-consuming computation and also some key-value pairs for efficient reading, and since different processes don’t share memory, we have multiple memory copies of the same data. That is, we need around 4x memory of the cache size. Of course, this can be solved by using something like memcached.

Another problem is logging. We are using Python’s built-in logging module to do this job (we needed extra logging besides Apache’s accesslog). At first we used the basic FileHandler and everything seemed OK. Later we decided to use TimedRotatingFileHandler to rotate the log at midnight so that we can analyze the logs daily. But on the second day, we found that the previous day’s log was missing. For example, today is 2011-08-10 and we expect to see yesterday’s log in file “customlog-2011-08-09”, but this file is full of today’s log entries! Both files “customlog” (the non-rotated file generated today) and “customlog-2011-08-09” are growing, which means that they are both being appended by processes.

Continue reading Python Logging from Multiple Processes

Setting Up OpenVPN Server in Fedora 14

There are many articles if you Google for “OpenVPN setup”. Most of them teach you how to install OpenVPN on various operating systems and how to write server configuration files. But while some people are looking for solutions of getting into a LAN (in an office, for example) from outside, I think many are seeking a way of breaking through some network restrictions, or creating a secure tunnel to reach the Internet.

In the latter scenario, just getting OpenVPN daemon up running isn’t enough. What we need to do next is setting up IP traffic forwarding and set iptables rules to accept the traffic. Actually my favourate tutorial is this one:

Continue reading Setting Up OpenVPN Server in Fedora 14