Pages

Tuesday, November 18, 2014

Mysql Puzzle(Left Join)-Take out those department who have no employees assigned to it

EMP
EMPNO   ENAME    DEPTNO

DEPT
DEPTNO   DNAME
 
 
1st Way using Subquery
 
SELECT D.DNAME
FROM DEPT D
WHERE 
NOT EXISTS (SELECT * FROM EMP E WHERE D.DEPTNO = E.DEPTNO) 

2nd way using Left Join
 
SELECT D.DNAME
FROM DEPT D
LEFT JOIN EMP E ON D.DEPTNO = E.DEPTNO
WHERE E.DEPTNO IS NULL 

Sunday, November 16, 2014

HTML - HTTP Request Types

1) GET:- Used when the client is requesting a resource on the Web server.

2) HEAD:- Used when the client is requesting some information about a resource but not requesting the resource itself.

3) POST:- Used when the client is sending information or data to the server—for example, filling out an online form (i.e. Sends a large amount of complex data to the Web Server).
POST sends data to a specific URI and expects the resource at that URI to handle the request. The web server at this point can determine what to do with the data in the context of the specified resource.

Example can be
obj.set_attribute(value)


4) PUT:- Used when the client is sending a replacement document or uploading a new document to the Web server under the request URL.
PUT puts a file or resource at a specific URI, and exactly at that URI. If there's already a file or resource at that URI, PUT replaces that file or resource. If there is no file or resource there, PUT creates one.

Example Can be
obj.attribute = value


5) DELETE:- Used when the client is trying to delete a document from the Web server, identified by the request URL.

6) TRACE:- Used when the client is asking the available proxies or intermediate servers changing the request to announce themselves.

7) OPTIONS:- Used when the client wants to determine other available methods to retrieve or process a document on the Web server.

8) CONNECT:- Used when the client wants to establish a transparent connection to a remote host, usually to facilitate SSL-encrypted communication (HTTPS) through an HTTP proxy.

Friday, September 5, 2014

Cakephp-Overview of Programming Patterns

Active Record Pattern

Active Record Pattern is for those application's which use relational databases.
The interface of an object conforming to this pattern would include functions such as Insert, Update, and Delete, plus properties that correspond more or less directly to the columns in the underlying database table.

Association Data Mapping

An Association data mapping pattern allows Relational object to associate with other Relational Objects the way they are associated in Relational Databases.

Front Controller

The Front Controller Pattern allows handling of all requests to be at a centralized location from where they are redirected specified Request Processors.

MVC

MVC expended as Model View Controller is a pattern where

Model's act as a wrapper classes for Database Table's
Controller's act as wrapper classes for Business Logic
and View act's as file for User Interface
 

Saturday, July 19, 2014

Set up htaccess permissions in ubuntu 14.04

We need to enable mod_rewrite

sudo a2enmod rewrite 

Then we need to restart Apache using following command

 
sudo service apache2 restart 

Then add following lines to /etc/apache2/sites-available/000-default.conf

<Directory "/var/www">
   Options FollowSymLinks 
   AllowOverride All
</Directory>

My apache directory is "/var/www" if yours is different change it to taste

Restart Apache again

sudo service apache2 restart 

Sunday, January 26, 2014

Debian/Linux/Ubuntu-Configure Postfix to use Gmail

Configure Postfix to use Gmail

Install necessary packages first

 sudo apt-get install postfix mailutils libsasl2-2 ca-certificates libsasl2-modules  

 Configure Postfix using


 sudo dpkg-reconfigure postfix  


Navigate to Postfix Directory

 cd /etc/postfix  

Open Postfix config file using following command

 sudo gedit main.cf  

Add following lines to it


 relayhost = [smtp.gmail.com]:587  
 smtp_sasl_auth_enable = yes  
 smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd  
 smtp_sasl_security_options = noanonymous  
 smtp_tls_CAfile = /etc/postfix/cacert.pem  
 smtp_use_tls = yes  

Now we need to create a file called sasl_passwd


 sudo vi /etc/postfix/sasl_passwd  

Add the following line to the same


 [smtp.gmail.com]:587  USERNAME@gmail.com:PASSWORD  

Configure permissions for sasl_passwd


 sudo chmod 400 /etc/postfix/sasl_passwd  
 sudo postmap /etc/postfix/sasl_passwd  

Validate Certificates


 cat /etc/ssl/certs/Thawte_Premium_Server_CA.pem | sudo tee -a /etc/postfix/cacert.pem  

Reload Postfix


 sudo /etc/init.d/postfix reload  

Test Mail from Terminal


 echo "Test mail from postfix" | mail -s "Test Postfix" you@example.com  

Copy of my php.ini mail section


 SMTP = ssl://smtp.gmail.com  
 smtp_port = 587  
 auth_username = usrname  
 auth_password = pwd  
 sendmail_from = from_mail