Code Profiling

April 27th, 2007 in Coding - No Comments

While running some tests on my local machine, I discovered a certain content item on Authware took between 2.5 and 2.9 seconds to load — when nearly every other one got loaded in less than 0.7 seconds. There were some basic references to clone — especially when determining the book name for a certain content item and discovering the book was it’s own parent — and I naturally erroneously assumed the overhead arose in those sections. Doing a manual copy of all the elements I needed instead of cloning changed nothing.

Something about code profiling from George Schlossnagle’s Advanced PHP Programming came back to me, and the hunt began. I must have been typing in the wrong stuff because only commercial products kept coming back until I got a Sitepoint article on XDebug.

Downloaded it, got WinCacheGrind and spotted the problem in less than a minute. That ‘nifty’ html_2_xhtml function I wrote sometime before when I was just starting out with regular expressions did a lot of arcane stuff with the e modifier of preg_replace.

Solution: swipe the wpautop and wptexturize functions from WordPress. The slow content item runs in less than 0.6 seconds now, and the other items take between 0.1 and 0.3 seconds to process. And er, the PHP website warns about using strstr just to determine if a needle exists in the haystack. Replacing it with strpos in my own version of wptexturize saw an increase in response times (by about 17 milliseconds).

Let’s hope I don’t keep profiling away instead of doing some real coding in the next few weeks.


March 6th, 2007 in Rants - No Comments

When I first wrote Authware I needed a WYSIWYG editor. I wanted one written in PHP that was basically drag and drop.

I couldn’t find a basic TinyMCE-PHP implementation back then. FCKEditor (it’s come a long way in the last two years) gave me a lot of bad code. By chance I came across Innovastudio‘s editor. It did everything it said it would — the problem was, it wasn’t free.

After some more scouring I came across Solemtra’s Spaw Editor. It gave me some pretty bad HTML code but I wrote a simple regexp matching function that converted all the uppercase tags (a la IE) to lowercase and did some font to span tag conversion.

Looking back now, am I glad I made the decision? You bet!

For one, it gives very very XHTML-compliant code now (no FONT tags + lowercase characters), works in Opera 9 (surprise!) and still has a nifty PHP class I can instantly plug in.

I’m off to look for a PHP Word to HTML parser. I need one badly :(.

Ethical Freelancing

March 5th, 2007 in Rants - No Comments

I’ve getting some extra pocket change for a while now by picking up freelance jobs. So far, I’ve been most successful with Scriptlance.

From an ethical viewpoint how do you respond to a [fishy] project that asks you to create 100 fake MySpace profiles or these ones that ask you to spam blogs, forums and social networks? On the one hand you’re making your cool money and on the other you’re contributing to problems.

Heck, I deal with spam everyday on my blogs. I wouldn’t want to help someone write a script that’d pass my own filters and hit my own blog.

Here’s the final clincher: a script to achieve higher appeal than MySpace between $100 and $500. If I had such an idea, I sure wouldn’t develop it and sell it for such a measly price.

So far

February 17th, 2007 in Coding - No Comments

We’re coming along nicely aren’t we?

Authware Screenshot

On WritingInn

February 10th, 2007 in Web Server - 3 Comments

I know this is lame but I haven’t posted here in ages.

The way the new version of Authware’ll work, we can have for user profiles if a friendly url handler is defined. I recently did some Windows hosts file tampering, redirecting a new domain name ( to my system for testing out WritingInn in realistic conditions i.e.

I still haven’t quite gotten the hang of virtual subdomains on Windows XP using Apache as I’d have loved to do the sort of implementation Blogger does for WritingInn but since Hostmonster doesn’t support it, I’ll settle for for user profiles.

Well, who knows — if I’m successful I’ll probably purchase VPS hosting elsewhere and move.

Enough with the rants…

Goodbye Google Reader

February 8th, 2007 in General - No Comments

I know Google Reader‘s still in the Google Labs section but I’ve had enough trying it out for the past one week. What feed aggregator marks feeds with the time it retrieves them instead of fetching what’s in the Atom or RSS information?

I could handle that for a while but I guess enough becomes enough when Google Reader starts fetching posts made in Jan 2006 and showing them as new — and keeps re-retrieving them after you mark them read. I’ve felt like a fool when I made comments on long-buried posts made so long ago, the blog owner’s probably forgotten them.

Goodbye Google Reader, hello SharpReader


January 7th, 2007 in OS - 5 Comments

Okay, I’ve had it.

This is the second time I’m installing Kubuntu on my system. As soon as I update via Adept and restart, I find I can’t log in. It authenticates me successfully but brings me back to the login screen.

What’s worse, it eliminated the bootloader on my first [Windows XP] hard disk and installed GRUB. Now I’m going to have to repair Windows so I don’t have to be on my toes to while logging in select XP before I can do any work.


December 23rd, 2006 in General - 1 Comment

I’ve long had a dream of connecting with other writers on the web. Paid for. And I’m not too sure I like any of the others I’ve come across. It’s because of just this, that I decided to work on WritingInn.

The idea’s been kicking around in my head for a very long time, and I guess I’ve always wanted to collaborate with others, discuss and such.

I’m going to be rewriting Authware for just that purpose. I’m currently dealing with architecting the code. I think I’m going to have a full permissions set, for which I have the author of this PHPFreaks permissions tutorial to thank.

In a way, it’s a big responsibility, and I think that apart from being a learning experience, it’ll be the first time I’m very security conscious.

Wish me luck, and don’t hesitate to send any ideas in.


December 22nd, 2006 in OS - No Comments

Are Apple and Microsoft beginning to bond? Or are these ads serving to poke fun at Microsoft?

Caught up

December 21st, 2006 in General - No Comments

I’ve been so caught up watching movies that I’ve hardly done any real coding in the past few weeks. I’ve been forced to stop waxing philosophical about anything geeky on my other blog, so this has been a long time waiting in the sidelines.

I’ve rewritten the db abstraction layer for Authware. It was never anything fancy to begin with, and it still isn’t, but that isn’t my problem. It connects successfully, and that’s about it. Here’s the parent class that initializes the db object. I’ve been accused of writing Java code. Java? Where? How?

[syntax,authware/snippets/db_layer.phps, php]

I’m sure you know such poorly written code is unnecessary. I’m just celebrating my freedom to do what I want.