Terry ChayVivanista (17.11.2009, 18:21 UTC)

(Disclaimer: I work for Automattic which contributes to the development of WordPress, WordPressMU, BuddyPress, and bbPress.)

At this month’s Bay Area WordPress Meetup, there were four interesting talks. One of which wised me up to the Zemanta WordPress plugin, which I’m using now, any content creator (or Another Search Startup) should check it out—it’s quite clever.

But the presentation I want to focus on in this article, was Annie Vranizan’s Vivanista demo.

Vivanista homepage
The Vivanista homepage

Vivanista is a social network for women focusing on philanthropy. Even if you don’t have a passing interest in such things, the website deserves a look, it’s quite an attractive website and built in record time—a couple of months.

Being a vertical, this is mostly the territory of white-label social networks, and more recently, Facebook. In fact, if you look at their team, it reads more like a group blog than a company.

That’s because it is.

What makes Vivanista so interesting is that it is built on WordPress MU blog publishing platform in combination with Andy Peatling’s BuddyPress plugin.

BuddyPress, WordPress MU, and Automattic

Image representing WordPress.com as depicted i...
Image via CrunchBase

WordPressµ (Automattic’s flagship product: WordPress.com, as well as many blog networks out there. MU stands for “multi-user”, but perhaps it would have been better-named “multi-site”. It started as a plug-in on top of WordPress, but has evolved to a code base in its own right. Because of this, and the popularity of plugins dependent on it, it will be merged w

Truncated by Planet PHP, read more at the original (another 8670 bytes)

Link
Terry ChayAfter the Deadline Open-Sources (27.10.2009, 02:30 UTC)

Raffi, a co-worker of mine at Automattic, mentioned today that his project, After the Deadline, is now open-source.

It might help to explain what After the Deadline is.

What is After the Deadline?

After the Deadline it is a TinyMCE editor plugin for grammar, style and spell checking.

The statement above is factually correct but also completely boring.

Let’s face it, the last time I had fun with most spell checking programs was twenty years ago when I used to type in the names of my friends to see the suggestions and invent “spell check names” for all my friends.

Instead let me channel my inner Mudge and explain why After the Deadline rocks and then why open-sourcing it is cool.

The reason it’s rocks is that most spell checkers and grammar editors suck.

How After the Deadline is different

Most spell checking works by finding if a word is in the dictionary. If you’re really lucky, it might highlight the word “it’s” every time it sees it, for when you really meant “its.” But here we are, with the wealth of Google to build on, and my Mac OS X spellchecker still suggests that “the written wrd” should be written “the written wry” or “the written ward” before “the written word.”

That’s bullshit.

Mac OS X spellchecker
The Mac OS X built-in spellchecker guesses wrong twice.

So one thing After the Deadline does is sort the suggested misspelling based on rules generated by a neural network based on real data. This means, it, unlike my Mac suggests “the written word” first because it knows that that phrase is used much more often than “the written wry.”

Similarly, if you new the write word, but use the wrong one, it might highlight the one you knew to be right. In the last sentence, Mac OS X only caught one of the two misused words, but AtD catches both. Finding misused but correctly-spelled words is important because (there is a bloody difference between sanguine and sanguinary!

AtD spellchecker
AtD gets it right much more often and finds more errors.

Finally, it has an optional rule-based style-grammar checker, which, now that it is open-sourced, Raffe is hoping to add foreign language support to based on integrating other open-source projects into.

Open sourcing

Now that AtD is part of Automattic, open-sourcing simply makes sense. But more than that, it has uses far beyond some text editor box in for your WordPress.

I hear our Happiness Engineers find AtD so nice, they sometimes paste their replies into WordPress just to use the spellchecker. Now that sucks, but with the jQuery API, it’d now be possible to spellcheck-enable any website out there. In fact, people have already written a GreaseMonkey script to make it available in any text box—now if only someone would give me it! :-)

Imagine harnessing the power of the intertubes to do spelling and grammar checking right in your desktop application or AIR app. Imagine having that support on your website under your control or in the language of your choice. Imagine generating your own statistical dataset of suggestions for your own needs—even feeding the engine Cheezburgers so it ca

Truncated by Planet PHP, read more at the original (another 1821 bytes)

Link
Terry Chay5 million (27.7.2009, 23:53 UTC)

“Five million, bitches”
—my new reply every time someone mentions Ruby

A friend of mine is learning to program, and how to learn a programming language came up.

The issue is that there is a lot of people who are non-programmers and have taken programming classes and not learned to program. When I was a kid, those languages were BASIC, Logo, and Karel the Robot, now they are things like C#, Java, and Ruby. Still the same problem rears its ugly head.

Recommending what you know

The big thing that bothers me is, too often, I think people recommend what they know already or are are learning themselves. Ignore these people, they’re idiots.

The first language I ever became an expert in was Pascal. It’s a highly structured language that was great for learning. The last time I coded in Pascal was in 1991 in order to prove computationally that some differential equation doesn’t approach e^x but rather the curve e^x-1. It’s not a forgiving language to be programming in today, the popularity of Delphi notwithstanding. I’m sorry, if you want to learn a language with OOP bolted on, you might as well put the C gun in your mouth, pull the trigger, and blow out your brain with C++.

I don’t code in Pascal anymore. And I don’t plan to.

(I’m sure there is someone out there recommending people learn Erlang as a first language. I’d be offended, but I figure they’ll be dismissed because they long ago lost the ability to speak coherently.)

Filing for divorce

One time at a McDonald’s in San Jose, I watched a guy talk to about six different people in their native language. Asking him on how to learn a language is futile. He is so far removed from the “learning” stage that he forgot. He picks up languages as easily as I pick up new cuss words.

It occurs to me:

We’re that guy.

It’s hard for a programmer to give good advice on what language to learn because we’re so divorced from the learning part that we don’t know the answer ourselves.

Answering by analogy

But maybe that incident clues us in to the answer. If words have meaning through paradigm the reason we call it a programming language is because it is a language.

Programming languages are a lot like real languages—maybe the best way to learn a language can be derived from how we learn real languages. You know you can learn it in a classroom, but immersion is a much faster way to learn.

The best way to learn to program is to have an itch that needs scratching.

If you have a need to program, then you will immerse yourself and learn fast. If you learn in a class, oftentimes it’s a lot like those years spent diagramming sentence grammar…

miranda_sam

or memorizing declensions…

firstdeclensionendings2

Sure, my understanding of the future-perfect tense has helped me write marginally better, but you’ll learn much faster and better if you really need to speak/write/use a language.

I believe the fundamental problem with most programming courses is that they’re more an exercise in “look how smart the teacher is” and the theory behind the language rather than actually learning the language. You can’t get more than ten pages into an introductory book on programming before being hit by a wall of terms like “object-oriented” “run-time” and “compiler.” WTF?

Whe

Truncated by Planet PHP, read more at the original (another 2641 bytes)

Link
Terry ChayMy favorite language (code) (1.7.2009, 23:21 UTC)

Internationalizing the a website, you run into a problem where you don’t know what strings you’ve parsed out for localization or not.

For these tasks, my favorite language is “zxx.” I use that code to replace all strings with some XX’s. Now any strings (or images) I missed are immediately evident.

Meetme Play — Tagged (in zxx_XX)

Keeping the zxx localization file up to date is easy to update…

// {{{ l10n_upgrader($pofile,$callback)
/**
 * Allows you to upgrade a PO file automatically.
 *
 * Search for all "" (two double quotes) and translate these.
 *
 * @param string $pofile the messages.po file to upgrade
 * @param string $callback the callback function that does the string lookup
 * @return array
 */
function l10n_upgrader($pofile,$callback='')
{
    if ($callback) {
        $data = file_get_contents($pofile);
        $matches = array();
        $data = preg_replace_callback("!^msgid \"(.+?)\"\nmsgstr \"\"!m", $callback, $data); // if I add s it matches too aggressively
        //unlink($pofile);
        file_put_contents($pofile,$data);
    }
    // generate output
    //msgfmt message.po
    $exec = sprintf(
        'cd %s;msgfmt %s',
        escapeshellarg(dirname($pofile)),
        escapeshellarg('messages.po')
    );
   pass($exec); //erroring out this is an exec function
}
// }}}
// {{{ l10n_ZXXer($matches)
/**
 * Add a bunch of XXXX's to a string
 *
 * @param array $matches
 * @return string
 */
function l10n_ZXXer($matches)
{
    return sprintf(
        "msgid \"%s\"\nmsgstr \"%s\"",
        $matches[1],
        str_pad('',strlen($matches[1]),'XXXX ')
    );
}
// }}}
l10n_upgrader($gt_dird.'zxx_XX/LC_MESSAGES/messages.po', 'l10n_ZXXer');

You may have some trouble getting things working, so remember that gettext uses your system to set the language. If your system doesn’t have zxx installed, you can’t just flip your locale over and expect it to work. As a quick hack for develement, just symlink the directory in your dev machine over to a language you aren’t using. I’m currently using “zu_ZA” which will be okay until Tagged localizes for Zulu.

Also remember that your web server caches gettext strings, so be sure to shut down the webserver to free the file lock before updating your .pot file.

Improving your linguisticness

l10n_ZXXer() above is not that clever. It won’t handle the cases where you have nested sprintf() substitutions. But you can imagine improving it. Here are some ideas of different fake languages:

  • Multiply strlen() computation by 1.2 in order to handle spacing issues for localizing to German.
  • Replace many of the letters with the letters in the cyrillic alphabet. This way you know unicode is correctly supported. Don’t replace all of them so your pattern replace can be easier and strings don’t get smashed.
    Tagged in fake russian
  • Replace the code to run it through a filter so it’s linguistically recognizable. Maybe turn your site into 133t-speak. Personally, I used ebonics from my Plaxo days. Careful though, while it is amusing to see your website littered with argot, fo’ shizzle. Apparently, I was committing a lot of cuss words into the code base. It’s times like that you’re grateful for the symlink trick above preventing your users from stumbling on these fake languages.

Truncated by Planet PHP, read more at the original (another 1351 bytes)

Link
Andrei ZmievskiMay Wrap-up (2.6.2009, 18:10 UTC)

May has come and gone and for me almost half of it was spent on the road. SFO-DEN-BNA, BNA-ORD, ORD-ZRH-TXL-ZRH-ORD, ORD-SFO. To decipher that for you, I first went to Nashville to visit my friend Raquel and see the land of the honky tonks. I was surprised to find an almost full-sized replica of Parthenon there, as well as a really great ƒood/drink scene. Some highlights include Prince’s Hot Chicken Shack (I dare you to order something more than medium hotness), a great beer place called The Flying Saucer (150+ beers on the menu), and especially The Patterson House (recommended by the awesome Steph Dub), where we spent a few hours snacking on tasty bits from the menu and drinking the awesome cocktails that the bartender mixologists prepared in front of us.

Then it was off to Chicago for php|tek 2009 conference. The first two days were dedicated to the first real PHP developers meet-up since November 2005. On Monday we discussed technical issues with regard to PHP 5.3 and 6, and on Tuesday the topic shifted more towards potential features aside from Unicode to entice people to move to 6 and how to ease this migration. Overall it was a productive meeting and the notes should be posted soon. The next day I gave the opening keynote on the present and future of PHP. I managed to throw in a few inside jokes and funny photos in there to lighten up the morning mood. The rest of the conference was productive as well—there were great talks on everything from utilizing HTTP status codes to multi-level caching to a talk that Cal gave on telecommuting. After the conference hours we stopped by the Map Room a couple times for some excellent beer flights (La Folie on tap, OMG).

 

@tychay is not happy

@tychay is not happy

After Chicago, I flew to Berlin for the International PHP Conference Spring Edition 2009. This year they accepted all 3 of my proposals, so I had my work cut out for me. Miraculously, I managed to make the German audience smile and even laugh a couple of times during my keynote. Success! The other two talks intl me this, intl me that on localizing and translating your pages, and All the Little Pieces on using PHP with memcached, mogilefs, and Gearman went well too. Funny enough, the RailsWay conference was going on at the same place—didn’t they know that Terry Chay is coming to town?! This was my first visit to Berlin, so Terry and I played tourists for a bit and went to see Checkpoint Charlie, the remaining pieces of the Berlin Wall, Brandenburg Gate, and Reichstag. It is really amazing to consider that the Berlin Wall used to be 150 km long and embedded a piece of Western Germany in the middle of Eastern one.

Finally, I had a long series of flights home, and despite a mishap at the immigration in Chicago, arrived to my apartment safely and almost on time. It was great to see old friends and new faces and to talk to the best development community out there.

For those of you who wondered where to get the I Unicode t-shirt that I wore during my keynote, I put the design up on Zazzle, so you can get your own for the next gathering of the Unicode-minded folks.

Link
Terry ChayWriting and speaking (7.5.2009, 23:57 UTC)
Terry-ist
I can’t find the conference speaker badges so this will have to do. The fact that it feeds my ego doesn’t hurt either!

Paul wrote something nice about me. In fact, it’s so very nice, that I can (almost) forgive him for listing me sixth. ;-)

