Wednesday, April 9, 2008

Handy tools from Mr. Google

Here are useful tools from google that i allways use :
  1. Google Translate : Used to translate text or a web page, currently available languages are Arabic, Chinese, Dutch, French, German, Greek, Italian, Japanese, Korean, Portugese, Rusian, Spanish.

Tuesday, February 26, 2008

Do ScriptTagProxy with AIR


With AIR Beta 3 you cannot do XHR to remote domain, so you have to create new html file as root file then you call your real index file using <iframe> tag.

Set allowcrossdomainXMLHttpRequest and allowcrossDomainxhr parameter to true , then set your remote domain to sandboxRoot parameter, and dont forget to add src parameter and point to your index file.

If AIR application looks bad, just modified using style code bellow:

<style>
body {margin:0px; padding:3px}
iframe {border:0px; width:603px; height:270px;}
</style>
<iframe id="UI"
src="wsclient.html"
allowcrossdomainXMLHttpRequest="true"
allowcrossDomainxhr="true"
sandboxRoot="http://http://example.com/test_folder/"
documentRoot="app:/"
</iframe>
Hope its help...lets go XHR
Agus Sudarmanto.

ScriptTagProxy invalid label solution

ExtJS.com
If you have problems when you want to fill ExtJS grid to get data from remote domain may be you will get error that says 'invalid label' because it should be a javascript content not JSON content and the script should call the callback function was declare in the URL.

Based on Ext ScriptTagProxy documentation here the PHP code to fix that error :

<php
require_once('../lib/json/json.php');
$json = new Services_JSON();

$scriptTag = false;
$cb = $_GET['callback'];

if (!empty($cb)) {
$scriptTag = true;
header("Content-type: text/javascript");
} else {
header("Content-type: application/x-json");
}

if ($scriptTag) echo $cb . "(";

echo $json->encode(
Array(
'totalCount' => $res->numRows(),
'dt' => getData($_GET['start'])
)
);

if ($scriptTag) echo ");";
?>
First we check callback variable if it set we set content-type for browser to javascript and add callback function to JSON data retrieved.

Ok. Hope it help you
Agus Sudarmanto

Tuesday, February 12, 2008

Installing CoolStack Solaris 10 AMP (Apache, MySQL, PHP) and GD (gd.so) also

  1. Requirement to download, browse http://cooltools.sunsource.net/coolstack/ and download packages below :
    CSKruntime : Coolstack runtime package
    CSKamp, that includes 3 packages : CSKapache2, CSKphp5 and CSKmysql32
    CSKphplibs : (optional, if you going to use gd.so or other usefull PHP extension)

  2. Extract your download files with bunzip2 and install using pkgadd
    # bunzip2 CSKruntime_1.2_sparc.pkg.bz2
    # pkgadd –d CSKruntime_1.2_sparc.pkg
    # bunzip2 CSKamp-sparc.pkg.bz2
    # pkgadd –d CSKamp-sparc.pkg

  3. Coolstack package will be installed into /opt directory

  4. #@ APACHE @#
    Start web server using this command
    # /opt/coolstack/apache2/bin/apachectl start

  5. #@ MySQL @#
    Next we configure MySQL server :

    --> First we create group and user for MySQL
    # export PATH=/opt/coolstack/mysql_32bit/bin:$PATH
    # groupadd mysql
    # useradd –g mysql mysql
    # chown -R mysql:mysql /opt/coolstack/mysql_32bit

    --> Create MySQL configuration file
    #vi /etc/my.cnf
    [mysqld]
    basedir=/opt/coolstack/mysql_32bit
    datadir=/opt/coolstack/mysql_32bit/data

    --> Create mysql database needed by server
    # cd /opt/coolstack/mysql_32bit/bin
    # ./mysql_install_db
    # chown –R mysql:mysql /opt/coolstack/mysql_32bit/data

  6. Now we can run MySQL server with this :
    # su – mysql
    $ /opt/coolstack/mysql_32bit/bin/mysqladmin -u root password ‘yourrootpassword’
    $ /opt/coolstack/mysql_32bit/bin/mysqld_safe &

  7. Check apache and MySQL is running on our server
    # ps –ef | grep apache2
    # ps -ef | grep mysql | grep –v grep

  8. Installing PHP Libs (extension, like gd.so)
    # bunzip2 CSKphplibsbundle_1.2_sparc.pkg.bz2
    # pkgadd –d CSKphplibsbundle_1.2_sparc.pkg

  9. Edit php.ini to load GD library
    Open /opt/coolstack/php5/lib/php.ini and type the code anywhere or after `extension="apc.so"`
    extension="gd.so"
    Restart Apache with
    # /opt/coolstack/apache2/bin/apachectl restart


OK. We are finish installing AMP on Solaris 10.