Monthly Archives: February 2010

recaptcha

I recently started to poke around with drupal for the content of a couple of sites I host.
Thats when I stumbled upon this nice take on capthas.

Traditionally a captcha consists of random letters and words, that are more or less readable, to stop spamming scripts. This is a problem since people also have a somewhat hard time reading garbled random characters.

Recaptcha uses a different approach, it lets users decode scanned words from books that OCR software can’t handle. This means that what you see are actual words which is easier for humans to understand, and that it should be sufficiently hard to decode by software. Also you help digitalize books. It is really a win-win situation!
An example of it in use can be seen below, or in the comment form on this blog.
recaptcha example

As of the fall of 2009 google has also acquired recaptcha.
More info and some statistics can be found at the recaptcha web site.

Share

jail resources oneliner

Getting a quick overview of the resources currently assigned to your your jails can be done using the following command sequence:

top -Pajnojid | tail -n 20 | awk '{if ($2!=0) print $0}'

Starring in order of appearance:
top; with the flags P -Show info per CPU, a -get command name from argv[] and not the name of the executable, j -display jail id, n -non interactive mode, ojid -the order flag `o` followed by jid for sorting.
tail; to get the last 20 lines of output (skip the sys info)
awk; print all lines where column 2 is not `0`

if you have many jails and hence many jail processes you might want to bump up the number of lines a bit like follows to show a maximum of 50 processes instead of the default 20:

top -Pajnojid 50 | tail -n 52 | awk '{if ($2!=0) print $0}'

Share

wordpress quickfix via mysql

If you fudge up you wordpress installation to the point where it is not even accessible this might be a way to fix it.

Log on to the server hosting your database (or do it remote via mysql) and do a dump of the database in question with mysqldump:

bloghost# mysqldump -p --databases wordpress >> wordpress.sql

Then open your file in an editor and browse to the setting that is causing the trouble and edit it back to normal!

Then it is just to import the database back into mysql with mysqlimport or to simply pull it in via the mysql command like this:

bloghost# mysql -u user -pyourpassword < wordpress.sql

And you are good to go again!

The good thing about wordpress is that it stores this enormous amount of stuff in the database and not just the posts. And as a bonus, since the site was unavailable you know that the info you wrote back into the db is the latest and nothing got lost on the way!

However, there are plenty of opportunities to make more damage than good this way, so do not blame me if you brake anything taking my tip. If you do, you probably should not have been there anyway!

Share

mod_rewrite goodness

I had been annoyed since day one that the redirection to the blog-jail was not satisfactory and have been meaning to fix it since about then..
So today I finally got myself together and was going to set up mod_proxy once and for all.
However I had compiled apache without it, so I looked at the other modules that was compiled.
The first one that came to my mind was mod_rewrite wich I felt should be capable of filling my needs.
I was right, and it prooved to be quite powerful (as most things apache IMHO) and simple to setup.

The simple solution was to create an http root on the redirecting host for this vhost, and add AllowOverride All to its Directory options.
And in it i put a single .htaccess file with the following two lines:

RewriteEngine On
RedirectMatch ^/(.*) http://blog.henrikandersen.se:591/$1

Wich effectively sends all requests to the vhost straight over to the port that gets nat’ed in to this jail.
So now one can finally use full URL;s to posts here without adding any port as opposed to the front page redirection previously used!

Share

quickie of the day – rm

One thing that bothered me for a long time was when I had to delete files behinning with `-`or `–`.
You can always use slashes and quotes but there is an easier way to go about it.

Add — to rm, and it will stop parsing the command line for flags and options.
So simply try this next time!

rm -- -file

A lot simpler and cleaner than slashes and quotes if you ask me!

Share