cat STDERR | rot13

Submitted by gwolf on Fri, 02/08/2008 - 11:52

Cannot help but laugh and share.
I've been triaging and trying to reproduce some oldish bugs on pkg-perl's packages. Some bugs are no longer there, some have to be forwarded upstream, and so on. Usual tasks, yes.
Until I stumbled with #406227. I just have to laugh and share! Hope nobody feels ashamed - The bug is the result of different people coding maybe under pressure and with quite different mindsets :)
For some reason I fail to understand, the submitter's test case (rot13 implemented over a HTTP proxy) is invoked in the report as ./rot13 2>/dev/null. Of course, when trying to debug a bug report, the first thing to do is not to ignore STDERR. So, off goes the 2>/dev/null. What happens next?

  1. 0 gwolf@mosca[2]/tmp$ perl ./rot13 &
  2. [1] 4394
  3. 0 gwolf@mosca[3]/tmp$ GET -p <a href="http://localhost:8080/" title="http://localhost:8080/">http://localhost:8080/</a> <a href="http://www.debian.org/<br />
  4. Can't" title="http://www.debian.org/<br />
  5. Can't">http://www.debian.org/<br />
  6. Can't</a> locate object method "filter" via package "UGGC::Cebkl::ObqlSvygre::fvzcyr=UNFU(0k604160)" (perhaps you forgot to load "UGGC::Cebkl::ObqlSvygre::fvzcyr=UNFU(0k604160)"?) at /usr/share/perl5/HTTP/Proxy/FilterStack.pm line 126.
  7. 500 EOF when chunk header expected

WTF... Well, at least the program name gives me a clue... Lets try to "decrypt" the error message...

  1. gwolf@mosca[4]/tmp$ echo 'UGGC::Cebkl::ObqlSvygre::fvzcyr=UNFU(0k604160)' | rot13
  2. HTTP::Proxy::BodyFilter::simple=HASH(0x604160)

hrm... How comes the filter is filtering its own code and only then refusing to find itself!? Ok, time to open up the manpage - Remember, I'm only group-maintaining this pacakge, I am not yet at all familiar with it! Ok, so the core of the filter is when the submitter states:

  1. my $proxy = new HTTP::Proxy();
  2. $proxy->push_filter(response => new HTTP::Proxy::BodyFilter::simple(sub { tr/a-zA-z/n-za-mN-ZA-M/; }));

While the manpage states it should be invoked as:

  1. my $filter = HTTP::Proxy::BodyFilter::simple->new( sub { ${ $_[1] } =~ s/foo/bar/g; } );
  2. $proxy->push_filter( response => $filter );

Of course, once looking at it, the answer is simple: The submitter left out which element to act on in the anonymous function body - The ${ $_[1] } =~ part. Adding it makes gur svygre jbex nf rkcrpgrq... Err, sorry - makes the filter work as expected.

Now, bonus points: For the non-Perlers out ther: How come we get the namespace translated as well? Oh, that's very simple: In Perl, as in Python (and concievably other languages I'm unaware of), the object is passed to any of its methods as the first argument. Functions in Perl receive their arguments via @_ (read: the default array). And, of course, the tr (regex-based transliteration) takes by default the first thing it sees - the object itself. And what happens when you apply a (string-oriented) regex to an object? Of course, it gets stringified - which, by default, in Perl means converting it to the closest possible description: "a hash reference blessed as an object of the class such-and-such at this memory location". That string gets worked on, and we get UGGC::Cebkl::ObqlSvygre::fvzcyr=UNFU(0k604160). This proxy does not die on very-very-short web pages, where the whole content fits on one iteration of the code (although it does not work correctly - the text remains unaltered, of course, as it was not worked on), but if the request spans several chunks, the second time the filter is called, it will be... just gibberish.

Oh, and what about the extra ${ (...) } around $_[1]? Oh, simple: The string is passed as a scalar reference, so it can be modified in place. Yes, it's the Perl way of pass-by-reference instead of pass-by-value (the default behaviour): Of course the parameter is only passed as a value. Only that the value is incidentally a reference - but who cares? ;-)

Anyway... Many oddities. I would implement the module in a completely different way, and it looks quite backwardish in my book. But then again, TIMTOWTDI.

