Comet story (part II)


[The first part of "Comet Story" was the story of failure. This part is no different with a slight twist at the end.]

Forgetting Comet was not such a bad thing actually. In the aftermath, I ended up passing the Zend Certified Engineer exam :-) But after the exam, the itch was back; time and again, I'll start thinking about Comet and online whiteboards. Regarding Comet, I was probably thinking deep inside my mind that a magic solution will appear somehow.

Comet story (part I)

A few years ago, I wanted to create a remote tutoring website. I even bought a domain name - remoteguru.info. Then after a long thought, I decided against creating the site and instead concentrate on AI (no, I haven't built R2D2 yet). But in the meantime, I have done some homework on this remote tutoring site. In this piece, I'll tell what happened during that time.

Customizing CruiseControl

CruiseControl is a continuous integration tool. When any project is listed with CruiseControl, it looks for source code changes in that project at regular intervals and runs various tools everytime the codebase is updated. These tools include build tools, unit test frameworks, coding standard checker, source code documentation generator, etc. Any tool that has anything to do with source code can be in this list as long as they fulfill one criteria - the ability to generate XML output. CruiseControl is written in Java and its focus is also on the Java world.

Lessons 0

  • Run your unit tests at least once a day. I haven't run it for a week, and now I see that people have added tests which has turned the whole test suite unusable
  • If your project has anything to do with sending emails to other people, do use a separate mail server. And then configure the mail server such that it redirects those emails to a specific email address or mailing list. Something like Fakemail (http://www.lastcraft.com/fakemail.php) should be very useful.

Interactive Drupal Programming

If you like REPL (AKA interactive programming as in "php -a"), you might love this script as well. It loads the whole of Drupal and then waits for
you to type in any php statements. This statements can ALSO be any function defined in your Drupal instance. Here's a demo:


[ju@ju ~]$ php php/inter-drupal.php
Go...
echo drupal_strlen('hihi hoho haha'), PHP_EOL;
14

echo base_path(), PHP_E0L;
/./

echo 3;
3

$return_value = arg(0);
echo $return_value;
node

exit;
[ju@ju ~]$

<?php

/**

Some PHP Questions

0. Name the Super Global that holds the cookies.

1. Which was not available before php5 -
a) DOM b) SOAP c) SAX d) XSL

2. Is the use of type hinting available in methods only ?

3. What's the output of the following:


function foo(IAMACLASS &$arg0 = NULL)
{
    if (is_null($arg0))
    {
         echo 42;
    }
}

4. What's the output of the following:


function foo(IAMACLASS &$x = NULL)
{
    $x = 42;
}

$obj = new stdClass;
foo($obj);
echo $obj;

array_merge() is damn Slow

After this mornings performance by array_merge(), I doubt I would dare to use it again. What I was doing was pretty simple. My code was reading a textfile with the first one million primes. Each line had 8 primes and there were 125002 lines. I was extracting the primes eight-at-a-time and merging them with an array. This merge operation, as you can guess, was happening through array_merge() :


$primes = array();
while ($data = fscanf($fp, ' %d %d %d %d %d %d %d %d \n'))
{
$primes = array_merge($primes, $data);
}

The View-ing problem

Everybody on the Drupal ecosystem knows that the View module is a query builder.
You select some database fields and some rules (equals, not equals, etc) from
the View builder and gets the output of the query in page or block or some
other format. All's fine so far. The problem started when I actually tried to
create a View instead of reading its praises. The problem was simple - I
couldn't find the database fields of my love in View builders field list. I was
eventually enlightened by Mr. Nobleman.

From MSAccess to Localexchange

The marathon run for importing Norwich LETS's msaccess-based database to LocalExchange's MySQL-based database has ended a while ago. It took almost 7-8 hours and pushed my SQL knowledge to its limits. Here's how I did it.

0. Open database in MSAccess and export all tables as CSV file.

1. Make a list of columns in each table and create identical tables in MySQL.

2. Import the tables from the CSV files into MySQL:
$ mysqlimport -u dbusername -p --local --fields-terminated-by=, --fields-enclosed-by='"' --lines-terminated-by='\r\n' norlets tablename.txt