Comment Spam & Literature
I finally got fed up with manually monitoring the spam messages, but I didn't want to turn off anonymous comments. I figured captcha was the answer, but what was the easiest way?
photo.net, the awesome photographry site built and run by Philip Greenspun is built on a similar platform to this site, and I knew it had captcha. Philip is true to his word on the importance of open source software, and the api and code of his site is publicly available. I discovered that photo.net uses a free service called reCAPTCHA - and it's brilliant! It gives you two words to type in. One that it knows the answer to (to check you're a human) and the other is a curly word that the OCR system at Carnegie Mellon University couldn't figure out while scanning books for the public good. I assume they run the unknown word through a number of captcha queries and pick the most popular interpretation.
Now that's really crowd-sourcing!
07:52 AM, 26 Jul 2008 by Mark Aufflick Permalink | Comments (1)
TWiki on FastCGI
I couldn't find much discussion of TWiki on FCGI. There is a beta project to make a standalone TWiki daemon which can also be run under FCGI, but I had already installed TWiki 4.2.0 so I was reticent to reinstall from a different branch.
I only really needed to speed up the view cgi, so it shouldn't be too hard surely? I already had mod_fcgid installed on my Apache2 server.
It turned out to really be very easy, and seems to be working fine so far. Here is my diff for twiki/bin/view:
--- view~ 2008-01-22 14:18:52.000000000 +1100
+++ view 2008-07-20 18:40:33.000000000 +1000
@@ -27,6 +27,14 @@
require 'setlib.cfg';
}
+use FCGI;
use TWiki::UI;
use TWiki::UI::View;
-TWiki::UI::run( \&TWiki::UI::View::view, view => 1 );
+
+my $request = FCGI::Request;
+while ($request->Accept >= 0) {
+ eval {TWiki::UI::run( \&TWiki::UI::View::view, view => 1 );};
+ warn $@ if $@;
+ $request->Flush;
+ $request->Finish;
+}
And I added the following to the bin <Directory> section in my apache config:
<FilesMatch "^view$"> SetHandler fcgid-script </FilesMatch>
This seemed to work fine, but searches failed to spawn grep correctly. I think diffs would have also failed to spawn rcs. So I switched over to the pure perl versions by making the following settings in LocalSite.cfg:
$TWiki::cfg{StoreImpl} = 'RcsLite';
TWiki::cfg{RCS}{SearchAlgorithm} = 'TWiki::Store::SearchAlgorithms::PurePerl';
Working a treat so far - Memory use seems ok. It rose from about 14000k up to about 15200k, and then hovered around that level indefinately. I'll let you know if I see any memory leaks or wierd issues.
Update: I guess the pure perl search implementation isn't well used. It threw up a taint error when I tried to use it. No matter, the fix was as simple as replacing a horrible piece of string eval:
--- lib/TWiki/Store/SearchAlgorithms/PurePerl.pm~ 2008-01-22 14:18:55.000000000 +1100
+++ lib/TWiki/Store/SearchAlgorithms/PurePerl.pm 2008-07-20 19:32:58.000000000 +1000
@@ -46,9 +46,14 @@
# Convert GNU grep \< \> syntax to \b
$searchString =~ s/(?]/\\b/g;
$searchString =~ s/^(.*)$/\\b$1\\b/go if $options->{'wordboundaries'};
- my $match_code = "return \$_[0] =~ m/$searchString/o";
- $match_code .= 'i' unless ($options->{casesensitive});
- my $doMatch = eval "sub { $match_code }";
+
+ my $doMatch;
+ if ($options->{casesensitive}) {
+ $doMatch = sub { $_[0] =~ m/$searchString/o };
+ } else {
+ $doMatch = sub { $_[0] =~ m/$searchString/oi };
+ }
+
FILE:
foreach my $file ( @$topics ) {
next unless open(FILE, "<$sDir/$file.txt");
I'll have to track down how to submit TWiki bugs...
Update 2: Another search issue - in the persisted view, the search page never gets re-rendered (ie. after making one successful search, all future searches appear to have identical results).
I didn't have time to find if that was a problem in the view code or the pure pearl search, but it was easy enough to make sure a new cgi was spawned per search request by adding the following at the end of the VirtualHost:
<LocationMatch "WebSearch">
SetHandler cgi-script
</LocationMatch>
Conveniently the FCGI script works fine as a regular one-shot cgi, and since LocationMatch is processed after FilesMatch by Apache, this overrides the fcgid handler setting.
04:51 AM, 20 Jul 2008 by Mark Aufflick Permalink | Comments (1)
Archive
| July 2008 | ||||||
| S | M | T | W | T | F | S |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
March 2012
February 2012
November 2011
October 2011
April 2011
March 2011
January 2011
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
February 2009
January 2009
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
March 2008
February 2008
January 2008
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
January 2004
December 2003
November 2003
October 2003
September 2003
August 2003
Blog Categories
software (40)..cocoa (21)
..heads up 'tunes (5)
..ruby (6)
..lisp (4)
..perl (4)
..openacs (1)
mac (21)
embedded (2)
..microprocessor (2)
..avr (1)
electronics (3)
design (1)
photography (26)
..black and white (6)
..A day in Sydney (18)
..The Daily Shoot (6)
food (2)
Book Review (2)
Notifications
Request notifications