( categories: )

Converting incoherent sets of data between charsets

Submitted by gwolf on Mon, 02/04/2008 - 23:33

Dato complains that converting changelogs to be UTF8-clean is not always as simple as running iconv - One of the reasons that took me so long to migrate my blog is that, due to having migrated (at different points in time) my previous CMS (Jaws 0.4->0.5->0.7), its underlying database (MySQL 3.4 -> 4.0 -> 5.0 IIRC), the distribution (Debian Woody -> Sarge -> Etch+backports), several reinstalls and all... Well, I had a completely mixed-up database, with some tables in UTF, some tables in latin1, some tables with mixed rows, some tables that for some strange reason had double-mixed rows (that is, that had UTF8 misrepresented as latin1 and then re-encoded into UTF8)... No, it was not fun to sort out.

( categories: )

Switched!

Submitted by gwolf on Mon, 02/04/2008 - 10:54

Ok, the time has come. I have postponed this change too much - But finally, after three months of having hired my Dreamhost account (and stating so in this very blog), I finally made the switch from Jaws to Drupal.
Now I only hope I don't flood any planets with my RSS (I was careful to check the dates are consistent, but you never know), finish moving over my static content (I carried over about half of it already), play a bit with the theme, and... that's it! :D
Anyway, I promised my oh-so-not-generic-but-what-the-heck Jaws (0.7 at least) to Drupal (5.x) migration script. It worked like a charm - Ok, I only used it to move blog and photo albums/entries, but that's at least the most typical use AFAICT.
Now, I'll have to understand still some more terms and details in Drupal. For example, WTF? Why was jaws_to_drupal.pl renamed to jaws_to_drupal.pl.txt? (stated content-type, I guess) Why do my uploaded tar.gz files get renamed to tar_.gz even if I explicitly requested to allow .tar.gz suffix uploads? (same thing, I guess)

( categories: )

Yet Another Ciclotón

Submitted by gwolf on Sun, 01/27/2008 - 23:44

Call me reiterative, but yes, it is this time of the month again: Last Sunday. Today we went cycling to my city's Ciclotón. Although Nadezhda already took part in the August 2007 ciclotón, I was flying in from Europe that day. When I did the Ciclotón in October, she was in Monterrey. Then in December, Rodrigo reminded us that we missed it. So, this is the first time I do the Ciclotón with Nadezhda! (To my defense: Yes, I sent a SMS to Rodrigo... But too late - He probably didn't plan it on time, so we just didn't meet once again).

And what, am I going to come and brag each time I take my bike out for a longer-than-usual ride? (40Km is no small feat. Well, not for me at least!) Probably not. But if you remember, I just got a new toy, and I can now prove it to you all:

( categories: )

Introspection in Perl

Submitted by gwolf on Thu, 01/24/2008 - 11:19

Some days ago, my RSS reader found Mark Jason Dominus' Help.pm - Yes, the module is (so far, at least - I could not find it on CPAN) only published as a blog post. But don't let that fool you - It's a beautiful (and simple!) Perl module that can help developers that are too lazy to go look up methods in the man pages.

Perl's introspection capabilities are not behind other dynamic languages' (i.e. Python's or Ruby's, speaking only about what I'm familiar with). However, it's used much more seldom, partly because Perl does not ship by default with an interactive console (such as Ruby's irb or Python's regular behaviour when called without an input script). Of course, writing a Perl console is an easy task, and good Perl consoles exist, although its use is not part of the Perl culture.

But of course, just glancing over MJD's code made me come up with a simple, yet useful, way to use introspection in Perl, usable as a simple one-liner. Say you want to look at all of the methods provided by IO::File:

gwolf@mosca[25]/tmp$ perl -e 'use IO::File; print join(", ", grep {defined &{"IO::File::$_"}} sort keys %{"IO::File::"}), "\n"'
binmode, carp, confess, croak, gensym, new, new_tmpfile, open, qualify, qualify_to_ref, ungensym
Want the scalar variables? Of course:
gwolf@mosca[26]/tmp$ perl -e 'use IO::File; print join(", ", grep {defined ${"IO::File::$_"}} sort keys %{"IO::File::"}), "\n"'
VERSION
Same goes for arrays and hashes. And, of course, leaving out the grep gives you anything. Yup, it's the magic package-name hash trick. Main difference between this and MJD's Help.pm? That Help.pm goes up the inheritance chain, and is thus much more correct.

Of course, I'll be uploading Help.pm to Debian very soon - And, why not, I think I'll add a way for it to query on different symbols, not just on methods. And the simple binary to call from the command line. Sounds very much worth it ;-) Thanks, MJD!

