Friday, November 16, 2007

javascript include workaround

While i am working on a server side javascript framework, i realize that javascript doesn't support include. that means, you can't directly include another javascript.

If you are write web application, this can be done by

document.write('<script language="javascript" src="' + baseHref
+ 'variables.js"></script>');


However, i want to separate my javascripts into libraries, and called on the server side.
In the end, i write a include function as work around.

usage:


...
var includes = "";
...
include("another.js");
eval(includes);
includes = "";
...






include function:


function include(filename){

length = filename.length;

if (filename.indexOf(".js") < 0) {
filename = filename + ".js";
}
reader = new java.io.BufferedReader(new java.io.FileReader(filename));
while((chunkread = reader.readLine()) != null) {
includes = includes + chunkread + "\n";
}
reader.close();
}

Wednesday, October 31, 2007

How to solve the connection refuse error for php script on Linux

I am trying to use Magpie RSS parser to parse RSS feed in my PHP scripts today. However, I always got 'unable to connect to www.google.com:80 (Permission denied)' error messages.

In php.ini, the allow_url_fopen is set to on.
Then it must has something to do with my Apache or network configurations.

After fighting for one hour, I finally found the problem that it was disabled by my network policy.
To fix this, Desktop > System > Administration > Security Level > SELinux > httpd > check the HTTPD scripts to connect to the network.

Thursday, September 27, 2007

Building auto-translator based on google translate API (3)

Finished the ETranslator plugin

Since machine translation is getting more mature year over year, it can be used for localization vendors to cut the translation cost.
Even more, if we can mash-up related technologies together, we can create

Interpreter Robot

  1. Speech-to-Text, to input English
  2. machine translation, to translate to Franch
  3. Text-to-Speech, to speak out in Franch