Reading his description reminds me how grateful I am every time someone reads my articles. Writing is a craft that I’m not very good at and have to work at constantly. I hope my logorrhea has, in a small way, created a little context for you and perhaps trolling the internets for my name, I’m reading your blog… and growing.

Mad talks

Paul also mentioned my that I’m a conference speaker.

In light of this, I better mention that in a couple weeks in Chicago at PHP|tek, I’ll be bookending the opening keynote of Andrei, my (a)cross-street rival, with the closing keynote. I have no idea what I’ll be talking about so this should be interesting!

After that, I’ll be racing to Berlin to catch up with Andrei, in order to give two completely different talks at the International PHP Conference. I’m noticed that Thies Artzen will be there—I’ll finally get to see if the rumors of him mellowing out are true.

Maybe Keith Casey will let me dry run my Berlin talks at the PHP|tek Unconference (I hope so). Even if not, I should probably participate in the Pecha Kuchamy speaking skills have deteriorated noticeably.

What killed the whom

Finally I noticed that in an interview, Andi Gutmans, the “nd” in Zend mentioned my company:

The Java disruption by PHP is well under way. PHP is everywhere, and Zend’s solutions are being used in business-critical deployments by companies such as Tagged, Fiat, BNP Paribas, and Fox Interactive Media, to name a few. The strategic adoption of Zend in larger accounts, often in favor of Java, is related to our strong return on investment and shorter time to market.

