Wednesday, May 19, 2010

Scrolling while using screens

I had missed this for long:

If you are using screen and you want to scroll through the terminal use the following sequence:

ctrl+a [

After this you can use the arrow keys or ctrl + u,b etc

http://www.samsarin.com/blog/2007/03/11/gnu-screen-working-with-the-scrollback-buffer/

Monday, May 3, 2010

mysql Dumps!

mysql> SELECT * FROM  INTO 
OUTFILE '' FIELDS TERMINATED BY ',';

We can use below query for importing data from .txt file

mysql> LOAD DATA INFILE  INTO 
TABLE ''
FIELDS TERMINATED BY ',';

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