Tech: PHP PEAR Extension silliness

Website using Drupal with PEAR extensions for users to export class schedules into an Excel file.

Certain class schedules won’t export. Throwing an error like:

Fatal error:  Call to undefined method PEAR_Error::write() in /opt/lampp/htdocs/xxx/xxx/xxx.module on line 166

The line of code was trying to write some stuff into a field.

$worksheet[$i]->write(0, 0, $group, $info);

I first thought special characters were causing the problems. Since it’s only making a mess on schedules with parentheses in the fields. Used preg_replace() to sanitize the necessary. Still the same error.

Turns out, the problem is this. This is a 5 year old bug, and I dismissed it when Google threw this result at me. Thought the PEAR would’ve been sorted out ages ago. And there wasn’t an issue with my worksheet names.

Seems that the problem was never resolved. There’s a limitation in the length of an Excel worksheet name. The PEAR is aware of this. And how it handles the error, is to crash routine, and throw you a cryptic error.

Thus, it’s as easy as rewriting line 325 and line 333 of /PEAR/Spreadsheet/Excel/Writer/workbook.php

Around line 325 and 333, just add the following respectively:

$name = substr( $name, 0, 30 );

$name = substr( $name, 0, 27 ) . ($index+1);

To make sure the worksheet name is not over 30 characters long, and is not repeated. Then everything works. Again.

Posted in Tech | Leave a comment

Tech: EMail-Merge with Microsoft Office 2007

Synopsis: IT IS TERRIBLE!!! DON’T DO IT!!! Google for a solution using OpenOffice!!! GET OUT WHILE YOU STILL CAN!

The adventure started easy enough… We are migrating about ten thousand students over to a new email system. There’s this Live@Edu email system that someone keeps selling to management, and I can’t avoid it.

I jumped all the hoops and have created those ten-thousand mailboxes in the MS Exchange server. It’s kinda cool that I can do some management via PowerShell2. It’s painful to learn, but most useful when management suddenly changes their mind and decides that student mailboxes should not have GAL (Global Address List), and I needed to effect this change to mailboxes I’ve already created…

So I’ve got all those mailboxes ready, I figured I could just prepare an Excel sheet with all the student names, current email addresses, email password etc and just mail-merge the new email login/passwords to everybody. Job done. Easy?

Apparently not…

Managed to import a CSV file into the recipient list. Filter it to only send where “EMAIL” field is not blank. That’s kinda nifty. Got the form letter typed out nice and good.

Attempt #1, the “Finish & Merge” is completely gray-ed out. Or, I can set the merge to print, but NOT to Email.

Cause: My default email client is Thunderbird, like most sane people. Word 2007 attempts to merge out to Thunderbird, and gets stuck. Without showing any hanging dialog boxes or any indication that it’s stuck.

Solution: Set Outlook 2007 as the default mail client. Close all Office applications. Then reload the Word mail merge document and re-do the shit. And finally, the “Send Email Messages…” at Finish & Merge is no longer gray-ed out.

Attempt #2, Outlook now starts throwing up a dialog box, warning you that a software is trying to send an email, and asks you to confirm that you want to do this, and make you click an “Allow” button. After a 5 sec mandatory pause. OK, I can appreciate this ‘feature’. You don’t want innocent machines to be infected by malware and become inadvertent spam relays. Right. That’s like GM designing a car with SQUARE tyres, because round tyres make the car move too fast and causes accidents.

I obviously can’t sit there and click a button every 5sec ten-thousand times. So there must be a way to stop it from doing that.

Most obvious setting to fix, would be in Outlook -> Tools -> Trust Center -> Programmatic Access

Maybe I can set it to “Never warn me…” but the options are gray-ed out. I was using Vista. It’s fine on a WinXP machine though. But even setting it to “Never warn” on the WinXP doesn’t make this dialog disappear.

And enabling the gray-ed out settings in Vista was all but impossible.

Figured it’ld be some kind of policy settings. Found this to maybe be relevant… Downloaded the 2007 Office System Administrative Templates. Did some random shit or another to install those templates. Look for relevant settings and fiddled with some. Mostly to use the admin templates to override the Programmatic Access in MS Outlook.

Still didn’t work.

Rebooted.

No work.

Gave up. Left it over the weekend. Came back to it 4 days later.

And it works.

Somehow, I can now Mail out without the stupid interference.

