Debian - BASH Prompt Customization

Customization of the the Bash terminal line

Add the following codes in ~/.bashrc. Every time you open a Bash terminal, the first line will show HH:MM:SS@hostname:workingDirectory # .

Debian - Network Configuration

Manually configure network in Debian

If you are manually setting a static IP address in Debian, you have to edit /etc/network/interfaces. For example, if you want to change your eth0 interface to use a static IP address instead of dynamic IP address , change the following settings accordingly.

#iface eth0 inet dhcp #Comment this line out with the pound(#) key. It was your dhcp setting(dynamic IP address).
 
# Add the following lines below in /etc/network/interfaces.

Debian - mplayer

Usage

CakePHP - User Model::saveAll() to save hasMany association

In view

<?php
  echo $form->create('Phone', array('action'=>'save'));
 
  for($i=0; $i<3; $i++)
  {
    echo $form->input('Phone.'.$i.'.number');                                                                                      
  }
  echo $form->submit('Save');
  echo $form->end();
?>  

Here is how the Controller see the phone data after users filled the fileds and clicked on the Save button :

[PhoneNumber] => Array
  (
    [0] => Array
      (
          [id] => 1
          [phone_number] => (123)456-7569
      )
 
    [1] => Array

CakePHP - Pagination

I can't change the output of PaginatorHelper::next and PaginatorHelper::prev to return as <span>. So, I wrote code to replace <div> with <span>. https://trac.cakephp.org/ticket/3991

<?php
  //Pagination
  if($paginator->hasPage(null, 2))// Don't display pagination if there is no second page.
  {
    //&laquo;
    $sPrev = $paginator->prev('«'.__('Previous', true), null, null, array('class'=>'disabled'));
    $sPrev = str_replace('<div class="disabled">', '<span class="disabled">',$sPrev);
    $sPrev = str_replace('</div>', '</span>',$sPrev);

CakePHP - See all data that have been sent to the controller

Put the following in the function of your controller:

CakePHP - Fields Data Validations

Change validations errors messages http://book.cakephp.org/view/125/data-validation

CakePHP - Execution order of multiple validation rules

Below is a typical validations rules for User Model. The validations rules of a field are ran from bottom up. In this case, for the email field, it will run stringLength, email and then isUnique rules.

<?php
class User extends AppModel
{
  var $name = "User";
 
  // Validation rules.
  var $validate = array(
    'username'=>array(
        'isUnique'=>array(
            'rule'=>'isUnique',
            'message'=>'This username has already been taken.',
            ),
        'stringLength'=>array(

Pages

Subscribe to OpenWritings.net RSS