The Advantage Of PHP

First, PHP have a unique structure, base on "share nothing" philosophy, each thread run  php web server and Zend Engine was done independently, completely freeing resources after the end of the task .This help PHP what is dinamic language and interpreter but with very fast performance, and especially, consuming very little resources. Another point is the HTTP protocol (communication protocol of the web) also operates a similar "HTTP, each request is distinct".

Second, PHP  was born to code web (see more) so designers of PHP will certainly better than other languages in web technology. PHP itself is a very powerful template engine friendly web (HTML-CSS-JavaScript).

Third, PHP is the language used for the world's most popular web, almost web hosts support PHP.  PHP also offers a number of web developers the world's largest which has built a large community, a lot bigger than other communities.











Read more reviews on TIOBE community, PHP 5th, high over a language used only Web - server side scripts.

See the latest statistics of Nexen

Fourth, PHP is open source language, so with millions of apps available, free, open source library enables programming language becomes quick and quality.
If there are 1-2 other languages eg ASP.NET product has a - two products, the PHP forum has a few dozen products have much better quality .Can see the same thing over other apps such as: Shopping, Shopping Cart, CMS.
The PHP library technology more than any other web programming, contributed by a broad community, including leading IT companies such as Oracle, Yahoo, IBM, Zend, FaceBook ...

Fifth, With open source stack LAMP technologies including the Linux operating system, Apache Web server, System Administrator Mysql database and PHP. Made a powerful open platform with a very modest cost. But easily extended.

CakePHP Console


Guide: How to generate code with CakePHP Console
  1. Start > Run > cmd [enter]
  2. cd C:\AppServ\www\cake_1.2.0.7692-rc3\cake\console
  3. cake -app C:\AppServ\www\cake_1.2.0.7692-rc3\app bake 
    (Parameter -app to specify the path to the app folder C:\appserv\www\cake_1.2.0.7692-RC3\app)
  4. Welcome to CakePHP v1.2.0.7296 RC2 Console

Using Helper TinyMCE in cakePHP 1.2

