Why I won’t use PHP 5.3.3

December 2, 2010

Uh… because it won’t handle “localhost” properly.

There seems to be two possible reasons. Streams and Sockets.

I have no problems with PHP 5.3.0. It works.

PHP 5.3.3 BROKEN IMHO.

 

Announcing: Debugging and TDDing Ajax with jQuery just got easier with ajaxMonitor

August 6, 2010

I am freakin’ excited!

I got tired of switching between tabs and firebug when trying to figure out what the hell was going on with my ajax requests.

The worst is when I tried finding anything about my requests in Internet Explorer. Forget it!

So I wrote a jQuery Plug-in. You attach it to your page and it will monitor all your Ajax requests [1].

One Click —-> Get the plug-in ajaxMonitor <—- One Click

The running unit tests for the source.

The running unit tests validating with jQuery 1.4.2 Ajax tests with the plug in. [2]

Two feature that are becoming a must have for this plug in

1> Mocking Ajax request by specifying your Ajax settings like this: { /*other settings*/ mock: true }

2> What I’m going to call single-shot.

  • Fire an AJAX request once
  • For all repeat requests will be  mocked with the response data.

Presently the way I TDD a client, is I retrieve content using the normal Ajax call to get the presentation HTML.

Then I make another Ajax call in my normal code and store it into a string. At the start of each test I load this string into my: $(‘#contentContainer’).html(myPreloadedPresentationHTML);

Then remove it. So for all the unit tests I make a total of TWO Ajax calls. That’s one too many calls (latency can be up to 1~2 seconds OUCH!).

Since the monitor already controls the success callback of the original Ajax request why not replace it with my own.

First Ajax request success supplies the response data.
Hang onto it.
Any other calls to this request will get the stored response data.

I would welcome any comments.

Good or Bad!

…even requests.

Please help push against this software. I think it is a great tool and could be better with your help.

[1] Because jQuery 1.4.2 executes the complete callback twice during the request. If you want you can include my modified jQuery 1.4.2 library that fixes this use it. See here for bug tick #5383 .

[2] Two failing tests dealing with preserving the context. It is caused by XPC Cross Origin Wrapper. If anybody has a fix, post on stackoverflow.com.

Thanks from the ajaxMonitor Team.

Event messaging between JavaScript objects.

June 12, 2010

Simplest implementation:

function NewMessageBus() {
    return {
        when: function(name, fn) {
            this.fire[name] = fn;
        },
        fire: {}
    };
}

var msgBus = NewMessageBus();

Usage of this requires two things:

Creating the event

var presenter = (function() {
    msgBus.when('getContent', function() {
        model.load(view.content);
    });
}());

Note that the presenter is state-less.

Firing the event

var view = {
    getContent: function() {
        msgBus.fire.getContent();
    },
    content(htmlData) {
        $('#contentContainer').html(htmlData);
    }
}

var model = {
    load: function(cb) {
        $.ajax({
            type:       'GET',
            url:        'myContent.php',
            dataType:   'json',
            data:       {/* some parameters */},
            success:    function(data) {
                // some preprocessing of data
                cb(data.html);
                // some post processing of data
        });
    }
}

Usage

view.getContent();

That’s it pretty simple.

The view/model does not have any references to each other.

Why drupal 6.x SimpleTest is not a developer’s tool

May 6, 2010

This presentation is not a condemnation of Drupal 6.X SimpleTest.

It is an idea that there are areas that can  be improved.

This is what I’m going to be about it.

As a programmer do you want to work on operational programs or do you want comabat training?

April 22, 2010

Tank: We’re supposed to start with these operation programs first. That’s major boring shit. Let’s do something a little more fun. How about… combat training.
Neo : Ju jitsu? I’m gonna learn Ju jitsu.
[Tank winks and loads the program]
Neo : Holy shit!
Tank : Hey Mikey, I think he likes it. How about some more?
Neo : Hell, yes. Hell yeah.

Well I can tell you that I prefer comabt training…

Read the rest of this entry »

Mocking: LOL

April 19, 2010

I was cruising StackOverflow and came across this:

What is Mocking?

The funny part is the remark to the question.

when you deride people for not being able to unit test due to dependencies ;)

’nuff said

Drupal 6.x adding new tests for simpletest

April 4, 2010

If you add a new test, be sure to clear caches.

This is done in (Administer -> Site Configuration -> Performance).

See this post.

Drupal Noob

April 4, 2010

I’m using:

  • Microsoft Vista
  • Netbeans 6.8
  • PHP 5.3.2
  • Drupal 6.16
  • Apache 2.2

Things to get running:

Things to remember:

  • Remove in hosts file, the entry ::1
  • Restart Apache server when getting the white screen of death
  • Have to patch core when installing simpletest
  • ereg() php function deprecated

Future:

  • find a code coverage tool similar to webgrind

Topeka and Google

April 1, 2010

Google displays Topeka

Are they going to blaze with speed?

Or is it April Fools?

I don’t need no sticking tests!

March 29, 2010

This is a very good question:

Chocolate Covered Unit-Tests


Follow

Get every new post delivered to your Inbox.

Join 202 other followers