( categories: )

Don't need a weatherman to know which way the wind blows

Submitted by gwolf on Wed, 01/23/2008 - 19:59

This could have just been a nice Summer morning, uneventful as they usually are, were it not for the fact that it was already 19:00, and it was mid-winter. (with due apologies, of course, to Bob Dylan and Les Luthiers)

Nadezhda called me, warning me about a very dark sky and strong winds, and went off for her meeting. I told her weather looked decent from mx office... But started paying attention. And yes, wind was crazed. Hints of an upcoming power outage were felt in the Institute. I left my office as soon as I could. Cycling back home was quite a challenge - The 3.1Km route back home, usually much easier than the way there as it's mostly downhill, was quite a challenge: Biking with eyes almost-closed because of the flying leaves and dust, and little but menacing raindrops... Scary, all in all.

Anyway, it gets scary... At least one person was killed because of the winds not far from here. This city has the fame that febrero loco y los vientos otro poco (February is crazy, but the winds are even more). And the first crazy wind of the season are always scary.

[update] One person dead because of the strong winds in Mexico City; Power outages in several areas; Three more hours of strong winds expected; Heavy winds caused by the #24 cold front(?); Winds cause mayhem on DF streets;

( categories: )

Yay, new gadget!

Submitted by gwolf on Mon, 01/21/2008 - 08:25
A week ago, I got my fourth cell phone so far. This is the first time, however, that I pay for it - even though the first one I had was a very nice smartphone for its time (basically, a not-really-well-integrated Palm Vx and a bulky phone very worthy back in its time. Anyway - Some months ago, I decided I wanted a Wifi-able phone, in order not to need to carry around my laptop for simple tasks such as checking my mail. Shortly after I started looking for phones which fit my needs, I found Nokia's N95. The map-maniac in me found it had a GPS, and... Well, it just became matter of waiting until my phone company brought it to the Mexican market (as I paid about half its street-price... Y'know, points for customer loyalty, blah blah).
Anyway... I've been extensively playing with my new toy, and although I am still often frustrated by Symbian's so very-very-propietary-minded OS and general culture (it's amazing the number of for-a-fee very simple applications!), I'm very happy. So far, my favorite application (and, of course, the one that made me jump for it) is Nokia's Sports Tracker. While it does have some issues (particularly the web application - at least its interaction with firefIceWeasel is somewhat buggy; it abuses AJAX interaction and some pieces of information are just not linkable, they lack a proper URL), I'm delighted at using it - tracking my theoretically daily excercise sessions, be they excercising per se or my bike rides to work, linking photos taken during those sessions, tagging them to the point and moment they were taken (although, I must admit, it is awkward to take photos while running - And next to impossible while biking, of course).
Yes, to many this is not so impressive... But it is really the toy I was looking for.
( categories: )

World Social Forum 2008 - Another world is possible

Submitted by gwolf on Sun, 01/20/2008 - 23:10
A phone call in December made me very proud: A colleague I met thanks to the Espora collective told me she was involved in the Mexican activities for this year's World Social Forum (FSM Mexico 2008 site). The Mexican activities? Yes. This year, the World Social Forum will not be held at one -or several- distinct places, but it will happen globally. There will be activities in tens of countries. The activity program for Mexico (full PDF version) is quite loaded - And I was invited to give one of the talks, this Friday (Jan 25) at 12:00, about Free Software for a Free Society, in the Foro Derecho a la Comunicación track.
I am very honored by this invitation! I just spent a couple of hours organizing/going through the topics I will be presenting. I hope to be able to be at some other of the forum's activities, as it just is too important and interesting to miss out!

Royal abuse

Submitted by gwolf on Wed, 01/09/2008 - 10:54

I just went to our Institute's yearly ceremony of rosca de reyes. What's that? Well, according to the tradition, on January 6 the tres reyes magos (boringly translated to English as three wise men - It should be something like three wizard kings) payed a visit to the newborn baby Jesus. In Mexico, the tradition mandates that every family, group of friends, or whatnot should gather and eat rosca de reyes, a round, sweet bread, usually some 10cm wide. The rosca has some plastic babies hidden in it, remembering how baby Jesus had to be hidden and smuggled out of his birthplace. And, according to the Mexican tradition, if you cut your piece of rosca and get the baby, you are expected to buy tamales for everybody on February 2, día de La Candelaria. (why? Don't ask me!)

Anyway... An image is worth ~10Kb of UTF8 (so it's still better to describe it, as it weighs around 63K, but what the hell):

Two babies?! I was abused by the Three Wizard Kings! (at least it does not sound as sad as "I was abused by three wise men"!) I'll have to buy tamales for everybody on La Candelaria twice, even if they are no longer hungry!

( categories: )

Supertheory of supereverything

Submitted by gwolf on Wed, 12/12/2007 - 19:58

First time I had read the Bible
It had stroke me as unwitty
I think it may started rumor
That the Lord ain't got no humor

Put me inside SSC
Let's test superstring theory
Oh yoi yoi accelerate the protons
stir it twice and then just add me, 'cause

I don't read the Bible
I don't trust disciple
Even if they're made of marble
Or Canal Street bling

From the maelstrom of the knowledge
Into the labyrinth of doubt
Frozed underground ocean
melting - nuking on my mind

Yes give me Everything Theory
Without Nazi uniformity
My brothers are protons
My sisters are neurons
Stir it twice, it's instant family!

I don't read the Bible
I don't trust disciple
Even if they're made of marble
Or Canal Street bling

My brothers are protons
My sisters are neurons
Stir it twice dlja prekrastnih dam...

Do you have sex maniacs
Or schizophrenics
Or astrophysicists in your family
Was my grandma anti anti
Was my grandpa bounty bounty
Hek-o-hek-o-hej-o
They ask me in embassy!

'Cause I don't read the Bible
I don't trust disciple
Even if they're made of marble
Or Canal Street bling

And my grandma she was anti!
And my grandpa he was bounty!
And stir it twice
And then just add me!
Partypartypartypartypartyparty
now afterparty...

That's the Supertheory of Supereverything, by the gypsy-punk Gogol Bordello. I was really surprised to find their Super Taranta! at a local music shop. Of course, five minutes later, we were heading home with our shiny and oh-so-very-green purchase. Highly recommendable!

BTW, does anybody else think that Eugene Hutz is Larry Wall's evil twin? (No, and I don't only mean it because of their choices in background colors)

( categories: )

Debian Developers fail Turing tests?

Submitted by gwolf on Fri, 12/07/2007 - 12:31

Ok, so two people replied to yesterday's post about triple negations - Dato (by email) and MadCoder. Both, said basically the same thing: || false and && true are silly noops. And yes, knowing this, I added them. Why? Clarity... At least having them at the end of a test shows the statement is of conditional nature (and not just another obscure attempt to do ${DEITY}-knows-what). They at least look cleaner than a one-line-squashed if block in a makefile. To me, at least ;-)

But... If you noticed this post's title, it goes beyond this comment - One of the most benefical effects I noticed when I installed Jaws 0.7 (over 0.6, of course) is that I no longer had the swarms of spambots flooding me - I often had hundreds of comments a day, and nowadays I hardly get any spam. Now, I fail to see what is so strange in my blog's comment forms (it does not even have any obvious Javascript, although it does obfuscate a bit the source of the captcha image). And you are not the first Debian people to complain you cannot post comments to my site. Strangely, few non-Debian people have ever complained.

And yes, the spam has stopped, almost completely.

So, Debian guys: Are you human?

( categories: )

Triple negations

Submitted by gwolf on Thu, 12/06/2007 - 15:18

I'm packaging Ruby's PDF::Writer module for Debian - It is a simple module and (almost) ready for upload. But anyway, it carries some issues I had to bring to debian-legal's attention, mainly, five files licensed under Creative Commons licenses (specially two of them, which are under its NonCommercial variant - clearly non-free), so I'm repackaging the .orig.tar.gz into a +dfsg version.

But I know I'm a lazy and sometimes stupid bum. Even more, the package will be group-maintained by the pkg-ruby-extras team, so we must be as careful as possible not to forget to remove the non-free material - To remove two scripts, and to replace three images with free equivalents I just made. But hey, tell me if this does not feel ugly to you. At least to the bits of you who learnt human grammar:

clean::
	# Make sure we strip out non-DFSG demo files from the orig.tar.gz
	[ ! -f demo/qr-library.rb -a ! -f demo/qr-language.rb ] || false 
	[ $$(md5sum images/bluesmoke.jpg | cut -f 1 -d ' ') == 0586eca5af7523ab871609eceb44724a ] || false
	[ $$(md5sum images/chunkybacon.jpg | cut -f 1 -d ' ') == a000b1917142ce332fd3474f0722cd6f ] || false
	[ $$(md5sum images/chunkybacon.png | cut -f 1 -d ' ') == 927feec1cbbf23c4d89a4a5ad88e6d0f ] || false

Triple negations. How nice.

( categories: )

Digging into Drupal

Submitted by gwolf on Thu, 12/06/2007 - 12:06

As of late, I've shifted quite dramatically my sysadmining/development activities. On the development front, although Perl is still my mother tongue and I maintain many systems I wrote with it (and my main involvement in Debian is through the pkg-perl group, of course), I've been largely switching over to Ruby - both under the Rails framework and doing standalone stuff.

But somehthing that's new to me (well, relatively - it has been observed I have been playing with the idea in and out for some more time) is entering this maze of twisty little passages, all alike called Drupal. What can I say? I'm quite surprised by it. It is such a reach CMS, and so twistable for almost-anything, that it still defeats me.

I've been asked (ordered? pushed?) to propose a complete plan to replace my Institute's current static-and-butt-ugly-HTML site with something dynamic and manageable, so, of course, this last week has been an intensive Drupal crash-course for me.

Drupal itself is quite complex, yes, and I thought I had it mostly mastered for the trivial tasks. But then, I started looking for some I-thought-quite-simple extra thingies - And I started discovering its user-contributed modules. I've been having quite a bit of fun with them, and as I hate messing up my clean and nice installation, I've even set up a Drupal5 modules APT repository for Etch, where I'm putting the modules as I process them.

As I'm really not into PHP, and I still lack enough of the Drupal framework understanding to really step forward and become responsable for them, I'm not yet even suggesting packaging them for Debian - but a time might come where I upload them as well ;-)

BTW, in case somebody is wandering about this Jaws-to-Drupal scripty I mentioned that other time: It basically works for blog entries (as you can see in my test site - barring some trivial latin1-UTF discrepancies). I have not yet migrated because I'm also trying to migrate my Phoo photo galleries to Acidfree albums... And it's quite a more challenging task than just migrating blog+comments. But soon, I hope - I have a bit more time than in the last weeks to be able to play with it. Anyway, here it is as it is.

( categories: )

Welcome on board!

Submitted by gwolf on Thu, 12/06/2007 - 11:40
Yes, yes, I know I already said so, and surely in a more visible site, and even he also announced his victory over DAMnation... But still, having more Mexicans in this little project I call home makes me very happy. So, welcome on board, Rodrigo!
( categories: )

Is it already December!? Oh, crap...

Submitted by gwolf on Fri, 11/30/2007 - 19:38

Last weekend, Nadezhda and me went to the the San Nicolás Totoloapan park, a beautiful area in the slopes of the Ajusco mountain. We cycled only for a short while, as we are not really used to slopes nor to non-paved roads - But all in all, it was very fun and a very nice time.

But, only now I realize, thanks to the oh-so-always-nice Rodrigo, that, because of having fun while being at the Ajusco, we completely missed November's Ciclotón.

Crap.

Cycling over 30 Km in Mexico City is very fun. Nadezhda loved it when she did it in August, just the day I came back from Vienna. I loved it when I did it last month, when she was in Monterrey. But, being together, we insist on missing it. Bah. Anyway, this Sunday we will have the short (~15Km) ride in Coyoacán.

( categories: )
Syndicate content