follow me on Twitter

    Saturday, November 5, 2011

    I'm still alive :P

    Gonna code a little functional plugin for our Counterstrike server and have to learn some C language to get this done :P. I'm just here to say "Hi, im still alive :P"

    Read More...

    Tuesday, March 8, 2011

    Cool Comprehensive Guide to Save Streaming Videos online

    Cool Comprehensive Guide to Save Streaming Videos online

    Please refer to this link below since it is not original from me
    http://www.pallab.net/2007/06/05/comprehensive-guide-to-saving-streaming-video/

    Read More...

    Thursday, November 26, 2009

    How to get your portable Google Chrome (v 3.0.195.33) Flash plugin!

    Google chrome is a hot stuff now. Many people are using it. As i know a lot of people got this problem with flash plug in for their Portable Google Chrome. So how to get the flash plugin? Click before and read more . . .

    It is actually pretty simple.
    1st Step:
    download the google chrome portable from Here if you don't have it

    2nd Step:
    download the Flash player xpi for windows

    3rd Step:
    rename the extension of the XPI into zip file and extra the two file from it which are
    flashplayer.xpt
    NPSWF32.DLL


    4th Step:
    Go to your google chrome path, e.g. like mine:
    "D:\GoogleChromePortable\App\Chrome-bin\3.0.195.33"
    create a new folder call plugin
    paste the two files into this folder.

    5th Step:
    open Google chrome type in about:plugins to double confirm the flash plugin is enable

    Once it is done open your browser go youtube and enjoy :P

    Read More...

    Sunday, April 5, 2009

    How to centre align a div layer

    Hi, there. I wanna share this tip with you.
    It is about how to centre align a div layer.
    Well, some people are just wondering why there is a align= "center" but it just no working.
    well, straight tot he point if you want to align a div to center you need to do this:


    <div style="margin-right:auto;margin-left:auto;width:996px;">Testing</div>



    So now check it out on your browser, is it nicely centre align?

    Read More...

    Sunday, March 29, 2009

    Ajax and PHP real time validation

    I din't update for quite sometime because i was busy traveling around after my graduation. With friends and With my girlfriends as well as my bro and sis.
    So, for today what i wanna update is about Ajax and PHP real time validation.
    So wat is "real time" it is simply just when the user type something on the textfield and whatever is inside will be validate against the server and give user the real time update about the validity of the UserName

    Ok, so how to do it?
    For me, i prepared two pages, one is call validate.html this is the page for storing the form and as well as the javascript(Ajax)

    Another page is validate.php this page will store all the server side scripting. Well in this case i will validate against the server but just give a rough explaination on that


    Ok. so wat is the the coding inside validate.html
    well, the code will be as shown below:


    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Real Time Validation</title>
    <script language="javascript">
    var XMLHttpRequestObject = false;

    if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");
    }


    function validate(keyEvent)
    {
    keyEvent = (keyEvent) ? keyEvent : window.event;
    input = (keyEvent.target) ? keyEvent.target : keyEvent.srcElement;

    if (keyEvent.type == "keyup" ) {
    var targetDiv = document.getElementById("targetDiv");
    targetDiv.innerHTML = "<div></div>";

    if (input.value) {
    getData("validate.php?username=" + input.value );
    }
    }
    }

    function getData(dataSource)
    {
    var targetDiv = document.getElementById("targetDiv");
    if (XMLHttpRequestObject) {
    XMLHttpRequestObject.open ("GET", dataSource);

    XMLHttpRequestObject.onreadystatechange = function()
    {
    if (XMLHttpRequestObject.readyState ==4 && XMLHttpRequestObject.status ==200) {
    if (XMLHttpRequestObject.responseText =="taken") {

    targetDiv.innerHTML = "<div>The username is not available</div>";
    } else {
    targetDiv.innerHTML = XMLHttpRequestObject.responseText;
    }

    }
    }
    XMLHttpRequestObject.send(null);
    }
    }
    </script>
    </head>

    <body>
    <form id="form1" name="form1" method="post" action="">

    <input type="text" name="username" id="username" onkeyup="validate(event)"/>

    </form>
    <div id="targetDiv">Result text will be here</div>
    </body>


    for these codes:

    if (window.XMLHttpRequest) {
    XMLHttpRequestObject = new XMLHttpRequest();
    } else if (window.ActiveXObject) {
    XMLHttpRequestObject = new ActiveXObject("Microsoft.XMLHttp");
    }

    Why i did this is because some javascipt is because different browser may require diff things. Like firefox simple XMLHttpRequest will do but for IE you may need ActiveXObject.

    So, wat is inside validate.php here you are:


    <?php
    if ($_GET["username"] =="alexding") {
    echo "taken";
    } else {
    echo "ok";
    }
    ?>


    Well, i din really put the full coding down here because it just to save me some time on that. So, what u need to do is do your validation against the server in the if...else statement. I thk it is pretty simple and straight forward.
    So if valid/invalid just echo whatever you want and remember to change the javascript in validate.html if you change the contents in the echo.

    So, quite simple huh. Hope you will like this.

    Read More...

    Friday, February 13, 2009

    Handle checkbox with PHP and Javascript

    I am so sorry take so long to make this post.
    I was busy with something else, and also my hard disk was crashed. Sad.
    I will try my best to update as often as possible.

    Anyway for today:

    I wanna share about my experience in handling checkbox in PHP and javascipt


    1st of all, you need to create some checkbox of cause. Thus:


    <label><input type="checkbox" name="interest[]" value="music"/>Listen to Music</label><br />
    <label><input type="checkbox" name="interest[]" value="game" />Play Game</label>


    As you can see above. Two checkbox with name interest[], next just put these two into a form, Therefore:


    <form action="test.php" method="get" onsubmit="return valid();">
    <label><input type="checkbox" name="interest[]" value="music"/>Listen to Music</label><br />
    <label><input type="checkbox" name="interest[]" value="game" />Play Game</label>
    <br /><input type="submit" name="submit" value="submit" />
    </form>


    Ok, now you are about there. The next step will be doing the javascript. I will be using getElementsByName to get the array of the checkbox. Below is my coding:


    <script type="text/javascript">
    function valid() {

    var isSubmit = false;
    var check = document.getElementsByName("interest[]");
    alert (""+ check.length);
    for (var i = 0, n = check.length ; i < n; i++){
    //alert(check[i].checked.value);
    if (check[i].checked) {
    isSubmit = true;
    }
    }
    if (isSubmit) {
    return true;
    } else {
    alert ("Something wrong");
    return false;
    }
    }
    </script>


    Once you reach here. The 1st page is done. Now we will be working on PHP (test.php)

    For PHP it is rather simple i will not go for further explain. Below is the coding:


    <?
    $array = $_REQUEST["interest"];
    foreach ($array as $v) {
    echo $v . "<br />";
    }
    ?>


    So far so good?
    >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>Get the full coding here<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<

    index.php:


    <!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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function valid() {

    var isSubmit = false;
    var check = document.getElementsByName("interest[]");
    alert (""+ check.length);
    for (var i = 0, n = check.length ; i < n; i++){
    //alert(check[i].checked.value);
    if (check[i].checked) {
    isSubmit = true;
    }
    }
    if (isSubmit) {
    return true;
    } else {
    alert ("Something wrong");
    return false;
    }
    }
    </script>
    </head>

    <body style="font-family:Verdana, Arial, Helvetica, sans-serif">
    <form action="test.php" method="get" onsubmit="return valid();">
    <label><input type="checkbox" name="interest[]" value="music"/>Listen to Music</label><br />
    <label><input type="checkbox" name="interest[]" value="game" />Play Game</label>
    <br /><input type="submit" name="submit" value="submit" />
    </form>
    </body>
    </html>


    test.php:


    <?
    $array = $_REQUEST["interest"];
    foreach ($array as $v) {
    echo $v . "<br />";
    }
    ?>

    Read More...

    Saturday, January 31, 2009

    Replace Single Quote and Double Quote in JSP

    Finally get a weekend! Yohoo~~ Now got a little bit of time to blog something lol because the next two days which is the weekend i am going to be extremely BUSY! sigh... wth is this kind of life...

    Ok, what i am going to talk about today is how to deal with those single quote and double quote in the string.

    It is pretty simple actually wat u need to do is replace it. Thus, here is your solution for single quote:


    String input = JOptionPane.showInputDialog("Any text");
    String output = input.replaceAll("'", "\\\\'");
    System.out.println(output);


    Your "input" can be anything you like.
    if u wanna replace double quote simply add in another line like this:


    String output = input.replaceAll("\"", "\\\\\"");


    PS:
    Well if you are dealing with SQL database u may wanna change the "\\\\'" to "\'\'" and the "\\\\\" to "\"\""

    ok, it is done now test it out~ any question can refer to me at alex_jinbo@hotmail.com

    Read More...