(I guess this means I’ll finally have to figure out the difference between him and Zeev, the “Ze” in Zend.)

One thing the writer, a Java developer, doesn’t notice is that a significant fraction of Tagged is Java. This wasn’t the case when I joined the company, but it was an architectural system I made because there are some things PHP isn’t good at.

If I had to guess, when Andi is saying “Java disruption,” I think he really means “Java/J2EE” disruption. It’s a minor distinction…and one of which I’ve been attacked for when I say “Ruby” and really mean “Rails.”

Link
Terry ChayHow much does a date() cost? (6.5.2009, 20:31 UTC)

One of the fringe benefits of open sourcing an existing code base is that you have an opportunity to set error_reporting to E_ALL | E_STRICT, or perhaps rather to 2147483647. When you do that you find small problems with your code base you missed the first time you sloppily wrote it.

In my case, I noticed that date() was throwing strict errors. For example

error_reporting(E_ALL | E_STRICT);
ini_set('date.timezone',false);
echo date('c');

shows you

Remember to set your timezone!

I’m sure if you’re Derick, you are intimate with date()ing, but I had forgotten about this wasted guess_timezone() sys call and the suppressed strict error (which still takes time in PHP 5).

I sent an e-mail with this bug, along with the one line fix to the php.ini, to site operations…and promptly forgot about it. That is until the ticket was sent back with the message that it needed to be “tested in dev and stage before making it to production.”