But…

The Outlook.com server bounces the 501st email that I send out. There’s a 500 mail limit per user account per dunno how many hours.

Solution: created 20 email accounts to shoot out 10k worth of emails.

So. Much. Fun.

Posted in Tech | Leave a comment

Tech: Absolute-Privacy plug-in for WordPress

Very useful plug-in.

Setting up a blog to act as a collective brain for the department. Thus thought of using WordPress and then use a plug-in to make it private so that only those who are able to log in can view the pages.

Very easy to set up. And just works.

Posted in Tech | Leave a comment

Kodiak paying for itself

There’s a batch of BRAND-NEW Pragel kitchen counter-top selling for a song at Ikea’s AS-IS corner. 8′ long, black laminate surface. Only RM120.

My current kitchen counter is already water-damaged. My fault for not taking better effort to do the plumbing better. Also the fault of silly housemates who toss wet rags carelessly onto a solid wood countertop.

So this sale is JUST the opportunity that I’ve been waiting for! And also a chance for my D-Max to show its mettle!

But an 8′ long piece of chipboard isn’t fitting into a 4.5′ long bed.

I don’t have a sports bar to lash the thing properly. But a piece of styrofoam packing from a washing machine, some duck-tape, and 2 lengths of thick bungee… And I managed to drive it slowly back to my apartment.

Saving RM65 in delivery fees.

MUAHAHAHHAHAHAAAaaa

~~*** Unlocked IKEA Achievement ***~~

In honor of this achievement, I officially christen my truck, Kodiak!

Posted in Me! | Leave a comment

Book: Dragon Haven – Robin Hobb

This is the continuation of the earlier book, Dragon Keeper. Basically, the book ran too long and Robin had to break it into two.

The sea-serpents which featured as a side-story in the LiveShip Traders finally found their way up the Rain Wilds River to their old cocooning grounds where they will finally pupate into dragons. The serpents have been wandering the seas for centuries, after a geologic catastrophe destroyed their dragon ancestors and their Elderling helpers. Even the taste of the river changed after the event, so the clutch of serpents who escaped the disaster were unable to rediscover their cocooning grounds and dragons were lost to the world.

Until a long buried cocoon was dug up, and Tintaglia the last queen was birthed, and she finally guided the serpents home.

But the serpents were too old. Too lean. And a lone dragon was not able to help all the serpents. Less than a score of serpents survived the metamorphosis, and everyone of them were stunted and deformed in some manner. Whereupon a disappointed Tintaglia got distracted elsewhere with the events in The Tawny Man series, digging up another dragon that had been trapped in ice.

The sad mutants wallowed in the mud, becoming a burden on the humans who allied with Tintaglia, until the events in Dragon Keeper. The book ended with the dragons halfway upriver, questing to rediscover the lost Elderling city of Kelsingra half remembered in their ancestral memories. Aided by a Liveship barge captain, a few hunters with bad intentions, a bunch of kids, a scholar, and her gay friend.

The biggest moment came for me when I discover that Maulkin did not truly survive the metamorphosis. Every dragon adopted a new name upon birth, so I couldn’t match them up with the serpents I remember from the LiveShip books. From tone of voice, I could only match up Sintara to one of the serpents, and I pretty much assumed that Maulkin is Mercor, seeing how he formed the plot to ‘lead’ the expedition to Kelsingra.

This is one of the most fantastic gimmick that Robin Hobb uses. The sudden and unexpected reveal, in a manner more subtle, more grandiose and more astounding than any Agatha Christie. In the Farseer stories, when the nature of the ‘man-made’ dragons were revealed. In the Liveship stories, when the identity of Amber was revealed, and the nature of Paragon was told.

The reveal in Dragon Haven pales in comparison. The fact is, that Robin had already spent 9 books creating this realm. Almost all the mysteries have been peeled away. So there’s little that’s surprising in the latest two books. Part of it even stank of Gossip Girl, as Robin tried to preach chastity, and one must stand up to peer pressure, and taught that rules are there for a reason, and promiscuity will result in pain and a dragon will munch on your mutated still-birth.

It took me out of the world for a bit, but that’s OK. I’ve been in love with this realm since ages ago. Although nothing will ever be as brilliant as The Farseer trilogy, it’s still fun to revisit the world every once in a while.

Posted in Books | Leave a comment