twitter
    Find out what I'm doing, Follow Me :)
If you have any question, suggestion or article topic for me to write, feel free to contact me through my shout box. ;) Some time I need an idea to write. hehe Hopefully I can help you and share my expertise.

Can I install multiple OS in one computer without reboot?

The answer is yes. You can use virtual machine to do that. Virtual Machine is a software implementation of a machine (computer) that executes programs like a real machine. In layman term, you can install OS virtually in one computer with capability same as a real computer.. err. can understand or not ??. :) . The most popular virtual machine is VMWare and you can download it free at vmware.com.

There are a lot of Virtual Machine out there from open source license as well as proprietary. You may see comparison of platform virtual machine to help you made a decisions which Virtual Machine is suitable with your needs.

How ever, I would like to share with you how to install ubuntu in MS Virtual PC 2007.

First of all, you need to download Microsoft Virtual PC 2007 and Ubuntu ISO from their respective site. If your internet connection is too slow, you can get a free DVD copy of ubuntu installer from ubuntu request a free cd site. No option for Microsoft Virtual PC 2007, you need to download it with approximate size 30.4MB. Otherwise you can get your friend to help you download it for you or go to cyber cafe and download it. Both file are free.

For this tutorial I will use MS Windows XP as a host, MS Virtual PC 2007 and Ubuntu 8.10 Server Edition.

Step 1
Install MS Virtual PC 2007 . click on setup.exe and follow the installation instruction.



Step 2

Configure virtual pc 2007 to install ubuntu. Click on Microsoft Virtual PC icon in your program files. Since this is your first time, then you need to configure new.



click next and select "Create a virtual machine" radio button. After that, click next.



Named your virtual machine file. You can change virtual machine file location by click on browse button. After that, click next.



Choose operating system from combo box. Choose other since we will install ubuntu then click next.



Allocate RAM for your virtual machine.



Create virtual harddisk for your virtual machine. You can choose an existing virtual harddisk if you already have it. In this tutorial, I'll choose "a new virtual hard disk" option. After that, click next.



You can change virtual harddisk name and location by click on browse button. In the virtual harddisk size input box, you can decide your virtual harddisk size in MB. After that, click next.



You are almost done!. click finish.



Next... How to install Ubuntu in Virtual PC 2007.

how to use wp_ajax in wordpress

last weekend I try to implement ajax in wordpress plugin. The problem is, there is no reference that I can get from wordpress wiki as well as their documentation to show the detail of how to use wp_ajax in wordpress.

How ever, here is the solution that i get how to use wp_ajax in wordpress.
Step 1.
You need to create callback function to handle ajax ( wp_ajax ) request.
function my_ajax_update(){
 if (isset($_POST['c'])){
     //you can do what ever here
 }
}


Step 2.
create add_action using wp_ajax hook.
add_action("wp_ajax_your_action_name", "my_ajax_update");

your_action_name is action name that you'll submit using ajax post or get in Step 3.

Step 3.
on jQuery post..
url_action = \'' . get_bloginfo('wpurl') . '/wp-admin/admin-ajax.php\';
jQuery.post( url_action ,  { action:"your_action_name",c:"True" } ,function(data){ 
//your return result             
                });


continue... next post I will show you the full plugin code.

so exhausted today

I feel so exhausted today. Yesterday my motorcycle breakdown and need to overhaul.I leave my motorcycle at the workshop near MRR2 at Jalan Kuari. I plan to get my motorcycle today but canceled. Maybe I go there tomorrow.

how to use syntax highlighter in blogspot

Last night I was searching syntax highlighter to make my sample code look nice and easy to read. I was googling using "blogspot syntax highlighter" keyword and found this website. This library was developed by Alex Gorbatchev and look nice for me. It's fully developed in Javascript which is compatible with all web scripting language.

I had an experience using Geshi before found SyntaxHighlighter library. Geshi is another excellent library for syntax highlighter. It's also have more supported language compared with SyntaxHighlighter. Why i didn't use Geshi?. actually there is no good reason.. just want to try SyntaxHighlighter and share with you all ;)

Alex also provide hosted library for user who are using hosted service like a blogger. His kindness make me easy to use his library.

hosted file located in http://alexgorbatchev.com/pub/sh/[VERSION].

by the way, here is the step how to use his library
Step 1.
copy below code and paste it in your template file before </head>
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shCore.css" rel="stylesheet" type="text/css">
<link href="http://alexgorbatchev.com/pub/sh/current/styles/shThemeRDark.css" rel="stylesheet" type="text/css">
<script language="javascript" src="http://alexgorbatchev.com/pub/sh/current/scripts/shCore.js"><br /><script language="'javascript'" src="'http://alexgorbatchev.com/pub/sh/current/scripts/shBrushPhp.js'/">


shBrushPhp.js and shThemeRDark.css is optional depending on what language and theme that you want to use in syntax highlighter. For more detail you may take a look at bundled syntaxes and bundled theme.