(The younger, less-tolerant terry would have blown a fuse at this point.) The older, jaded terry simply became curious about what the costs of date() really are.

Benchmarking

The last time I did synthetic benchmarking was week 1 at Tagged where I wrote a harness to compare sqlrelay vs. two home grown connection pools. Not happy with PEAR’s Benchmark_Iterate, I figured it was time to write a benchmarking suite again.

// Bootstrap this without framework
include('timer.php');
include('iterate.php');

//mimic production
$error_level = error_reporting(0);

// {{{ date()
ini_set('date.timezone',false);
$b1 = new tgif_benchmark_iterate(true);
$b1->run(10000, 'date', 'c');
$b1->description = 'date("c")';
// }}}
// {{{ date() + date.timezone
ini_set('date.timezone','America/Los_Angeles');
$b2 = new tgif_benchmark_iterate(true);
$b2->run(10000, 'date', 'c');
$b2->description = 'date("c") + date.timezone';
// }}}
// {{{ iterate date() + ini_set
//date_default_timezone_set('');
ini_set('date.timezone',false);
function ini_and_date() {
    ini_set('date.timezone','America/Los_Angeles');
    date('c');
}
$b4 = new tgif_benchmark_iterate(true);
$b4->run(10000, 'ini_and_date');
$b4->description = 'iterate date("c") + ini_set';
// }}}
// {{{ date() + date_default_timezone_set
ini_set('date.timezone',false);
date_default_timezone_set('America/Los_Angeles');
$b3 = new tgif_benchmark_iterate(true);
$b3->run(10000, 'date', 'c');
$b3->description = 'date("c") + date_default_timezone_set()';
// }}}
// {{{ iterate date() + date_default_timezone_set
//date_default_timezone_set('');
ini_set('date.timezone',false);
function set_and_date() {
    date_default_timezone_set('America/Los_Angeles');
    date('c');
}
$b5 = new tgif_benchmark_iterate(true);
$b5->run(10000, 'set_and_date');
$b5->description = 'iterate date("c") + date_default_timezone_set';
// }}}

