Zend Certified Engineer

After being delayed for couple days, due to some problem with Pearson Vue database, i finally took my Zend PHP Certification exam last tuesday.

What? are you kidding me, off course i passed the exam. 😉

So now i’m officially Zend certified engineer.

zce logo

Thanks to Brainmatics for such a good effort preparing my test.

Now, there are three Zend certified engineers from Indonesia. Rock on, dude!

Searchable Google Reader with Greasemonkey + Gears

gearsmonkey

I knew it, sooner or later somebody would make Google Reader searchable. Thanks to Raul Ochoa for creating a nice Greasemonkey script that mix Google Gears and Google Reader. Now, not only you can read Google Reader offline, you can search the old feed too.

Currency Converter

Couple days ago, i was asked by a friend to make a small currency exchange script in PHP. With slow internet connection and so short amount of time, the best thing i could think of was grabbing the number from available currency rate site like this. With curl and PCRE function, i finished the script in no time. :p

That’s evil of course.

So, i create the following script as my apology. I use FoxRate currency converter API. Be careful though, you can not run the script too fast, wait for awhile before sending the next request. That’s what happen when you use a free web service. I guess.

Anyway, it’s 2 a.m in the morning here. Gotto go to bed. Night night.

function convertcurrency($from,$to,$amount)
{
  $xml = "
<?xml version='1.0'?>
<methodcall>
  <methodname>foxrate.currencyConvert</methodname>
  <params>
    <param>
      <value>
        <string>$from</string>
      </value>
    </param>
    <param>
      <value>
        <string>$to</string>
      </value>
    </param>
    <param>
      <value>
        <double>$amount</double>
      </value>
    </param>
  </params>
</methodcall>";

  $url = "http://www.foxrate.org";

  $header  = "POST /rpc/ HTTP/1.0 \\r\\n";
  $header .= "Host: foxrate.org \\r\\n";
  $header .= "MIME-Version: 1.0 \\r\\n";
  $header .= "Content-length: ".strlen($xml)." \\r\\n";
  $header .= "Content-transfer-encoding: text \\r\\n";
  $header .= "Document-type: Request \\r\\n";
  $header .= "Connection: close \\r\\n\\r\\n";
  $header .= $xml;

  $ch = curl_init($url);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $header);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

  $xmlresponse = curl_exec($ch);
  curl_close($ch);

  $sxml = new SimpleXMLElement($xmlresponse);
  $xxml = $sxml->xpath("params/param/value/struct/member");

  foreach ( $xxml as $v )
  {
    if ( $v->name == "flerror" )
    {
      $errflag = $v->value->int;
    }

    if ( !$errflag )
    {
      return false;
      break;
    }

    if ( $v->name == "amount" )
    {
      return $v->value->double;
    }
  }
}

Sample usage:

$ret = convertcurrency("JPY","IDR",1);

if ( $ret )
{
  echo "1 JPY = $ret IDR";
}
else
{
  echo "Wrong currency code or you're too fast to fetch, wait for awhile.";
}

Google Reader Goes Offline

greaderoffline

Cool, now i can read my feed on a plane or a bus without having internet connection. Thanks to Google Gear, Google Reader is the first Google web apps made for online and offline viewing.

Java 6.0 Features – Scripting Language for the Java Platform

This is interesting,

Java 6 provides the Common Scripting Language Framework for integrating various Scripting Languages into the Java Platform. Most of the popular Scripting Languages like Java Script, PHP Script, Bean Shell Script and PNuts Script etc., can be seamlessly integrated with the Java Platform. Support for Intercommunication between Scripting Languages and Java Programs is possible now because of this. It means that Scripting Language Code can access the Set of Java Libraries and Java Programs can directly embed Scripting Code. Java Applications can also have options for Compiling and Executing Scripts which will lead to good performance, provided the Scripting Engine supports this feature. Let us have a high-level overview of this JSR before going in detail.

Apache Log Analyzer 2 Feed

apachelog2feed

If you like to follow everything using your feed reader, you might also want to read your Apache log in feed. Well, you need to try Apache Log Analyzer 2 Feed.

ApacheLogAnalyzer2Feed is an object oriented class, written in PHP 5, for parsing/filtering an Apache log file and convert it into feed.

You can filter out which part of your Apache log you’d like to see. For example, you can generate a feed that shows you when Google Bot visit your blog or when your visitor register, etc. See some sample codes here.

Here’s the sample output from my Apache log,


<rss>
<channel>
<title>Log /usr/local/apache2/logs/access_logs filtered by 1 filters</title>
<description>Array
(
    [0] => Array
        (
            [0] => Request
            [1] => regexp:generator\.php
            [2] => IS
        )

)
</description>
<link>/log.php</link>
<lastbuilddate>Wed, 06 Jun 2007 21:20:08 +0100</lastbuilddate>
<generator>FeedCreator 1.7.2-ppt ([email protected])</generator>
<item>
<title>192.168.1.99 - GET /generator.php HTTP/1.0</title>
<link>/log.php</link>
<description>Array
(
    [Remote-Host] => 192.168.1.99
    [Remote-Logname] => -
    [Remote-User] => -
    [Time] => [06/Jun/2007:21:17:26 +0700]
    [Request] => GET /generator.php HTTP/1.0
    [Final-Status] => 200
    [Bytes-Sent] => 9274
    [Referer] => -
    [User-Agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
)
</description>
<pubdate>Wed, 06 Jun 2007 21:17:26 +0100</pubdate>
<guid>b27435fba04c82a72e084d0404bc442b</guid>
</item>
<item>
<title>192.168.1.99 - GET /generator.php HTTP/1.0</title>
<link>/log.php</link>
<description>Array
(
    [Remote-Host] => 192.168.1.99
    [Remote-Logname] => -
    [Remote-User] => -
    [Time] => [06/Jun/2007:21:20:02 +0700]
    [Request] => GET /generator.php HTTP/1.0
    [Final-Status] => 200
    [Bytes-Sent] => 9274
    [Referer] => -
    [User-Agent] => Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4
)
</description>
<pubdate>Wed, 06 Jun 2007 21:20:02 +0100</pubdate>
<guid>005091851cf9b076180c57ff3c5ea081</guid>
</item>
</channel>
</rss>