7 Samples Of Professional PHP/Programmer Resume

I was in the way of fixing my current online resume and I though a few googling would reveal some good samples. I found some and though out that someone out there might be needed this resources as well. Here it is:

  1. Stan Taylor
  2. A.J. Brown
  3. Mike Brittain
  4. Alan T. Miller
  5. A nice one page resume featuring C’thulhu.
  6. An example from Best Sample Resume
  7. Another example from Programmer Resume

Get Only n Words From String

Here’s the code:

function trim_word( $words, $howmany = 1){
	$x = explode(" ", $words);
	if(count( $x) <=$howmany ){
		return $words;
	} else {
		return implode(" ", array_slice( $x, 0, $howmany));

Here’s the output:

$words = "this is string that is long enough that I want to trim it.";

echo trim_word($words, 10) . "\n";
//this will echo: this is string that is long enough that I want


  1. 2010-02-05 15:03:25 – Fixing $howmany usage. Sorry, for the inconvenience:D

PHPSH: Test PHP Snippet, The Python Way!

If you know python, maybe you know the interactive python shell, too. If you don’t know both, well, let me explain it. Python has it’s built in interactive shell. When you install python and you execute the command, python, you will be introduced to a shell like interface where you could type python statements and have it evaluated and shown the result, right away. This is really convenience for learning purpose, or some simple snippet testing.

Continue reading “PHPSH: Test PHP Snippet, The Python Way!”


Copy 3MU Playlist to Directory

One day, I want to copy music from my amarok playlist’s to my cellphone. This playlist has so many files that spread across directories. As a php ninja, I create a php script to do the hard work>:).

Here’s the script if you want to try:

$playlist_file = $argv&#91;1&#93;;
$output_dir = $argv&#91;2&#93;;
$lines = array_map("trim", file($playlist_file));

if(!is_dir($output_dir)) mkdir($output_dir);

foreach($lines as $line)
	if(substr($line, 0, 1) == "#") continue;
		$filename = basename($line);
		echo "$filename\r\n";
		copy($line, $output_dir."/".$filename);

Use it this way php 3mu_copier.php /path/to/3mu/files/playlist.3mu /path/as/target/copy/.


Gambas Language File for GeSHi

In the next few week, I’ll start posting my gambas tutorial. For that, I need a syntax highlighting feature for gambas language. This blog uses geshi for highlighting snippet. But, geshi doesn’t have gambas language file built in. Googling didn’t help me find any. Well, maybe gambas isn’t that popular. Therefor, I though to my self, I have to create it. Now that it’s ready, I think I have to share it. Maybe someone need it too for his site.

Click here to download it and rename it to gambas.php. Put this file along side with other geshi’s language files.


Output Buffering Untuk Template

Ceritanya saya dikasih script sama client. Script tersebut punya header.php dan footer.php sebagai include untuk, well, template. Nah, oleh client saya, saya disuruh untuk mengimplementasikan template HTML yang dia buat. Lebih jauh, dia juga minta supaya ada interface admin untuk mengubah template tersebut kalau suatu saat sudah bosan. Hmm… buat interface admin sih mudah, yang jadi masalah, file header.php itu meng-include beberapa file berupa menu.php yang isinya berupa file PHP untuk meng-generate menu secara dinamis. Dari sini saya memakai solusi output buffering seperti pada posting sebelumnya tentang logging file transaksi. Potongan scriptnya seperti berikut:

//ini function:
function getHTMLFromInclude($thefile)
	$stream = ob_get_contents();
	return $stream;
//ini penggunaannya:
/*isinya template_handler.php gak usah dijelaskan ya, cuman beberapa baris code deklarasi untuk template saja kok*/

$arrTemplate['{TOPMENU}'] = getHTMLFromInclude('menu.php');
$arrTemplate['{SIDEMENU}'] = getHTMLFromInclude('menuleft.php');

$stream = stripslashes(file_get_contents('templates/t.fp.header.php'));
//ini bagian parsing template tag
foreach($arrTemplate as $template => $value)
	$stream = str_replace($template, $value, $stream);
echo $stream;

Nah, sekarang di interface admin untuk template, tinggal taruh tag {TOPMENU} sesuai kebutuhan saja, tanpa harus repot-repot dengan include untuk menu.php.


Men-debug Script Transaksi IPN

Script IPN adalah script yang digunakan oleh online payment processor untuk mem-verifikasi suatu transaksi. Disini kan kita tidak tau apakah script tersebut berjalan dengan semestinya atau ada yang gagal di suatu bagian script. Cara yang biasa saya lakukan adalah dengan membuat log proses yang dilakukan. Apa input dari server, bagaimana script saya mengolah, query apa saja (kalau ada) yang dilakukan, apa response script saya kepada server.

Log yang biasa saya lakukan ada dua cara, pertama dengan menulis step by step proses ke file log dan yang kedua, dengan cara membuffer output dan menyimpan serta meng-echo hasilnya ke file dan output stream. Cara pertama, biasanya saya hanya menggunakan function sebagai berikut:

function writeLog($log)
	$fl = fopen("IPN_logger.txt", "ab");
	fwrite($fl, "$log\n");
//cara menggunakannya:
writeLog('=======PROCESS START=======');
writeLog('date:'.date('Y-m-d H:i:s'));
writeLog('=======PROCESS   END=======');

Sedangkan untuk cara kedua, caranya sebagai berikut:

$file = "IPN_logger.txt";
//mulai tulis output
echo '=======PROCESS START=======';
echo 'date:'.date('Y-m-d H:i:s');
//lakukan proses
echo '=======PROCESS   END=======';
//selesai, ambil outputnya
$saved_page = ob_get_contents();

$fl = fopen($file, 'ab');
fwrite($fl, $saved_page);

//clean up buffer;

//outputkan HTML-nya.
echo $saved_page;


Mimic Oracle’s LOV Feature for Web Application Part 2: Add Database Support

On my previous tutorial, you have seen how to create a Lookup Grid. That’s just basic, without database support.
In this tutorial, I’ll enhance the script with database and search support. What you’ll need first is obviously a database server. If you don’t have the tutorial file, please download it from my previous tutorial. Next think to do is, create a file which contain database information. Let’s call it db_conn.php.

$conn = mysql_connect('localhost', 'db_username', 'db_password');

With database information obtained, now we’ll move to lov.php file. Open it and include db_conn.php.


Next, delete all <row></row> xml data. Add this code right after header("Content-Type: text/xml");.

$x = isset($_GET['query']) ? $_GET['query'] : '';
$addSQL = "";
	$addSQL = "WHERE name LIKE '%".mysql_escape_string($x)."%'";
$sql = "SELECT * FROM friends $addSQL";
$rs = mysql_query($sql, $conn);

On place where <row></row> was, add this code:

	$select = 'selected="1"';
	while(false !== ($r = mysql_fetch_array($rs))){
		echo '
	<row id="'.$r&#91;'id'&#93;.'" '.$select.'>
		$select = "";

Now the XML generator part is ready, now we’ll head to HTML part.
Please add this code right before <div id="gridbox" height="100%"></div>

<div id="searchbox">
	Search&nbsp;<input type="text" id="searchText" value="">&nbsp;
	<input type="button" onclick="doLimit(document.getElementById('searchText').value)" value="Search">

And this javascript function inside HTML HEAD tag.

<script language="javascript" type="text/javascript">
	var mygrid = null;
	function doLimit(txt){

That’s it, save your lov.php file and run it to test. You can also try in online here
and download the example file here. Any question you might have, you can write in here in comment form below.
I’ll try to answer when I have time.


Mimic Oracle’s LOV Feature for Web Application

Pertama-tama saya mau minta maaf dulu, karena mulai posting ini saya akan semakin banyak memberikan content dalam bahasa Inggris. Saya ingin meningkatkan jumlah pembaca dari luar negeri.

For those of you who happen to develop an oracle application using oracle form, you’ll probably know that it has feature called LOV. This feature will show up a popup window that has a list of value for related field that is shown in grid form. I find this very useful and I miss this feature when I develop an intra net application.

In this post, I try to introduce a solution that mimic Oracle’s LOV. First, we need a javascript library called dHtmlXgrid. After that, we need to create a html form:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>LOV Test</title>
<script language="javascript">
	function callLOV(){
		var url = "lov.php";
		var opt = "width=690,height=180,left=100,top=100,scrollbars=yes,resize=no,menubar=no,toolbar=no,directories=no";
		window.open(url, "lov", opt);
	function fillForm(arr){
		document.getElementById('txtNIM').value = arr[0];
		document.getElementById('txtName').value = arr[1];
		document.getElementById('txtCity').value = arr[2];
		document.getElementById('txtPhone').value = arr[3];
		document.getElementById('txtEmail').value = arr[4];
	function kc(e) {
		var k;
		if (e.charCode) {
			k = e.charCode;
		} else
			if (e.keyCode) {
				k = e.keyCode;
		return k;
<style type="text/css">
	img { border: none;}

<table width="35%" border="0">
    <td><form id="form1" name="form1" method="post" action="">
      <legend>Friend List</legend>
      <table width="100%" border="0">
          <td width="23%">NIM</td>
          <td width="77%"><input name="txtNIM" type="text" id="txtNIM" />
			onKeyPress="if(kc(event) == 13){ callLOV(); }"
            <img src="dhtmlxgrid/popup.gif" name="imgPopup" width="12" height="15" id="imgPopup" /></a></td>
          <td><input name="txtName" type="text" id="txtName" /></td>
          <td><input name="txtCity" type="text" id="txtCity" /></td>
          <td><input name="txtPhone" type="text" id="txtPhone" /></td>
          <td><input name="txtEmail" type="text" id="txtEmail" /></td>

This should look like this: You click on popup image and it will launch LOV page.

Ok, form is ready, now move to LOV page. For this, we’ll create another file. Let’s call it lov.php. Here’s the code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <title>LOV Friend</title>
	<script src="dhtmlxgrid/dhtmlXGrid.js"></script>
	<script src="dhtmlxgrid/dhtmlXCommon.js"></script>
	<script src="dhtmlxgrid/dhtmlXGridCell.js"></script>
	<link rel="stylesheet" type="text/css" href="dhtmlxgrid/grid.css">
<div id="gridbox" height="100%"></div>
<script language="javascript" type="text/javascript">
	function doOnEnter(rowId,cellInd){
            var caller = window.opener;
            arrData = new Array();
            arrData[0] = this.cells(rowId, 0).getValue();
            arrData[1] = this.cells(rowId, 1).getValue();
            arrData[2] = this.cells(rowId, 2).getValue();
            arrData[3] = this.cells(rowId, 3).getValue();
            arrData[4] = this.cells(rowId, 4).getValue();
	mygrid = new dhtmlXGridObject('gridbox');
	mygrid.setHeader("ID, NAME, CITY, PHONE, E-MAIL");

A little explanation from the above code:

<div id="gridbox" height="100%"></div>

is your grid place-holder that is used in the following code

mygrid = new dhtmlXGridObject('gridbox');

The other code is explained in dHtmlXgrid’s documentation, you should see it. One other thing that is need an explanation is this snippet


This one is the key to connect LOV with our form, which will call fillForm function in html form’s page.

Now, this tutorial is complete, you can test it here. Follow this link to download the source file. Any question, just throw it below in comment form.