Wednesday, September 16, 2009

Installing gtalk in ubuntu - (Google atlk)

Now you can chat and talk to your gmail buddies in ubuntu...

1. check for gtk2.0 and qt4

$ sudo apt-get install libgtk2.0-dev
$ sudo apt-get install libqt4-dev


2. Remove 'pulse audio sound server'

Open synaptic package manager and remove pulse audio

3. "Download gtalx" from here

Dowload it here


4. Extract the file....

$ tar -zxvf gtalx.tar.gz

5. Get into the directory....

$ cd gtalx


and then...

$ sudo chmod u+x make
$ ./make
$ sudo ./make install


6. Enjoy.....

Please comment about your installation(whether it was a success or not....)

Take gtalx from Applications > Internet > gtalx
Enter your gmail login information..and click connect...



After successful login your online gmail buddies will be listed...
Click the "Contact" button to "chat or call" that person..


Upon clicking the contact button you will be shown a screen like this....
If you need to chat..type your message and click "send"...
If you want to talk..click 'call"....


Enjoy....It worked successfully for me...

Tuesday, September 15, 2009

MVC Directory Structure




I am sure this has great naming convention and we all could understand easily why we are having these folder structure
.

application - application specific code
config - database/server configuration
db - database backups
library - framework code
public - application specific js/css/images
scripts - command-line utilities
tmp - temporary data

Once we have our directory structure ready, let us understand a few coding conventions.

Coding Conventions

1. mySQL tables will always be lowercase and plural e.g. items, cars
2. Models will always be singular and first letter capital e.g. Item, Car
3. Controllers will always have “Controller” appended to them. e.g. ItemsController, CarsController
4. Views will have plural name followed by action name as the file. e.g. items/view.php, cars/buy.php

So you know the directory structure of MVC/Zend framework. So now we will start implementing this in real project. Let me explain more detail in next post.

and also there are many other standard frameworks, each one having their own advantages, and zend framework provides great security than anything else we just moving with zend and we will be seeing all the frameworks.

The other frameworks are

Cake PHP
Code Igniter
Symfony
Prado

To know more about zend just check out this

Zend

For more about Php Frameworks You can read this post.

Example of MVC architecture

Example of MVC architecture:

1. When the user Log In on the login page, a request is sent to the servlet handler.

2. The servlet handler dispatches the request to the appropriate control class. In this case, Login control.

3. The Control performs the action requested by the user on the Model; in this case the Login Model.

4. The Model returns a response; in this example, a successful login message.

5. The Control either redirects to another page or returns to the same page with new data since the Model has
been updated. In this case, the Control redirects to the MyPage.

6. The Interpreter gets the HTML for the page requested by the Control from the appropriate View, in this
case the MyPage View

7. The View returns the HTML for the page.

8. The Interpreter sends the HTML for the page back to the browser.

This is what happening while you are using MVC architecture. Isn't it structured and understandable. Am sure your answer is yes. So in coming posts we will develop a simple MVC application using php with the help of ZEND framework.

Model–View–Controller using ZEND framework

Model–View–Controller

Model–View–Controller (MVC) is an architectural pattern used in software engineering. Successful use of the pattern isolates business logic from user interface considerations, resulting in an application where it is easier to modify either the visual appearance of the application or the underlying business rules without affecting the other. In MVC, the model represents the information (the data) of the application; the view corresponds to elements of the user interface such as text, checkbox items, and so forth; and the controller manages the communication of data and the business rules used to manipulate the data to and from the model.


The main aim of the MVC architecture is to separate the business logic and application data from the presentation data to the user.

Here are the reasons why we should use the MVC design pattern.

1. They are resuable : When the problems recurs, there is
no need to invent a new solution, we just have to follow the
pattern and adapt it as necessary.
2. They are expressive: By using the MVC design pattern
our application becomes more expressive.

1). Model: The model object knows about all the data that
need to be displayed. It is model who is aware about all the
operations that can be applied to transform that object. It
only represents the data of an application. The model
represents enterprise data and the business rules that
govern access to and updates of this data. Model is not
aware about the presentation data and how that data will be
displayed to the browser.

In simpler terms

Model handles all our database logic. Using the model we connect to our database and provide an abstraction layer.

2). View : The view represents the presentation of the
application. The view object refers to the model. It uses
the query methods of the model to obtain the contents and
renders it. The view is not dependent on the application
logic. It remains same if there is any modification in the
business logic. In other words, we can say that it is the
responsibility of the of the view's to maintain the
consistency in its presentation when the model changes.


In simpler terms

Controller represents all our business logic i.e. all our ifs and else.

3). Controller: Whenever the user sends a request for
something then it always go through the controller. The
controller is responsible for intercepting the requests from
view and passes it to the model for the appropriate action.
After the action has been taken on the data, the controller
is responsible for directing the appropriate view to the
user. In GUIs, the views and the controllers often work very closely together.


In simpler terms

View represents our presentation logic i.e our HTML/XML/JSON code.

What is MVC Architechture

If You are planned to develop a project(Stand alone application/Web development) you have to look into many aspects regarding security,code readability and re-usability,understanding and many aspects as per your project goes.

What ever your project domain or what ever your technology chosen for project you will be having directory and file structure. Or else the total system will be confusing and some times the whole project concept will be clopsed. So you should be careful on directory and file structure once you finished your project requirement analysis, and another reason for security reason also you should follow a structured way of programming.


Whether you can define your own file structure or you can have already built in architectures.


If you are planned to write your own file structure means have these things in your mind.


1. Storage

2. Programming

3. GUI

Even stand alone or web application you should have these analysis.

Or if you are planned to use built in architectures means i always recommend you just know about MVC and you will be happily programming. Especially when it comes web application it supports you more than you expect.

Because it is not technology dependent. You can use it in PHP/ASP/JSP


What is MVC Architecture?

The main aim of the MVC architecture  is to separate the business logic and
application data from the presentation data to the user.

Advantages of MVC

1.Modifying isvery easier
2.Clean separation of roles
3.Easy to maintain and future enhancements
4.Parallel development
5.Gives the good productivity

Dis-advantages

1.For parallel development there is a needed multiple programers
2.Knowledge on multiple technologies are required

If you can able to manage above to disadvantages in your project means then i am sure you will be using MVC architecture.

Tuesday, July 21, 2009

Simplified Resolution Finder

It is a Simplified version of resolution finder using php and Jquery. As per the monitor resolution you can change your style sheet and so your web site will be looks like same in all resolutions.



Use this script

Thursday, June 25, 2009

Virtual Keyboard

This is the source which i got from other site. But i made some changes which can be useful to you. SO refer it here.


Source is here
And i got it from this site.

designshack

Wednesday, June 24, 2009

Insert distinct rows of table into another Table

Some times you may need to create a table from the other table or just you need the data of another table or another table distinct fields alone you might need.

For that here is simple query which will do your work

INSERT INTO wholegenere(url, name, genr) SELECT distinct(url), name, genr FROM `action`;

create New table example

SQL> CREATE TABLE EMP (EMPNO NUMBER(4) NOT NULL,
2 ENAME VARCHAR2(10),
3 JOB VARCHAR2(9),
4 MGR NUMBER(4),
5 HIREDATE DATE,
6 SAL NUMBER(7, 2),
7 COMM NUMBER(7, 2),
8 DEPTNO NUMBER(2));
SQL>

Inserting data into table

SQL> INSERT INTO EMP VALUES (7369, 'SMITH', 'CLERK', 7902, TO_DATE('17-DEC-1980', 'DD-MON-YYYY'), 800, NULL, 20);
SQL> INSERT INTO EMP VALUES (7499, 'ALLEN', 'SALESMAN', 7698, TO_DATE('20-FEB-1981', 'DD-MON-YYYY'), 1600, 300, 30);
SQL> INSERT INTO EMP VALUES (7521, 'WARD', 'SALESMAN', 7698, TO_DATE('22-FEB-1981', 'DD-MON-YYYY'), 1250, 500, 30);
SQL> INSERT INTO EMP VALUES (7566, 'JONES', 'MANAGER', 7839, TO_DATE('2-APR-1981', 'DD-MON-YYYY'), 2975, NULL, 20);
SQL> INSERT INTO EMP VALUES (7654, 'MARTIN', 'SALESMAN', 7698,TO_DATE('28-SEP-1981', 'DD-MON-YYYY'), 1250, 1400, 30);
SQL> INSERT INTO EMP VALUES (7698, 'BLAKE', 'MANAGER', 7839,TO_DATE('1-MAY-1981', 'DD-MON-YYYY'), 2850, NULL, 30);
SQL> INSERT INTO EMP VALUES (7782, 'CLARK', 'MANAGER', 7839,TO_DATE('9-JUN-1981', 'DD-MON-YYYY'), 2450, NULL, 10);
SQL> INSERT INTO EMP VALUES (7788, 'SCOTT', 'ANALYST', 7566,TO_DATE('09-DEC-1982', 'DD-MON-YYYY'), 3000, NULL, 20);
SQL> INSERT INTO EMP VALUES (7839, 'KING', 'PRESIDENT', NULL,TO_DATE('17-NOV-1981', 'DD-MON-YYYY'), 5000, NULL, 10);
SQL> INSERT INTO EMP VALUES (7844, 'TURNER', 'SALESMAN', 7698,TO_DATE('8-SEP-1981', 'DD-MON-YYYY'), 1500, 0, 30);
SQL> INSERT INTO EMP VALUES (7876, 'ADAMS', 'CLERK', 7788,TO_DATE('12-JAN-1983', 'DD-MON-YYYY'), 1100, NULL, 20);
SQL> INSERT INTO EMP VALUES (7900, 'JAMES', 'CLERK', 7698,TO_DATE('3-DEC-1981', 'DD-MON-YYYY'), 950, NULL, 30);
SQL> INSERT INTO EMP VALUES (7902, 'FORD', 'ANALYST', 7566,TO_DATE('3-DEC-1981', 'DD-MON-YYYY'), 3000, NULL, 20);
SQL> INSERT INTO EMP VALUES (7934, 'MILLER', 'CLERK', 7782,TO_DATE('23-JAN-1982', 'DD-MON-YYYY'), 1300, NULL, 10);
SQL>
SQL>

CREATE Table from another table with consitions

SQL>
SQL> CREATE TABLE newTable AS (SELECT * FROM emp WHERE sal > 2000);
SQL>
SQL> select * from newTable;

EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
---------- ---------- --------- ---------- --------- ---------- ---------- ----------
7566 JONES MANAGER 7839 02-APR-81 2975 20
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 09-DEC-82 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7902 FORD ANALYST 7566 03-DEC-81 3000 20
SQL>
SQL> drop table newTable;
SQL>
SQL> drop table emp;

You may need to create a copy of another table.

use this query.

CREATE TABLE new_table AS (SELECT * FROM old_table);

Its all just general sql quries, so you can execute this in Mysql,SQL server, DB2,oracle.

Finding Screen resolution using php and jquery

It will be very usefull when you are working on a project for Multi resolution monitors and the web pages should have same look in all resolutions.

Some others ways also available for this work. But this is best practice and you are going to learn it now.

I know you want to know in a single word how to do it all.

Just you are going to find client monitor resolution from your server and from that you are going to use various style sheets. Got it?

ok fine. Just follow it. In the end you will get source package also.

There are are four files available in the package.

One is index for client system output page - index.php
finder file is for client system resolution finder and store it as session - finder.php

jquery - for ajax (bcz you are going to send request to the server)
trace.js - for to trace monitor resolution and send it to server

and another two style sheets which are going to change the client system page view.

got it.?Yes you might...

Ok now The Source is here
 

About

Hi This is Elamurugan , PHP/AS Web developer from chennai.

Site Info

PHP,MYSQL,AJAX,Action scripting, css,and more tutorials