echo tgif_benchmark_iterate::format($b1->compare($b2,$b3,$b4,$b5));

// restore
error_reporting($error_level);

(Here are timer.php and iterate.php. If there are major bugs, I apologize, I hacked it together in bed last night.)

Results

I should have really rebuilt my dev install not to have xdebug, inclued, and other debugging crap here. In any case, here is the result when performed on my MacBook Pro:

mark wall time resource time
date(“c”) 0.000043s 0.000044s
date(“c”) + date.timezone 5.53x 5.60x
date(“c”) + date_default_timezone_set() 6.79x 6.96x
iterate date(“c”) + ini_set

Truncated by Planet PHP, read more at the original (another 1291 bytes)

Link
Terry ChayI want a PWNy (4.5.2009, 18:12 UTC)

Someone has a problem with their “WAP” installation…

PHP Bugs: #48139: MySQL Integration
Link
Terry ChayJoin Kiva for a Developer Drink-up (8.4.2009, 21:49 UTC)
Image:Kiva.org logo.svg

Halle is interning at Kiva, which, given her personality, I figure is her dream internship.

Kiva is a microfinance site for the poor that allows anyone to give flat-rate microloans via PayPal. As a coincidence of the “I seem to have a lot of cash” and my New Year’s resolution to be a more responsible person, I’ve recently started to put a tiny fraction of my income into Kiva. You can view my lender page here to see that I currently participate in 17 microloans.

I mention all this because Kiva will be sponsoring a Developers Happy Hour this Thursday at their headquarters in San Francisco. Considering I give 5% of my money lent back to Kiva, I’m going for the drinks. :-)

(Find out more about the concept from Muhammad Yunus’s Nobel lecture, the FrontLine program on social entrepreurship, conservative columnist Nicholas Kristof’s editorial in the New York Times, and the books Banker To the Poor, and Creating a World Without Poverty.)

Moneywatch

Speaking of money, Andrew Mager has been slaving away on the new CBS site, Moneywatch, which reminds me of a personal finance version of the old CBS-owned, now FOX-owned, MarketWatch.

CBS MoneyWatch.com - Personal finance advice, analysis and financial planning

Here is a link to the its launch on The Early Show, yesterday.

Link
Terry ChayWeb development as torture (5.4.2009, 05:19 UTC)

Apparently one commenter found my April Fools articleham-handed.”

ham-hand⋅ed
clumsy, inept, or heavy-handed: a ham-handed approach to dealing with people that hurts a lot of feelings.

I’m sorry that some people didn’t realize that an article was meant to show off someone else’s April Fool’s prank. I guess the snippets of code showing the joke, putting it in the “humor” category, and adding the words “april phails phools” to the URL just wasn’t enough for some people :-(

Next time, in order to prevent hurt feelings, I’ll be sure splay across the top the words: “Look, Phails is an April Fools Joke, Please don’t take it seriously (pretty please?)” in 42-point Charcoal typeface.

On second thought, why bother? 37Signals has me beat in the tact and sensitivity department. Notice how they introduce Ruby on Rails as…

The very definition of integrity
Great moments in Truth in Advertising™ just ask Twitter.

(And when I replied that this was madness, he kicked me into some CAT-5 ethernet cabling with the words, “THIS IS SPARTA!!!”)

(I heard that Web development is so hard that Rasmus had John Yoo write up a torture God, that I learned Ruby on Rails so I no longer have to deal with the pain of writing a SQL select.

Link
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP