Tuesday, June 28, 2011

Install Linux on Window 7 using Virtual Box

1. Download and Install Virtual Box
http://www.virtualbox.org/wiki/Downloads

VirtualBox 4.0.10 for Windows hosts x86/amd64

2. Create New Virtual Machine
Linux Fedora
Memory 1024MB
Hard Disk 8G

3. Start Virtual Machine
Auto Capture keyboard: capture the keyboard every time VM window is activated and unavailable to other applications

Host key to uncapture: Right Ctrl

Problem1: FATAL: NO bootable medium found! System halted.
Solution1:
When you first create a Virtual Machine with VirtualBox, there is no OS installed on the HD image. You have to have the VM mount a bootable ISO image to install the OS from.

Download Fedora disk image, create a folder C:/Fedora
CD/DVD device, select the disk image.

Problem2: GNOME 3 Failed to Load (graphics hardware or driver is not capable of delivering the full GNOME 3 experience.

Install Apache and PHP on Win 7

Install Apache on Windows 7 - how to
http://www.webdevelopersnotes.com/how-do-i/install-apache-windows-7.php


1.Go to the Apache download page.
Click on Win32 Binary without crypto (no mod_ssl) (MSI Installer) file
apache_2.2.14-win32-x86-no_ssl.msi

2. Download and Install

3. Test in browser http://localhost/


MySQL on Windows 7 64 bit – Installation with Apache and PHP
http://www.webdevelopersnotes.com/blog/mysql-windows-7-64bit-installation-with-apache-and-php/

Install PHP on Windows 7
http://www.webdevelopersnotes.com/how-do-i/install-PHP-windows-7.php

How to Install PHP 5.3 on Windows
http://www.sitepoint.com/install-php53-windows/

1. Go to PHP Download Page

which one to choose?

http://www.websiteadministrator.com.au/articles/install_guides/installing_php535_pg2.html

A Thread Safe version should be used if you install PHP as an Apache module. The Non Thread Safe version should be used if you install PHP as a CGI binary.

Download the VC6 builds if you are using the standard Apache.org web server. The VC9 builds should be used for the Apache Lounge binaries or IIS.

Wednesday, May 25, 2011

Clean Computer

1. Delete Stored Password in Firefox
1) In Firefox click Tools > Options.
2) Click Security at the top.
3) Click the Show Passwords button.
4) Find the web site you wish to remove in the list. Click/highlight it with your mouse.
5) Click Remove and click Close then OK when you are finished.

Friday, March 25, 2011

Tuesday, March 1, 2011

YUI Calendar

1. YUI: Using Event.addListener. One Calendar, Multiple Fields

http://grasshopperpebbles.com/ajax/yui-using-eventaddlistener-one-calendar-multiple-fields/


created a variable and set it to null:
var clickEl = null;

use an Event Listener (Event.Listener) using the ids of the input fields:

var ids = ["appoint_date", "interp_date", "service_date", "cancel_date"];
Event.addListener(ids, "click", showCal);


When a user clicks on one of the input fields, the showCal function is called. The showCal function sets the clickEl variable to the id of the “clicked” input field and then shows a YUI Dialog component that contains the YUI Calendar.
function showCal(e) {
clickEl = this.id;
dlgCal.show();
}

When a date is selected, the date value is inserted into the appropriate input field:
var selDate = calCal.getSelectedDates()[0];
var dStr = selDate.getDate();
var mStr = calCal.cfg.getProperty("MONTHS_SHORT")[selDate.getMonth()];
var yStr = selDate.getFullYear();
Dom.get(clickEl).value = yStr + "-"+ mStr + "-" + dStr;
...




Tuesday, February 22, 2011

mysql on linux

1. Use command line client - mysql
Genral syntax
mysql -u DBUSER -h DBSERVERNAME -p

So at a shell prompt you type all one single line to connect to database server install on localhost for root user:
mysql -u root -h localhost -p

Supply the password when prompted for password.

2. Use PHP to connect to MySQL

http://www.cyberciti.biz/faq/how-to-connect-to-my-mysql-database-server-using-command-line-and-php/


$link = mysql_connect("localhost", "USERNAME", "PASSWORD");
mysql_select_db("DATABASE");

$query = "SELECT * FROM TABLE";
$result = mysql_query($query);

while ($line = mysql_fetch_array($result))
{
foreach ($line as $value)
{
print "$value\n";
}
}

mysql_close($link);


3. Mysql list databases
http://www.cyberciti.biz/faq/mysql-command-to-show-list-of-databases-on-server/

mysql> show databases;
output

+--------------------+
| Database |
+--------------------+
| information_schema |
| test |
+--------------------+
2 rows in set (0.00 sec)


Use database
mysql> use test;

List tables
mysql> show tables;

4. Create a mysql database
http://www.cyberciti.biz/faq/howto-linux-unix-creating-database-and-table/
Create database
mysql>CREATE DATABASE books;

Use database
USE books;

Create Table
mysql>CREATE TABLE authors (id INT, name VARCHAR(20), email VARCHAR(20));

Add data
mysql>INSERT INTO authors (id,name,email) VALUES(1,"Vivek","xuz@abc.com");

Display all rows
mysql>SELECT * FROM authors;

5. Drop database / table
Drop database
mysql>DROP DATABASE atomstore;

Thursday, February 17, 2011

PHP Memcache

PHP Memcache Manual
http://php.net/manual/en/book.memcache.php
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.

Note: there are two *distinct* memcache PHP implementations
1) pecl-memcache
2) pecl-memcached

Using Memcache vs Memcached with PHP
http://stackoverflow.com/questions/1442411/using-memcache-vs-memcached-with-php

Memcache vs Memcached
http://stackoverflow.com/questions/1825256/memcache-vs-memcached


Comparison
http://code.google.com/p/memcached/wiki/PHPClientComparison

Install on Fedora
yum install php-pecl-memcache
fedora 100% |=========================| 2.1 kB 00:00
http://rpm.livna.org/fedora/7/i386/repodata/repomd.xml: [Errno 12] Timeout:
Trying other mirror.
http://livna.cat.pdx.edu/fedora/7/i386/repodata/repomd.xml: [Errno 14] HTTP Error 404: Not Found
Trying other mirror.


Check
ps -eaf | grep memcache

Check if memcache installed
phpinfo();

Check if memcache is running
telnet localhost 11211

Connection Refused


10 baby step to install Memcached Server and access it with PHP
http://www.webdeveloperjuice.com/2010/01/25/10-baby-steps-to-install-memcached-server-and-access-it-with-php/
Step1 Install libevent ,libmemcached and libmemcached devel (dependency)
yum install libevent
Setting up Install Process
Parsing package install arguments
Package libevent - 1.3b-1.fc7.i386 is already installed.
Nothing to do

yum install libmemcached libmemcached-devel
Setting up Install Process
Parsing package install arguments
No package libmemcached available.
No package libmemcached-devel available.
Nothing to do

Step2 Install Memcached Server
yum install memcached
Setting up Install Process
Parsing package install arguments
Resolving Dependencies
--> Running transaction check
---> Package memcached.i386 0:1.2.3-7.fc7 set to be updated
--> Finished Dependency Resolution

Dependencies Resolved

=============================================================================
Package Arch Version Repository Size
=============================================================================
Installing:
memcached i386 1.2.3-7.fc7 updates 50 k

Transaction Summary
=============================================================================
Install 1 Package(s)
Update 0 Package(s)
Remove 0 Package(s)

Total download size: 50 k
Is this ok [y/N]: y
Downloading Packages:
(1/1): memcached-1.2.3-7. 100% |=========================| 50 kB 00:00
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
Installing: memcached ######################### [1/1]

Installed: memcached.i386 0:1.2.3-7.fc7
Complete!

Step3 Start Memcached server
memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody
(d = daemon, m = memory, u = user, l = IP to listen to, p = port)

Step4 Check your memcached server is running successfully
ps -eaf | grep memcached
nobody 1888 1 0 07:29 ? 00:00:00 memcached -d -m 512 -l 127.0.0.1 -p 11211 -u nobody
root 1897 1827 0 07:30 pts/1 00:00:00 grep memcached

Step 5: Connect Memcached server via telnet
telnet 127.0.0.1 11211
Trying 127.0.0.1...
Connected to 127.0.0.1.
Escape character is '^]'.

Step 6: Check current status of Memcached Server on telnet prompt
stats
STAT pid 1888
STAT uptime 153
STAT time 1297945907
STAT version 1.2.3
STAT pointer_size 32
STAT rusage_user 0.054991
STAT rusage_system 0.027995
STAT curr_items 0
STAT total_items 0
STAT bytes 0
STAT curr_connections 1
STAT total_connections 2
STAT connection_structures 2
STAT cmd_get 0
STAT cmd_set 0
STAT get_hits 0
STAT get_misses 0
STAT evictions 0
STAT bytes_read 7
STAT bytes_written 0
STAT limit_maxbytes 536870912
STAT threads 4
END

Step 7: Exit telnet
quit
Connection closed by foreign host.

Step 8: Install PHP client to access Memcached Server
pecl install memcache
It will make “memcache.so”, you have to just put it on your /etc/php.ini file.

WARNING: channel "pecl.php.net" has updated its protocols, use "channel-update pecl.php.net" to update
Skipping package "pecl/memcache", already installed as version 3.0.2
No valid packages found
install failed

Step 9: Restart your apache server
service httpd restart

Step 10: Open your favorite editor to type below code and execute it, it will cache your data into Memcached server and access it back for you

$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211) or die ("Could not connect"); //connect to memcached server
$mydata = "i want to cache this line"; //your cacheble data
$memcache->set('key', $mydata, false, 100); //add it to memcached server
$get_result = $memcache->get('key'); //retrieve your data
var_dump($get_result); //show it