Thursday, April 29, 2010

Installing CPAN for perl

Installing: install cpan/
Reloading: reload cpan
dh-make-perl --install --cpan Template::Extract  :          for the module Extract from Template

Tuesday, March 2, 2010

PHP memcache

What is Memcached?(http://memcached.org/)

Free & open source, high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.
Memcached is an in-memory key-value store for small chunks of arbitrary data (strings, objects) from results of database calls, API calls, or page rendering.
Memcached is simple yet powerful. Its simple design promotes quick deployment, ease of development, and solves many problems facing large data caches. Its API is available for most popular languages.


Memcache module provides handy procedural and object oriented interface to memcached, highly effective caching daemon, which was especially designed to decrease database load in dynamic web applications.

sudo apt-get install php5-memcache

Example:

$memcache 
= new Memcache;$memcache->connect('localhost'11211) or die ("Could not connect");
$version $memcache->getVersion();
echo 
"Server's version: ".$version."
\n"
;
$tmp_object = new stdClass;$tmp_object->str_attr 'test';$tmp_object->int_attr 123;
$memcache->set('key'$tmp_objectfalse10) or die ("Failed to save data at the server");
echo 
"Store data in the cache (data will expire in 10 seconds)
\n"
;
$get_result $memcache->get('key');
echo 
"Data from the cache:
\n"
;
var_dump($get_result);
?>

Memcache Functions

Table of Contents





PECL

What is PECL?

PECL is a repository for PHP Extensions, providing a directory of all known extensions and hosting facilities for downloading and development of PHP extensions.
The packaging and distribution system used by PECL is shared with its sister, PEAR.

To see the list of packages go here:

http://pecl.php.net/packages.php

PHP APC

The Alternative PHP Cache (APC) is a free and open opcode cache for PHP. Its goal is to provide a free, open, and robust framework for caching and optimizing PHP intermediate code.

Check for the installation using:php -r 'phpinfo();' |grep apc 
If its not installed already use(on ubuntu):
  
 sudo apt-get install php-apc
 sudo /etc/init.d/apache2 restart

 or
 apt-get install apache2-prefork-dev
 pecl install apc

 
Use dpkg -L php-apc to know where the files are installed

There are two primary decisions to be made configuring APC. First, how much memory is going to be allocated to APC; and second, whether APC will check if a file has been modified on every request. The two ini directives that control these settings are apc.shm_size and apc.stat, respectively. Read the sections on these two directive carefully below. 



APC Functions

Table of Contents

Eg:

1)$bar 'BAR';apc_store('foo'$bar);var_dump(apc_fetch('foo'));?>
 

outputs : BAR 


2)
$constants = array(
    
'ONE'   => 1,
    
'TWO'   => 2,
    
'THREE' => 3,
);
apc_define_constants('numbers'$constants);
echo 
ONETWOTHREE;?>
 
From :php.net/apc
 
 

Monday, January 25, 2010

useful javascript functions

1)Window.open(url,id,extra_param) where extra_param may be toolbar=no;width,height etc.
2)window.location(url) to go to another url;

Sunday, January 24, 2010

Commands to know

Check the current runlevel :
1)who -r  or  runlevel
Change the runlevel :
init n where n=1to 6 0:halt 1:single user 2-5:multiuser 6:reboot
* man init ,update-rc.d
* link http://www.cyberciti.biz/tips/linux-changing-run-levels.html

Remove the job from running automatically in a run-level
* sudo update-rc.d -f cups remove
* sudo update cups defaults
But if the next time package is upgraded , the links(to /etc/init.d/) will again be made.
So better rename the start script to stop script S to K

Also rc.local is the script which is run after all run-level scripts have been run.Can be pretty useful to put startup commands here.



2) Command line short-cut
  Take arguments from previous command : (!*)
  like touch temp;rm !*; removes it

3)finger -l username : to check the details about a user like logged in,idle time,terminal etc .
  .plan in home dir can be used for additional info
  .nofinger can be used to restrict fingering.

4)sudo apt-get install dict-gcide
To install the webster dictionary on ubuntu

5) To find a directory/file
  find / -name 'dirname' -type d