Skip to content

F2 WordPress Theme

I changed the wordpress theme to F2 and to show my appreciation to the author I sent him the pt-br translation files.

However, I think I won’t be using them, since I’m considering maintaining only an English version of this blog. Hopefully it will help me improve my English skills. We’ll see.

If I end up keeping the Portuguese version, I’ll definitely switch the translation plugin from qTranslate to Polylang or WPML. They do a better job handling translations as separate posts, instead of doing some crazy filtering magic like qTranslate.

No More Distractions

Yes, it’s been a while. I know.

I could start this post with the traditional promise to update this blog more frequently, but I don’t know if I’ll be able to do it as often as I would like to.

What I do know is that I’m making an effort to eliminate distractions so that I can focus on more important things like writing, reading (books) and enjoying life away from the keyboard.

I am very easily distracted (oh look, a shiny red ball!), so I deleted my Facebook and Twitter accounts. I know it’s 2012, but email still works. My smartphone will now be “just” a phone (heh).

distractions exist to comfort you. to numb you. to prevent you from caring. (Bulimia – Rebeldia Premeditada)

That’s enough for now. I need to get some s*** done today.

(Português) PHP Conference 2010 – Desenvolvendo Extensões PECL

Sorry, this entry is only available in Português.

PHP API to SpamAssassin spamd Protocol

On the past few days I’ve been working on a PHP spamd client, and I think it is somewhat usable for now since it already implements all of the protocol commands. This is release 0.1.0, so you might expect some API changes for the next versions. Feedback is always welcome. I tried to make this the most straight-forward as possible, abstracting some nasty things that happens under the hood, so you can do things like:

require_once 'SpamAssassin/Client.php';
 
$params = array(
    "hostname" => "localhost",
    "port" => "783",
    "user" => "ppadron",
);
 
$sa = new SpamAssassin_Client($params);
 
$message = file_get_contents('/path/to/message/file');
 
var_dump($sa->isSpam($message));
bool(true)

Methods available

ping()
Pings the server to test the connection
getSpamReport($message)
Returns a detailed report if the message is spam or null if it’s ham
headers($message)
Processes the message and returns it’s headers (like X-Spam-Flag and X-Spam-Status)
check($message)
Checks if a message is spam with the CHECK protocol command
isSpam($message)
Shortcut to check() method that returns a boolean
process($message)
Processes the message, checks it for spam and returning it’s modified version
symbols($message)
Returns all rules matched by the message
learn($message, $learnType)
Uses SpamAssassin learning feature with TELL. Must be enabled on the server.
report($message)
Report message as spam, both local and remote
revoke($message)
Revokes a message previously reported as spam

I’m still working on providing some good usage examples, but I’ve put (temporarily) API docs available here. In the meantime, you can browse the tests directory and learn some basic stuff. If you want to use this library to implement a spam filter for your mail server, maybe you should consider using the spamc command line utility or the Perl librarythat already comes with SpamAssassin (which was my main source of inspiration). This library is most useful when you already have stuff written in PHP and you need to do something with SpamAssassin. If you have a webmail written in PHP and would like to interact with a remote SpamAssassin server to report spam, for example. The project is hosted @ Github, so you can:

I owe you a PEAR repo to serve this package.

Packaging Perl CPAN modules as RPM with cpanspec

If you happen to use some CPAN module that is not already available in any repo (always check EPEL), you might consider packaging it yourself. It can really be a pain if you try to do it from scratch, that’s why you should consider using cpanspec. It’s a simple tool that will generate a specfile given a CPAN package name or package file.

Continue reading ‘Packaging Perl CPAN modules as RPM with cpanspec’ »