A Php parser

- May 27th, 2009

I've written an antlr grammar for parsing Php files. It's still missing some features and it doesn't support the new stuff that was added in Php 5.3. You can get more details on the project page.

Or you could directly go ahead and download the source and the jars.



Web Service Idea: Call queues

- April 11th, 2009

For people who get a lot of phone calls, a service to allow callers to join a queue of callers who will be automatically notified when the callee is free.

Case 1: Caller calls number. Is informed that callee is busy at the moment and will call back when available. The caller is added to queue of callers and is automatically called when callee is available.

Case 2: Caller uses web interface to book a slot with callee at a specific time. The caller is automatically called at that time and connected with callee.

There will be a webui with estimated waiting time for the call to get through and information about the size queue. The caller will also be ale to configure when the call should be made.



Doubt

- April 1st, 2009
Non-Believer: God doesn't exist.
God: Ok, I can fix that.
Nu-Believer: How do I know what I know is right.




Here is a simple function I wrote to collect the results of multiple asynchronous function calls and pass them as a list to a single function.

function parallelExecuter(executer, operationCount){
  var parameters = [];
  var n = 0;
  var ctr = 0;
  function makeParallel(operation){
    var id = n;
    n++;
    function cookie(){
      parameters[id] = arguments;
      ctr++;
      if(ctr == operationCount){
        executer(parameters);
      }
    }
    operation(cookie);
  }
  return makeParallel;
}

Using it is quite simple. Define two functions getOne and getTwo, which will act as asynchronous functions. Each accepts one paramerter which is called with an integer value as it's parameter. And a function, sum, that totals the the numbers in a list and displays an alert box with that value.

function getOne(callback){
  callback(1);
}
function getTwo(callback){
  callback(2);
}

function sum(l){
  var total=0;
  for(var i=0; i < l.length; i++) {
    total+=l[i];
  }
  alert(total);
}

Call parallelExecuter with the final function to call and the number of asynchronous operations, here sum and 2 respectively. This returns a function which is used to queue the asynchronous calls, getOne and getTwo. Note that the number of asyncronous operations should be the same as was specified for creating the function or the code will break.

pe = parallelExecuter(sum,2);
pe(getOne);
pe(getTwo);

This will display an alert box containing the value 3.

A better design would be to aggregate all the pieces into a single request, but this might not be possible at times.



It's Aardvark.


A Php target for Antlr

- October 30th, 2008

Antlr is a pretty good parser generator. It targets a number of languages, including Java, Python and C. I've been working on a Php target for Antlr. The code is still in early stages but quite usable. Have a look at the documentation to get started.

There is also a pre built Antlr download to use. The source is available on svn.

svn checkout http://antlrphpruntime.googlecode.com/svn/trunk/ antlrphpruntime

Lots of stuff works, but I still have a long way to go before it is anywhere near complete. So expect issues. The best way to find out what works is to look at the test cases in the svn repository.



Replacing woman

- May 15th, 2008

It's time to get rid of the male references from the word. The color red marks the objectionable part.

  1. woman
  2. woperson
  3. woperchild

Another step towards the emancipation of woperchilds from the tyranny of men.



May 13th, 2008
picture-2.png


Next →