svnsync alternative

svnsync, like its doc says, is the Subversion remote repository mirroring tool. We may need to have a mirror for backup, or for faster checkout/update in a remote datacenter.

There are lots of documentations and articles about how to set up a mirror using svnsync. But in a situation that connection between mirror and master is really bad, svnsync fails frequently and leaves the mirror locked. Then we have to manually unlock the mirror repository to get it recovered.

Is there an alternative? Short answer – YES:

Continue reading svnsync alternative

Compiling Subversion 1.8

Getting compiled binaries is easier but sometimes it just isn’t a choice. It was 2007 when I last compiled subversion, it was still 1.4. I remember that I had a tough time figuring out the apr/apr-utils compatibility issues, and installing neon.

Now it’s 1.8. The new version deceptively gave me an impression that things has become much easier – on a CentOS 6.3 box it compiled, installed and worked with Apache 2.2 (installed by yum) perfectly! I didn’t realize it until I started checking out a repo from it. The checkout was successful but with a tiny warning – post commit FS processing had error: Couldn’t open rep-cache database.

This message was also deceptive. It made me think of permission problems. But it turns out to be a sqlite3 issue! It has the same cause with another problem – when I tried to checkout the repo on the svn server itself through file protocol, it failed with this message: SQLite compiled for 3.8.2, but running with 3.6.20.

Install with sqlite3

Since the sqlite3 version shipped with CentOS was lower than required by subversion, I downloaded the sqlite3 amalgamation, compiled it, and copied the binary and header files to correct locations. Then the configure script stopped complaining about it. I thought that fixed it but obviously it didn’t.

The correct way of installing subversion with the correct version of sqlite3 is like this:

./configure –with-sqlite=/path/to/sqlite-amalgamation/sqlite3.c

HTTP support for client

Later I noticed that the svn client didn’t even support HTTP.

Now subversion uses serf as client HTTP library.

To compile it, you need a build tool called scons. Then just follow serf’s README file.

Enjoy.

Postfix – Only Allow Whitelisted Recipient Domains

We have a test environment with real user data, and during testing, the servers may send emails to these real users. But we definitely don’t want our users to receive those test emails, since they’ll be totally confused and get a bad feeling about our service. Yet we want the emails sent to our company’s domain to be delivered successfully, so we can test with our work email address.

One solution is update the database and change all user emails to dummy ones. However this requires one more step each time the development database is refreshed with real data.

Continue reading Postfix – Only Allow Whitelisted Recipient Domains

Writing Greasemonkey User Scripts for Firefox and Chrome

Greasemonkey was initially only a Firefox extention but due to its popularity it’s quickly adopted by major browsers. Since Opera takes a very small market share, here on the topic of cross browser user scripts, I’m only going to talk about Chrome and Firefox. As for Internet Explorer, I just don’t like it.

Now Chrome doesn’t need an extension to enable user scripts. It had the functionality built in. But the way it handles the scripts is quite different from Firefox’s. At first when I wanted to test if my Greasemonkey script worked in Chrome, I tried to figure out where it stored the script. That’s the way I always do in Firefox – just right click on a user script and edit, save and refresh to see it in effect right away.

Continue reading Writing Greasemonkey User Scripts for Firefox and Chrome

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

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