Archive for the ‘Uncategorized’ Category

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…

(more…)

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

RU A Developer Using Firefox?

March 27, 2010

XRefresh

This program is for you!

I want you image

It does an automatic refresh of the pages that are being served by your development work. Whenever you save it will automatically do a refresh on the the web page.

How it works, is it has two programs. One is an add-on to Firefox. The other is an application you run from your desktop.

The application on the desktop monitors your development work directories. If any saves are done on the files in those directories, it will let the add-on for Firefox know to do a refresh on any pages for those directories.

Scenario:

Joe Sofwarer TDDs his code using qunit.

  1. So he writes a test (RED).
  2. Ctl-s.
  3. Loads up the unit-test page in Firefox.
  4. Gets his results.
  5. Writes code to make his (RED) test a (GREEN) test.
  6. Ctl-s.
  7. Goes to Firefox.
  8. Refresh button pressed.
  9. Reruns unit-test page.
  10. All is (GREEN).

Ten steps required for development.

Add XRefresh

  1. So he writes a test (RED).
  2. Ctl-s.
  3. Loads up the unit-test page in Firefox.
  4. Gets his results.
  5. Writes code to make his (RED) test a (GREEN) test.
  6. Ctl-s.
  7. All is (GREEN).

Seven steps required for development.

Faster feedback. Now there is more time to design and write code.

Or even blog about saving some time.

Recommend you check out there page, XRefresh.

Ugly Developing!

quicBlog Placeholder Functional Specification

March 25, 2010

Reason:

Need to be able to have placeholders introduced into output stream to automatically add empty-links.


Source:

quicBlog


Overview

At present when using showdown you specify a link by putting the text you want to be a link into brackets: [].

Now when you do this all the text is still surrounded by the brackets. You then have to go the bottom of your text page and add the actual link information (meta-link information). Here is an example:

link–> [showdown]

paragraph–> some text below the brackets placeholder

meta-link info–>[showdown]: #

See this is what I’m talking about; circularity at its worst while trying to put this post together I’m using showdown, but I have to go to the bottom of the page to put the meta-link information. Something like a chicken-egg problem. At least I’m dog-fooding code that I’m using in this web app

Note: The showdown tokens for placeholders

link = [link-text]

image = [image-holder][alt-text]

#


This spec is not complete!


Objects

placeHolder

There are five objects. The main architecture will use Atomic Object‘s Presenter First Pattern.

User Input

User will enter a character at a time which will get sent to the text model

Text Controller

Just forwards the character to the text model

Text Model

The text model will pass character to placeholder recognizer. If a place holder it will the generate the meta-link information for the placeholder and store it in the text. The revised text is then sent to showdown. the showdown information is then sent to the HTML presenter

HTML Presenter

Forwards data to the output.

HTML Output

Displays HTML.


Source:

quicBlog