Infinite Pig Theorem

Procrastination and elucubrations by a code piglet living in New York City.

May 2 2008

POST over mod_perl handlers with unusual content types

Recently I had to deal with POST requests on mod_perl 2 on a custom XML-RPC webservice server we have been developing and maintaining over the last year (we are actually moving it to REST some time in the middle future). It was time to move some of our base modules from a couple of CGIs to the power and muscle of mod_perl.

So, while dealing with POST requests (like XML-RPC is actually specified) I faced the issue that I wasn’t being able to get the POST data on the PerlResponseHandler phase. I was probably not reading it correctly, I got deeply into it and even read some libapreq source code. All I was getting was some nifty message like “not supported”. After reading some documentation (and, to my own shame, the Apache2::Request front page pod) I found out that the usual:

    use Apache2::Request;
$req = Apache2::Request->new($r);
@foo = $req->param("foo");
$bar = $req->args("bar");

will not work on your POST if the content type is different than application/x-www-form-urlencoded or multipart/form-data. For example, say, XML-RPC! So, in case you actually need to read POST data on your mod_perl 2 handler where it’s not a form or a file upload, you can read the data manually (I didn’t find a simpler way to read the data, actually):

sub handler {
my $r = shift;

return Apache2::Const::HTTP_BAD_REQUEST unless
$r->method eq "POST" and
$r->headers_in->{'Content-Type'} eq 'text/xml' and
$r->headers_in->{'Content-Length'};

my $length = $r->headers_in->{'Content-Length'};

my $xml;

while ($length) {
$r->read($xml, ($length [less than symbol] 2048) ? $length : 2048);
$length -= length($xml);
}

...

And you are ready for booze.


Comments (View)

Blog Normalize on The Perl Foundation

So I wrote an entry on my tumblelog about what’s going on with my life currently. Since Tumblr’s feed doesn’t get pushed immediately, I showed the post to my co-worker and friend Chris, before it hit the planets:

- So, yeah I have my blog since it’s syndicated on Planet Debian and other small feed aggregators -I said.

- But do they really care about your bike, your chess games or you attending that conference? -he asked-, I mean, I do care, but people?

- Well -I replied after a quick thought-, I think that’s how personal blogs work.

After a deeper thought I just realized that indeed no one cares and deleted the entry before it was pushed to the feed, updating it on FeedBurner, etc. It was a nice awakening.


But on a bit more interesting (for people) things, The Perl Foundation is currently requesting comments on the projects they received for grant requests. My proposal is there, “Solidifying and Extending the Blog Normalize project”. I do think there are some other more deeper projects, of course, but I think B::N is also an interesting one and the amount requested is not as big for other projects, so it’d be nice to give it a try.

I believe B::N is a good idea that could be enhanced nicely. I proposed the idea to the TextMotion developers yesterday on IRC (since that’s one of the CMS there would be a connector for -as of the grant proposal-). After deeper discussion, CMSs will not make translators for a lot of projects into theirs, but B::N would, so maybe we could make some sort of webservice that CMSs could call on their installation phases. That, or the user at the end could actually do the conversion himself locally.

Having the proper information, one could be able to get from TextMotion to Wordpress, to Blogger, to Joomla, to Tumblr, to MovableType and to TextMotion again, making a transparent circular transformation.

Some of this is currently possible with the few code I’ve written for it, currently in CPAN (and a bit deeper proof of concept); if you are interested, please leave your comments on the Perl Foundation blog entry. And review others too. At the end, I might end up doing the project myself, but if some money is granted to do so, why not apply to it, that’d just speed it up.


Comments (View)
Apr 20 2008

GMail and Sup, the smart way

I’m a person who isn’t satisfied with a lot of things. This both affects me and helps me on several circumstances in life, such it is.

The latter also affects my way to deal with mail, mail serving and MUAs. For years, I was a strong Novell Evolution user, mainly because it was quite easy to use, it was pretty and it used to understand the needs that people like me, involved in a lot of things (some of the worthwhile, some of them shitty), required. But in the last couple of years, it began to bloat, to handle connections Bayesian filters and SpamAssassin in a way that was utterly broken and decomposed.

I took a break years ago, and tried Mutt, as many free software folks and Debian developers use them on a daily basis to deal with even more incoming mail. I actually liked it, but I was just unable to deal with spam too. My local config was probably broken, fixing it was an obscure fart of Benedict XVI and hidden folders for mailing lists were just a way to forget that I actually was subscribed to mailing lists and focused only on the incoming mail on the inbox.

I then tried KMail, since I started usign KDE. It was good enough for it was sometimes slow when trying to load or search on about 100’000 mails and it just didn’t fulfill me. I also tried Thunderbird which only made me hate its very closed format to display its ugly UI. Besides, a lot of things on it were getting my angry, like the message filters, etc.

So I just didn’t give a damn and moved my whole personal mail accounts to Google Apps, giving an opportunity to a totally different approach on mail handling. So I started using the Web interface of GMail. At first I was shocked watching me dealing with a Webmail but after a while I started getting used to it and liking it. Its way to put all conversations threaded on a central inbox was sweet (i was able to filter, tag and take out of inbox too). So I liked it. Some things have never liked me whatsoever: It will always use your default mail address to reply to all messages, even if they are delivered to another recipient, which I consider retarded; its way to let users to top-post, etc, (you should also see how debian-private is seen on GMail and how the google sponsored links propose products based on all its threads xD). The good thing here also was that while not being a total purist, I loved that most spam has automatically handled for me, oh thank Lord I’m a lazy bastard.

Then I found Sup, which I think is like GMail but on mutt. It is written in Ruby and distributed as a gem (I’d prefer it to be in C/C++, but I’ll always give the benefit of doubt). Its main feature? A console mail client featuring GMail’s features, such as, one inbox, one big archive and labels all over the place, which is exactly what I was (probably) looking for. As the time of writing,Sup can only connect to IMAPs remote servers or read a number of local file formats. So, I undusted fetchmail and set it up. Since all my mail accounts now are forwarded to the main GMail account, I only need to handle one fetchmail config to get messages with POP (and some procmail recipes salting touch).

Here comes the sweetest thing from all this setup, by enabling GMail’s POP support, you can also specify if you want it to delete the GMail copy or store it. Since I’ve used 2% of all my storage, the best thing to do right now is to store and archive, which means that while i download all my email everyday and several times a day, all downloaded copies are also being stored on GMail, so in case I don’t have access to my machine, I can still find messages on the web interface. GMail also works nicely when you are sending an email from your remote mail client and using GMail’s SMTP, then also the mail you are sending gets stored on your GMail web interface, which is totally cool.

So I think I’m mildly content now with what I have. This also leads me to another awesome feature for me: Spam gets processed by GMail before I fetch it, so most of my downloaded POP mail is ham. In case I want to see some spam, the web interface will have it as usual for 30 days before being deleted.

I like to improve my time for productivity, to get more things done in less time, I do like learning about it, and the proof of concept for GMail handling being used by Sup and the free facilities that Google offers to dudes like me is just a great of avoiding procrastination. It’s a hell nice bag of features for me, and probably for you, why not try it?


Comments (View)
Apr 17 2008
Hell, yeah! Are you? Hell, yeah! Are you?

Comments (View)
Apr 14 2008
“Mujer, tú eres toda una geometría.
Tu tienes el pudín como me gusta:
Estira’o con estrías,
como de repostería;
con la falda corta
al estilo de Miami
enseñando la mitad del salami.”
Calle 13 wisdom.

Comments (View)
Apr 7 2008

Exhausted

We took two days off and went home to see our folks, family and friends. Superb.

  • The good: Mexico City at around 30C.
  • The bad: Getting a bit more exhausted than I usually am.
  • The ugly: MTA Subway. For real, ultimately, we cannot trust it anymore on our way to and back JFK. Ugly and sad.

Comments (View)
Mar 23 2008
“I guess I am talking more about the fuss involved, and the paranoia around GPG-zealots, like there are many in Debian. GPG is not the holy grail, it’s a tool which doesn’t actually fit the real world (you have to be a hacker to use it, basically), it’s misunderstood in many ways (see keysigning), and yet, it’s a great way to waste your time with it for minimal security benefit.” Martin F. Krafft, on the debian-private mailing list; accepted to be quoted publicly off-list.

Comments (View)
Mar 20 2008

WWW::Tumblr

After a while, I ended up building WWW::Tumblr (implementing the Tumblr API), so that Blog::Normalize::Tumblr can easily replace scrapping. The interesting part would be to write small applications to interact with the WWW::Tumblr to handle your tumblelog. Only file uploads missing for now. For now.

Comments (View)
Mar 18 2008

Joerg, Blog::Normalize is your bitch.

Although it’s not even released, B::N::Blosxom could have been a breeze.


Comments (View)
Mar 17 2008
Hehe. Hehe.

Comments (View)
Page 1 of 60