Monthly Archive for February, 2007

Vistas

Vistas

Loved the Pokémon reference. :) Hey, MS could actually make it so that, to catch get all the features, you would need to trade for them with someone who bought the “alternate” version, which in turn would lack some features found only in your version…

Naaah… that would be too simple.

Source: Penny Arcade

The abortion referendum in Portugal

Sorry about the offtopic post, but I really have to write about this, here.

While way too many people were too self-centered (”this doesn’t concern me, so I won’t move my ass”) to do anything at all (only about 40% of the population actually voted), still, the results were positive: the “don’t send women to prison anymore” side won. It shows that the Portuguese people are slowly, but surely, leaving the Middle Ages.

Today’s referendum, no matter what the fundies said, wasn’t about “saving lives” (anyone who really needs to have an abortion, will almost surely get one — even if it involves falling down a flight of stairs –, and who is concerned about their lives?). It was, instead, a choice between those who believe people should be free to decide things for themselves, and those who feel they have the “right” to control other people’s lives, to impose their own morality upon the rest.

Fortunately, and while the result isn’t “binding” (due to the low turnout), the former group won. It’s great to feel proud of my country, for a change. :)

Weirdness with different browsers: Safari, and the rest of the world

A couple of hours ago, I received an email from a reader of Planet Atheism tell me that it didn’t show up correctly in Safari: fonts were huge.

(Incidentally, PA is a month old today, and, apparently, had that problem since the beginning. Not too many Safari users out there, it seems… or, else, they’re shy! :) )

Well, I knew it displayed well in Firefox, IE and Opera, so I tried Konqueror, which is supposedly “closer” to Safari (which was originally based on KHTML). No problem there, either.

As I don’t have a Mac, I confirmed with another Mac user (thanks, Ricardo!) that there really was a problem (not that I doubted the guy, but it might be something only on his system), and, so, I started looking. Fire up the W3 CSS validator, and… it complained about this line:

font-size: 62,5%;

The problem, which you may already have spotted, is the comma: it should be a period (or should I say “dot”?) instead. My guess (which was correct) was that Safari was reading that as “625%”. So I changed the comma to a period, and… everything became smaller in Firefox! :shock:

Yes, Firefox (and every other browser except Safari, apparently) completely ignored that line because of the comma. Safari, on the other and, interpreted it without the comma.

Highly illogical, if you ask me… if you want to “do your best” to interpret code, the comma should be replaced by a dot, not completely removed. :) But it’s funny that the other browsers were ignoring that line, as well. I have since commented it out, as I had gotten used to a bigger font on PA. :)

Incidentally, every single Moonmoon installation probably has this bug. I’ll try to report it to the author.

Announcing DailyTasks 0.1

A few minutes ago, I submitted my first piece of software to Freshmeat (it hasn’t been approved yet; it will probably take a few hours): DailyTasks. It’s a small utility, written in PHP, with both a command line mode and a web interface, which, surprisingly enough, reminds you of daily tasks. :)

The web page linked above tells the “story” in more detail, but, basically, I’m much too chaotic to use traditional task management programs (every time I tried, I seemed to spend more time updating tasks than actually doing them), but I wanted something to remind me, every day, of doing something — from “clean up GMail’s spam folder” through “update a blog” to “do the laundry, if necessary”. :) There was already a similar program (frequent-task-reminder), but it lacked some features that I wanted (such as non-accumulating tasks), and so I wrote my own.

It’s really basic stuff, with no bells and whistles, and the PHP code would probably scare you, so impressionable young people should avoid looking at it. :) But maybe — just maybe — you’ll find it useful.

More about tidying up HTML

If you’re curious about the last post

I accept that making some HTML code validate in validator.w3.org shouldn’t be the be all, end all of the problem. A piece of code can validate and yet be… horrible. On the other hand, a piece of code may not validate because of a minor problem, and yet be better than 99% of what you see out there.

Still, that applies mainly to your code. What if you’re aggregating other people’s code? What if they’re using bad HTML, which their blogging systems (mostly Blogger or WordPress) automatically converts to a feed, which is then converted back to (simplified) HTML by a Planet? And what if you want all of that to validate?

Well, tidy works very well; it fixes the worst problems, mainly, badly nested code, and unclosed tags. But… well, if you’re being pedantic (like the W3 validator is), then there are still problems.

They’re mostly one of the following: 1) img tags without an “alt” attribute, and 2) proprietary attributes.

tidy, by default, doesn’t deal with those (since its point is for you to correct your code, and those problems should really be fixed in the code itself). But you can make it do so.

How? Well, here’s the command line I’m using for Planet Atheism:

/usr/local/bin/tidy -wrap 79 -m -i -utf8 --alt-text "" --drop-proprietary-attributes 1 -asxhtml filename

It should be obvious what each parameter does. The “ alt-text "" ” part adds some empty alt text to any img tag that hasn’t got one. The “--drop-proprietary-attributes 1” part removes those weird attributes inside other tags, which make the W3 validator choke. I don’t want them anyway, since a Planet site is supposed to display a basic version of a post — not a Flash-y, YouTube-d, animated one.

The result is: complete W3 validation, and readable code. From many other blogs, by many different authors. Automatically. What more could anyone want? :)

Adventures with moonmoon and tidy

As I’ve mentioned here before, for Planet Atheism I’m using moonmoon, mostly because 1) everyone else uses planetplanet, and 2) it’s in PHP instead of Python, and I know a little PHP. :)

moonmoon is still on version 0.2, however, and, while it removes “dangerous” tags from feeds automatically, it doesn’t (yet?) deal with unclosed tags. As most of PA’s members are as far from being geeks as possible, they tend to use WYSIWYG editors, and aren’t really worried about “validating HTML”. So, from time to time, a post would make every other post after it show in bold or italic. Annoying, to say the least.

Yesterday, it was even worse: some posts “spilled over” to the sidebar. And it wasn’t just one post causing it, but two, from different blogs, at the same time!

Well, enough was enough.

“Fixing” moonmoon (or, more precisely, SimplePie) was out of the question; I simply don’t know enough PHP / XML parsing to do it. But I tried something else: I saved the generated HTML to a file on the site’s directory, and used tidy on it. Surprise: this new version was perfect! So, I got the idea of using tidy on the generated HTML every time.

Now, PHP has a tidy module, but in PHP5 I would have to compile PHP by hand. Ubuntu doesn’t have a package for that module, unfortunately, and I really didn’t want to make an exception from using apt packages on that server. So, I had to find another way.

My solution was to dump all the page into a buffer (using the ob_ functions in PHP), save it to a temporary file, use the system command to apply tidy on it, load the altered file, and show it to the browser. It’s probably not very efficient, but it works… better than I expected, too. It may be a crude solution, but I’m proud of it anyway. ;)

Dealing with a PHB

Dilbert 20070202

Dilbert (unlike, say, Wally) tends to be quite naive from time to time, but for once he achieved true genius. :)




Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal
Creative Commons Attribution-NonCommercial-NoDerivs 2.5 Portugal