Copy below code and paste it before </script>
<script type='text/javascript'>
//<![CDATA[
function FindTagsByName(container, className, tagName)
{
var elements = document.getElementsByTagName(tagName);
for (var i = 0; i < elements.length; i++)
{
   var tagClassName = elements[i].className;
   if (tagClassName != null && tagClassName.search(className) == 0)
   {
      container.push(elements[i]);
   }
}
}

var elements = [];
FindTagsByName(elements, "brush:", "pre");
FindTagsByName(elements, "brush:", "textarea");

for(var i=0; i < elements.length; i++)
{
if(elements[i].nodeName.toUpperCase() == "TEXTAREA") {
   var childNode = elements[i].childNodes[0];
   var newNode = document.createTextNode(childNode.nodeValue.replace(/<br\s*\/?>/gi,'\n'));
   elements[i].replaceChild(newNode, childNode);
}
else if(elements[i].nodeName.toUpperCase() == "PRE") {
   brs = elements[i].getElementsByTagName("br");
   for(var j = 0, brLength = brs.length; j < brLength; j++)
   {
       var newNode = document.createTextNode("\n");
       elements[i].replaceChild(newNode, brs[0]);
   }
}
}
SyntaxHighlighter.all();
//]]>


wacha..... done

how to use it?.. type in your html editor
<pre class="brush: php">

//your php code here

</pre>


<pre class="brush: delphi">

//your delphi code here

</pre>

php global variable

Last week I got an email from someone need my help to solve her problem. She asking me why there is no result when she do echo inside function.

this is an example code to illustrate her problem.

$lang = 'bahasa melayu';
function test(){
   echo $lang;
}
test();
actually the problem is in variable declaration. The first $lang variable is a global scope variable while second $lang variable reference to local scope variable.

$lang = 'bahasa melayu'; //global scope variable
function test(){
   echo $lang; //local scope variable
}

test(); //return ''
To solve this problem you need to declare local scope variable as global.

$lang = 'bahasa melayu'; //global scope variable
function test(){
   GLOBAL $lang;  //declare $lang as a global variable
   echo $lang; //reference to global scope variable
}

test(); //return 'bahasa melayu'
others solution, you may sent variable into function parameter as an example below

$lang = 'bahasa melayu'; //global scope variable
function test($param){
   echo $param;
}

test(); //return 'bahasa melayu'
Happy coding ;)

hear back from

Opps .. this is not about a geek world, but It's about a language. ;)

hear back from someone
receive a reply from someone

Normally I'm using "reply from" but from the book I read there are using hear back from.

An example
1. "I emailed Mat Nur yesterday. I hope to hear back from him soon"
2. "A: Did you get the job?
B: No. I had an interview but I never heard back from the company"

php parse string as variable

Yesterday I blog about variable variables . By adding double sign dollar $$ we can make a string as a variable.What going to happen if I have set of variable in one string?. I got this problem when I'm using jQuery nested sortable plugin in my daily coding. yeah, nestedsortable plugin have a serialize function to get all element. I can use jQuery post or get to send this paremeter to process using ajax but I don't want to do that because I need to do other entry first before sending all variables at one time.

my problem is, the serialize hash format is like this
$str = "list_container[0][id]=1&list_container[1][id]=2
&list_container[1][children][0][id]=3
&list_container[1][children][0][children][0][id]=4
&list_container[1][children][0][children][1][id]=5";
at first I'm thinking to use explode function to split a string by using ampersand '&' and = as a delimiter and variable variables to get a variable but I think it's not so effective. Then I ask uncle google what others people do to solve this problem.Yeah, I like google... one of the search result is by using parse_str. It's so easy and this is what I want.

How to use parse_str?.
$str = "list_container[0][id]=1&list_container[1][id]=2
&list_container[1][children][0][id]=3
&list_container[1][children][0][children][0][id]=4
&list_container[1][children][0][children][1][id]=5";
parse_str($str);

//Now parse_str function will return string value as an array set.
//I can get the value by using $list_container as a variable
var_dump($list_container);
You can download sample file :How to use parse_str in form post

php variable variables

I'm sure, some time we need to create variable dynamically. the normal variable declaration in PHP is starting with dollar signs $ .
an example
$fruit = 'banana';
$fruit is a variable when 'banana' is a string value for that variable. when we do echo $fruit, the result is 'banana'.
an example
$fruit = 'banana';
echo $fruit;
//result : banana
This is a static variable. How about when I want to create new variable in a run time?. You can do it by adding double dollar sign
an example
$fruit = 'banana';
$$fruit = 'durian';
echo $banana;
//result : durian

You can download sample file : How to use variable variables in php
more information

Shhhhh don't tel anybody

hahaha... finally I decided to start blogging again. mmmp. actually this spirit comes after I attended global internet seminar last weekend. The seminar is 3 days seminar starting from Friday 19 to Sunday. Actually my bos register me and my colleague to attend that seminar.all about the seminar, you can go to my colleague web.

by the way.. I write this blog not to promote internet marketing and making money online.. but more on sharing my knowledge and finding beside to improve my writing skill and my English.