Skip to content


Speedup cakephp apps

This is a great article about speeding up cakephp apps:

http://www.pseudocoder.com/archives/2009/03/17/8-ways-to-speed-up-cakephp-apps/

Posted in Uncategorized.


cpanel – view ftp activity

This is a quick way to view ftp access activity in cpanel:

CODE:
  1. </p><p>
  2.  grep account_name /var/log/messages</p><p>

the message are archived chronologically like messages messages.1 messages.2 messages.3 messages.4 with messages.1 being the most recent

Posted in Uncategorized.


Copy a file to remote server with scp

This assumes that ssh runs on the remote machine.

To copy a file to a remote machine use the following command:

CODE:
  1. scp /path/to/file user@remotehost:/path/to/destination

To set the access port use the -P switch:

CODE:
  1. scp -P 1234 /path/to/file user@remotehost:/path/to/destination

If you need to copy from the remote host to the local host, reverse the above command

CODE:
  1. scp user@remotehost:/path/to/file /path/to/destination

if you need to copy an entire directory full of files to a remote location, use the -r argument

CODE:
  1. scp -r /path/to/directory/ user@remotehost:/path/to/destination/

If you are transferring logfiles or other highly compressible files, you might benefit from the -C argument. This turns on compression, which, while it will increase the CPU usage during the copy, should also increase the speed in which the file transfers.

Use the -l argument to limit how much bandwidth is used. Follow -l with the bandwidth you want to use in kilobits per second. So, to transfer a file and limit it to 256 Kbps use the following command

CODE:
  1. scp -l 256 /path/to/file user@remotehost:/path/to/destination

Posted in Uncategorized.


Postfix. view message in queue

use

mailq

to dispay all the messages and message id

use

postcat -vq message_id

to display the message contents

Posted in linux, postfix.

Tagged with , .


Cakephp find(’list’) and select

How about a little trick to extend the find(’list’) functionality?..

Let’s say we need to display a list of users, but instead of just User.id and User.name we need to have User.id, as well as User.name and User.email combined. Unfortunately find(’list’) doesn’t have that type of functionality out-of-the-box. Well, that’s OK, we’ll make our own…

CODE:
  1. function find($type, $options = array()) {
  2. switch ($type) {
  3. case 'superlist':
  4. if(!isset($options['fields']) || count($options['fields']) &lt;3) {
  5. return parent::find('list', $options);
  6. }
  7.  
  8. if(!isset($options['separator'])) {
  9. $options['separator'] = ' ';
  10. }
  11.  
  12. $options['recursive'] = -1;
  13. $list = parent::find('all', $options);
  14.  
  15. for($i = 1; $i &lt;= 2; $i++) {
  16. $field[$i] = str_replace($this-&gt;alias.'.', '', $options['fields'][$i]);
  17. }
  18.  
  19. return Set::combine($list, '{n}.'.$this-&gt;alias.'.'.$this-&gt;primaryKey,
  20. array('%s'.$options['separator'].'%s',
  21. '{n}.'.$this-&gt;alias.'.'.$field[1],
  22. '{n}.'.$this-&gt;alias.'.'.$field[2]));
  23. break;
  24.  
  25. default:
  26. return parent::find($type, $options);
  27. break;
  28. }
  29. }

Now all we have to do in our controller is:

CODE:
  1. $this->User->find('superlist', array('fields'=>array('User.id','User.name','User.email'),'separator'=>' * '));

source

Posted in cakephp, php.

Tagged with , .