Using tinyMCE in cakePHP already guide in previous lesson (http://blog.javamonday.com/2016/06/using-tinemce-ibrowser-with-cakephp.html). However, in this lesson, i am going to guide you how to using tinyMCE through a helper tinyMCE of cakePHP.



Setup tinyMCE
You can download newest tinyMCE at : http://tinymce.moxiecode.com/download.php and copy /tinymce/jscripts/tiny_mce folder to /app/webroot/js folder.

Create helper tinyMCE
You create a helper tinyMCE  with path : app/views/helpers/tinymce.php. You can get source at : http://blog.javamonday.com/2016/06/helper-tinymce.html.

Use in controller
You declare using helper tinyMCE in controller follows

var $helpers = Array('Form', 'Tinymce'); 
Use in view
Use tinyMCE helper in view will same as use helper forms, html in cakePHP. To declare a textarea using tinyMCE, you only add some code:

<?php echo $tinymce->input('content') ?>

Here are two sample code page to view your reference:
Paragraph 1

<div class="form-container">
  <?php echo $form->create('Page'); ?>
    <fieldset>
      <legend>Page</legend>
      <?php
        echo $form->input('title');
        echo $tinymce->input('content');
      ?>
    </fieldset>
  <?php echo $form->end('Save'); ?>
</div>
Paragraph 2: In here, we will config some options of tinyMCE

<div class="form-container">
  <?php echo $form->create('Page'); ?>
    <fieldset>
      <legend>Page</legend>
      <?php
        echo $form->input('title');
        echo $tinymce->input('content', null, array(
          'theme'                             => 'advanced',
          'theme_advanced_toolbar_location'   => 'top',
          'theme_advanced_toolbar_align'      => 'left',
          'theme_advanced_statusbar_location' => 'bottom',
        ));
      ?>
    </fieldset>
  <?php echo $form->end('Save'); ?>
</div>

The advantage of using helper tinyMCE is you can choose any textarea what use tinyMCE. We can config each textarea with our idea.

Function Create Alias From Title

Here is code of  function create alias form title: 


/**
*This function will replace vietnamese character with latin character,space with '-'  
*
*@author : noname
*@param string
*@return string
*/
function convert2Alias($cs)
{

$marTViet=array("à","á","ạ","ả","ã","â","ầ","ấ","ậ","ẩ","ẫ","ă",
"ằ","ắ","ặ","ẳ","ẵ","è","é","ẹ","ẻ","ẽ","ê","ề"
,"ế","ệ","ể","ễ",
"ì","í","ị","ỉ","ĩ",
"ò","ó","ọ","ỏ","õ","ô","ồ","ố","ộ","ổ","ỗ","ơ"
,"ờ","ớ","ợ","ở","ỡ",
"ù","ú","ụ","ủ","ũ","ư","ừ","ứ","ự","ử","ữ",
"ỳ","ý","ỵ","ỷ","ỹ",
"đ",
"À","Á","Ạ","Ả","Ã","Â","Ầ","Ấ","Ậ","Ẩ","Ẫ","Ă"
,"Ằ","Ắ","Ặ","Ẳ","Ẵ",
"È","É","Ẹ","Ẻ","Ẽ","Ê","Ề","Ế","Ệ","Ể","Ễ",
"Ì","Í","Ị","Ỉ","Ĩ",
"Ò","Ó","Ọ","Ỏ","Õ","Ô","Ồ","Ố","Ộ","Ổ","Ỗ","Ơ"
,"Ờ","Ớ","Ợ","Ở","Ỡ",
"Ù","Ú","Ụ","Ủ","Ũ","Ư","Ừ","Ứ","Ự","Ử","Ữ",
"Ỳ","Ý","Ỵ","Ỷ","Ỹ",
"Đ"," ");

$marKoDau=array("a","a","a","a","a","a","a","a","a","a","a"
,"a","a","a","a","a","a",
"e","e","e","e","e","e","e","e","e","e","e",
"i","i","i","i","i",
"o","o","o","o","o","o","o","o","o","o","o","o"
,"o","o","o","o","o",
"u","u","u","u","u","u","u","u","u","u","u",
"y","y","y","y","y",
"d",
"A","A","A","A","A","A","A","A","A","A","A","A"
,"A","A","A","A","A",
"E","E","E","E","E","E","E","E","E","E","E",
"I","I","I","I","I",
"O","O","O","O","O","O","O","O","O","O","O","O"
,"O","O","O","O","O",
"U","U","U","U","U","U","U","U","U","U","U",
"Y","Y","Y","Y","Y",
"D","_");
return str_replace($marTViet,$marKoDau,$cs);
}




Begining HTML5 game part 3

To continue "Begining HTML5 game part 2" :

Today, we build and play BlackJack game.

In js folder, create player.js file : contain methods of player interactive with cards and computer

           
var Player = function(name)
{
      this.cards = [];
      this.x=400; //position for cards
      this.y=300;
      this.calcPoint=function()// calculate point of player
     {
            var total =0;
            for ( var i = 0; i < this.cards.length; i++) 
            {
                    total+=this.cards[i].value;
                      
            }
            return total;
     }
     
     this.draw = function(graphic) // draw cards of player
     {
           for ( var i = 0; i < this.cards.length; i++) 
          {
                 this.cards[i].x=this.x+i*21; // set distance between 2 cards
                 this.cards[i].y=this.y;
                 this.cards[i].draw(graphic);
          }
              
     }
}
In js folder, create computer.js, extends player.js file

var Computer =  function()
          {
                 this.x=400;
                 this.y=80;
           }
Computer.prototype =new Player(); //computer extends player
   
In dealer.js, define deal function to deal cards to player and computer :

//deal card
this.deal = function(step)
{
      if(step==5) return ;
      var card1 = this.cards.pop();
      if(step!=4)
      {
            card1.flip();
      }
      if(step==1||step==3)
      {
            this.player.cards.push(card1);
      }
      if(step==2||step==4)
      {
            this.computer.cards.push(card1);
      }
      setTimeout("dealer.deal("+(step+1)+")",1000);
}
In index.html, in head section, add :
 //set border for layout of canvas tag by 1px solid and has black color
<style type="text/css">
        canvas {
               border1px solid black;
        }
</style>
index.html-> head section -> <script> tag : add code to init player and computer and assign to player and computer:
var dealer = new Dealer();
var player = new Player();
var computer = new Computer();
dealer.player=player;
dealer.computer=computer;

index.html -> body section : add deal button :
<input type = "button" id = "dealId" name = "dealBtn" value = "Deal" onclick="dealCard()"></input>
index.html -> head section -> <script> tag : create dealCard function to handle event when player click "Deal" button.
function dealCard()
{
       dealer.deal(1);
}

To create Hit Button :
index.html -> body section -> add Hit button :
<input type = "button" id = "hitId" name = "hitBtn" value = "Hit" onclick="hit()"></input>
 index.html -> head section -> script tag : define hit function to player and computer :
function hit()
{
       player.hit();
       computer.hit();
 And same dealCard function, you need init and assign to player and computer when they hit in index.html->head section -> script tag :
player.dealer = dealer;
Computer.dealer = dealer;
In computer.js file, define hit function for computer:
this.hit = function()
           {
                  dealer.computerHit();
}
            
In player.js file, define hit function for player:
  this.hit = function()
         {
                   dealer.playerHit();
In dealer.js, create hit fuction for player and computer :
this.playerHit = function()
         {
                var card = this.cards.pop();
                this.player.cards.push(card);
                card.flip();
         }
         this.computerHit = function()
         {
               var card = this.cards.pop();
               this.computer.cards[this.computer.cards.length-1].flip();
               this.computer.cards.push(card);
Result :
  
Now, we create more Stand and Repeat button in index.html
<input type = "button" id = "standId" name = "standBtn" value = "Stand" onclick="stand()"></input>
    <input type = "button" id = "repeatId" name = "repeatBtn" value = "Repeat" onclick="repeat()"></input>
And index.html->head section -> script section : define 2 functions for stand() and repeat() for player when player choose stand button or repeat button.
function stand()
 {
        player.stand();
 }
 function repeat()
 {
        player.repeat();
 }
In Player.js : define methods stand() and repeat()
   this.stand = function()
    {
        if(this.calcPoint()<21)
        {
            dealer.playerStand();
        }
    }
    this.repeat = function()
    {
        dealer.playerRepeat();
    }
In dealer.js : define methods playerStand() and playerRepeat() and checkPoint() to check Point of Player and Computer
 this.checkPoint = function()
    {
        var cPoint = 0;
        var pPoint=0;
        cPoint = computer.calcPoint();
        pPoint = player.calcPoint();
        //alert("point of computer : "+computer.calcPoint());
   
        if(actionStr=="playerHit")
        {
       
            if(pPoint>21)
            {
                alert("You lose");
                return;
            }
            if(pPoint<21)
            {
           
                if(cPoint==pPoint)
                {
                    alert("You draw");
                    return;
                }
                if(cPoint>21)
                {
                    alert("You win");
                    return;
                }
                if(pPoint==21)
                {
                    alert("You win");
                    return;
                }
            }
            if(pPoint==21)
            {
                if(pPoint==cPoint)
                {
                    alert("You draw");
                    return;
                }
                if(pPoint>cPoint)
                {
                    alert("You win");
                }
            }
       
        }
        else if(actionStr=="playerStand")
        {
            if(cPoint<=21)
            {
           
                if(cPoint>pPoint)
                {
                    alert("You lose");
                    return;
                }
                if(cPoint<pPoint)
                {
                    alert("You win");
                    return;
                }
                if(cPoint==pPoint)
                {
                    alert("You draw");
                    return;
                }
            }
            else
            {
                alert("You win");
                return;
            }
        }
   
    }
     this.playerStand = function()
    {
        actionStr="playerStand";
        this.computer.cards[this.computer.cards.length-1].flip();
        this.checkPoint();
   
    }
    this.playerRepeat = function()
    {
   
        while(this.player.cards.length>0)
        {
            var card = this.player.cards.pop();
            this.cards.push(card);
            card.flip();
            card.x = this.x;
            card.y = this.y;
        }
   
      
        while(this.computer.cards.length>0)
        {
            var card = this.computer.cards.pop();
            this.cards.push(card);
            card.flip();
            card.x = this.x;
            card.y = this.y;
        }
   
        this.shuffle();//recall shuffle() method to shuffle cards.
   
    }
Result:

It's demo. To better, you need set rate and blackjack game rule to exactly.

Full Source code : https://docs.google.com/open?id=0Bw97UupVaNHuYUpnWkpCc1J2bHc

Hope to helping ^^
Part 1
Part 2

Begining HTML5 game part 2

To continue Begining HTML5 game part 1 .

Download images for this tutorial .

https://docs.google.com/open?id=0B3wmdk4k7b_-V3Q1TTVIWW5LaWM (Save s to get zip package)

We using simple html5 game framework for develop a card game . Maybe blackjack

First, you need create Struct Folder to easy manager when your project become  complex 


In WebContent-> index.html :
Body part, add code into body of index.html file
       
<canvas id="gameCanvas" width="800"  height="550">
</canvas>

Body tag : add code into body tag :
       
           <body onload="initGame()">
       
Head-> add Script tag : define 3 methods  into <script></script> tag :
       
function draw()
function initGame()
function update()
 index.html -> draw function : add more code :
       
 update();

 requestAnimFrame(draw);
      
In js folder, create util.js file : contain some util functions and call util.js in index.htmla
       

            window.requestAnimFrame = (function(){

   return  window.requestAnimationFrame       ||

           window.webkitRequestAnimationFrame ||

           window.mozRequestAnimationFrame    ||

           window.oRequestAnimationFrame      ||

           window.msRequestAnimationFrame     ||

           function( callback ){

             window.setTimeout(callback, 1000 / 60);

           };

 })();

       

 In js folder, create card.js file : description about card object : set name , set value, draw for a card
In js folder, create dealer.js file :init for 52 cards

In index.html  : add more code in draw function
       
        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

and include 2 file :  card.js and dealer.js to script tag.


To test, i'll add more code to flip card when i click on card

Add flip function to card.js
       

           this.flip=function()

       {

               if(this.status==0)

               { 

                       this.status=1;

               }

               else

               {

                       this.status=0;

               }

       }

       
Call shuffle() function of util.js in card.js to shuffle cards.

shuffle(this.cards);
 Create position and draw cards in card.js

       
for ( var i = 0; i < this.cards.length; i++) {

                     

           t=parseInt(i/15)*4;

            

           // no animation

          

           this.cards[i].x=this.x+t;

           this.cards[i].y=this.y;

           

                     

           }

    

    this.draw = function(graphic)

    {

        for ( var i = 0; i < this.cards.length; i++) 

        {

            

            this.cards[i].draw(graphic);

        }

              

    }
 
 In index.html : Add canvasClicked function to <script> tag of <head> tag to handle event

       

function canvasClicked(e)

{

    var gameCanvas = document.getElementById("gameCanvas");

    var x;

    var y;

    if (e.pageX || e.pageY) { 

      x = e.pageX;

      y = e.pageY;

    }

    else { 

      x = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft; 

      y = e.clientY + document.body.scrollTop + document.documentElement.scrollTop; 

    } 

    x -= gameCanvas.offsetLeft;

    y -= gameCanvas.offsetTop;

    for ( var i = 0; i < dealer.cards.length; i++) {

            
            if((dealer.cards[i].x<x) &&(dealer.cards[i].x+90>x) && (dealer.cards[i].y<y) &&(dealer.cards[i].y+135>y)  )

            {

                dealer.cards[i].flip();

            }

    }

}
       
 
and add more code in initGame function :

 // listerner event click
 var gameCanvas = document.getElementById("gameCanvas");
 gameCanvas.addEventListener("click",canvasClicked,true);
 
Declare and init value for dealer :
 QuercusScriptEngineFactory factory = new QuercusScriptEngineFactory();
 ScriptEngine engine = factory.getScriptEngine();
  engine.put("abc", "def");
   ScriptContext context = engine.getContext();
  try {
  engine.eval("<h1>hello   <?=$abc?>  </h1>");
 } catch (Exception e) {
  // TODO Auto-generated catch block
  e.printStackTrace();
 }


And draw cards in draw function
dealer.draw(graphic);


Result : Drew cards and when you click to card, card will be flip.
Source code :  https://docs.google.com/open?id=0Bw97UupVaNHuVDVIZ1ZOQ21hQWc

Part 1
Part 3

Create slick effects with CSS3 box-shadow


Create slick effects with CSS3 box-shadow


Drop shadows and inner shadows are some of the effects I learned to apply using Photoshop’s Blending options. But now, since CSS3 “hit the charts”, you don’t need Adobe’s design tool to add a drop shadow or an inner shadow to a box. 


Nowadays, the cool thing is that you create beautiful CSS3 shadows without actually needing Photoshop anymore. 

Browser Support



  • Internet Explorer 9/10

  • Firefox (from 3.5)

  • Safari/Chrome

  • Opera (from 10.5)


Add below Style in Header section :  
<style>
    html, body
    {
        height: 100%;
        margin: 0;
        padding: 0;
    }
 
    body
    {
        background: #b3b4b7;
        text-align: center;
    }
 
    h1
    {
      font-family: 'Allan', serif;
      text-shadow: 0 1px 0 rgba(255,255,255,.5);
      margin: 20px 0;
    }


    /* --------------------------- */
 
    body:before
    {
      content: "";
      position: fixed;
      top: -10px;
      left: 0;
      width: 100%;
      height: 10px;
      z-index: 100;
      -webkit-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
      -moz-box-shadow: 0px 0px 10px rgba(0,0,0,.8);
      box-shadow: 0px 0px 10px rgba(0,0,0,.8);            
    }


    /* --------------------------- */
 
    #box
    {
      position: relative;
      width: 60%;
      background: #ddd;
      -moz-border-radius: 4px;
      border-radius: 4px;
      padding: 2em 1.5em;
      color: rgba(0,0,0, .8);
      text-shadow: 0 1px 0 #fff;
      line-height: 1.5;
      margin: 60px auto;
    }


    #box:before, #box:after
    {
      z-index: -1;
      position: absolute;
      content: "";
      bottom: 15px;
      left: 10px;
      width: 50%;
      top: 80%;
      max-width:300px;
      background: rgba(0, 0, 0, 0.7);
      -webkit-box-shadow: 0 15px 10px #000000(0,0,0, 0.7);
      -moz-box-shadow: 0 15px 10px 
      #000000 (0, 0, 0, 0.7);
      box-shadow: 0 15px 10px 
      #000000 (0, 0, 0, 0.7);
      -webkit-transform: rotate(-3deg); 
      -moz-transform: rotate(-3deg);
      -o-transform: rotate(-3deg);
      -ms-transform: rotate(-3deg);
      transform: rotate(-3deg);
    }
    #box:after
    {
      -webkit-transform: rotate(3deg);
      -moz-transform: rotate(3deg);
      -o-transform: rotate(3deg);
      -ms-transform: rotate(3deg);
      transform: rotate(3deg);
      right: 10px;
      left: auto;
    } 
</style>
 

Add below html in body section :
  

<div id="box">
<h1>Lorem ipsum dolor sit amet</h1>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed sapien elit, pulvinar a fermentum vel,
sagittis nec dolor. Cum sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus.</p>
</div> 

Begining HTML5 game part 1

OK. Let's start .

Do you know HTML ?
Create file game.html with content :
       
 <!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

</head>

<body>



</body>

</html> 

Adding some javascript as framework
       
<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<script type="text/javascript">

    function update()

    {

        // Game UPDATE login

    }

    function draw()

    {

        // game DRAW

       

    }

    function setup()

    {

       

        setInterval(draw, 21);

        setInterval(update, 21);

    }

</script>

</head>

<body onload="setup()">

    <canvas id="gameCanvas" width="800"  height="550">



</canvas>

</body>

</html>


You can see a HTML5 Canvas tag . We will create game , and draw all thing on this canvas
function setup  some variables and create game loop .

Now we will addling some object to game . A image may be good for begin .
I will draw this image on canvas :


you can download and reset name for image is "monday.jpg" in same location of html file aaaa
       
function draw()
{

        // game DRAW

        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image(); 
        // you can download and reset name for image is "monday.jpg"

            monday.src="monday.jpg";

             graphic.drawImage(monday,100, 100);

} 
               
 Open browser and you can see this image show on canvas .

OK.  For now we implement simple event mouse event .
       

          function setup()

    {

        var gameCanvas= document.getElementById("gameCanvas");

        gameCanvas.addEventListener("click", canvasClicked,true);

        //setInterval(draw, 21);

        setInterval(update, 21);

        

    }

    function canvasClicked(e)

    {

        

        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image();

        monday.src="monday.jpg";

         graphic.drawImage(monday,e.clientX, e.clientY);

    }     
 

Function draw is not loop (commented //setInterval function call), to you can see when click to canvas , new Image is drawn.

As you see HTML5 not so hard as you think , it very simple .

Result : when you click mouse, you could see  monday.jpg draw :D
Full source
<!DOCTYPE html>

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">

<title>Insert title here</title>

<script type="text/javascript">

    function update()

    {

        // Game UPDATE login

    }

    function draw()

    {

        // game DRAW

        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image();

        monday.src="monday.jpg";

         graphic.drawImage(monday,100, 100);

        

    }

    function setup()

    {

        var gameCanvas= document.getElementById("gameCanvas");

        gameCanvas.addEventListener("click", canvasClicked,true);

        //setInterval(draw, 21);

        setInterval(update, 21);

        

    }

    function canvasClicked(e)

    {
        var gameCanvas = document.getElementById("gameCanvas");

        var graphic =  gameCanvas.getContext('2d');

        var monday = new Image();

        monday.src="monday.jpg";

         graphic.drawImage(monday,e.clientX, e.clientY);

        

    }

</script>

</head><body onload="setup()">
    <canvas id="gameCanvas" width="800"  height="550">



</canvas>

</body>

</html>


part 2 is for next post .
Part 3

[How to] Install resin webserver on centos


Resin is very strong webserver/servlet container  . It really fast and strong ,  it may be keep ~10k  concurrent connection  . This tutorial will help you install Resin as service on Centos

1. Install jdk (best is  jdk7 , skip this step if you already have JDK [5,6,7])

http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.rpm

    wget http://download.oracle.com/otn-pub/java/jdk/7u2-b13/jdk-7u2-linux-x64.rpm

    rpm -i jdk-7u2-linux-x64.rpm

2.Install resin (current version is 4.0)

    wget http://www.caucho.com/download/resin-4.0.24.tar.gz

    tar xzf resin-4.0.24.tar.gz

    cd resin-4.0.24

    ./configure

    make

    make install

In this step  script configure maybe not work because in .configure :

    tmpname=”/tmp/java$$.out”

    $JAVA_EXE -version 2> $tmpname

    grep “1\.[678]” $tmpname 1> /dev/null
    if test “$?” != “0″; then
    echo “no”
    java_version=`cat $tmpname`
    as_fn_error $? “Java 1.6 required. ${JAVA_EXE} returned: ${java_version}” “$L
    NENO” 5

   This script will check current  java version is  1.6[7,8] or not . But in centos java version is 1.6.0_23 or 1.7.0

To make it work edit  “1\.[678]”  to  grep “1\.[678]\.[0-9]\”

continue make and make install

Check resin service ready work

    service resin restart

Check by open http://yourip:8080

Done .

But some task may be you need :
- config port change to 80 instead of 8080
- config admin username/password
- config virtual host
- config memory/heap






Hello world WebSocketServer with Netty

I've done to write hello world of WebSocketServer (for html5 websocket) with Netty (a network framework  by jboss) . It's really simple to create. You start with 7 step to create WebSocketServer :
  • S1 : Create new project with "HelloNetty" name
  • S2 : Download documentation in : http://netty.io/docs/ and  lib of Netty : http://netty.io/downloads/
  • S3 : Create "lib" folder and paste 2 packages : "netty-3.4.4.Final-sources.jar" and  "netty-3.4.4.Final.jar" to "lib"


  • S4 : Add lib and source preference :


    • S4.1 : Add lib : Click right mouse to HelloWorld ->Build Path -> Configure Build Path Choose "Libraries" tab -> Add JARs -> lib -> "netty-3.4.4.Final-source.jar"
    • S4.2 : Add Source : choose lib package -> Source attachment -> Edit button -> Workspace -> choose source(netty-3.4.4.Final-source.jar) -> Ok button
  • S5 : Create "src" folder" and paste 4 files : "WebSocketServer.java", "WebSocketServerHandler.java", "WebSocketServerIndexPage.java", "WebSocketServerPipelineFactory.java" in there
  • S6 : In Src, have 2 files that you need to care to edit : "WebSocketServerHandler.java" and "WebSocketServerIndexPage.java"


    • S6.1 : In "WebSocketServerHandler.java" : we care to "handleWebSocketFrame()" method. This's method that u can do. Cause it's simple helloworld project, so, u can edit directly in this. But if your project has big, you should write others methods to clear seeing and easy manager, then, call those methods in this method.
    • S6.2 : In "WebSocketServerIndexPage.java" : it's client. But to easy, you can create new html in others folder to edit. Example, i create "test.html" file to test.
  • S7 : Run and Test Server, Client
    • S7.1 : Run Server : go to "WebSocketServer.java" file, and run.
    • S7.2 : Run Client : go to "test.html" file, copy location of "test" file, and paste to browser to run
Source code in herehttp://www.mediafire.com/?c434vlhd46cdc2y
Hope to helping ^^

Cake Bake - Cake Console


Some quick tip to use cake bake
In normal, you will type : 
$cake bake
After that, you will answer each question of cake bake as what do you generate (D/M/V/C/P/Q ...) ... how to gen.
We have a quickly statement to do that : 
  1. Want to direct generate models
    $cake bake model
    
  2. Want to direct generate controller
    $cake bake controller
    
  3. Want to direct generate view
    $cake bake view
    
  4. Want to direct generate models with name
    $cake bake model model_name
    
  5. Want to direct generate controller with name
    $cake bake controller controller_name
    
  6. Want to direct generate view with view name
    $cake bake view controller_name view_name
    
  7. Want to direct generate view with template name
    view name and template name in : /cake/console/libs/templates/views and can add or override in : /app/vendors/shells/templates/views

     $cake bake view controller_name template_name view_name
    
  8. Want to generate controller like result of scaffold
    $cake bake controller Users scaffold
    
  9. Want to generate controller add more actions for admin
    $cake bake controller Users scaffold admin
    
  10. Want to gen controller only have actions for admin
    $cake bake controller Users null admin
    
  11. Gen help
    $cake bake model help
    
  12. List of model
    $cake bake all
    
  13. model -> controller -> views
    $cake bake all Model_name