Posted
Comments None

​Website development in local computer or PC has lots many configuration. Developers who are using WAMP (Apache, MySQL and PHP bundle for windows) server can develop the website by putting the project files into the WAMP installation folder which is most of the time:

c:\wamp\www\folder_name\

and you need to access your test site as:

http://localhost/folder_name

where the folder name is your project folder name where index.php file exists. As a developer you must have thought of accessing your site as a general URL and also keeping your project folder and files outside the WAMP directory. To accomplish this you need to setup the virtual host into the WAMP server and this blog describe details steps involved to accomplish the goal.

Setting up virtual host in WAMP server involves the below steps:


Step 1: Enable the Virtual host configuration in Apache's httpd.conf file. Open the httpd.conf file usually located at "C:\wamp\bin\apache\apache2.4.9\conf" and find the below settings:

# Virtual hosts
#Include conf/extra/httpd-vhosts.conf

Initially the virtual host inclusion is commented. You need to uncomment it i.e remove the # from the Include command. So after the change the above two lines will look like:

# Virtual hosts
 Include conf/extra/httpd-vhosts.conf

Save the file. In this step you have actually enabled virtual host feature in WAMP's Apache server.


Step 2: Update the virtual hos configuration file httpd-vhosts.conf which is located under folder "C:\wamp\bin\apache\apache2.4.9\conf\extra". Here you need to add the entry of your custom host accordingly. Lets assume that your host name is example.dev and your project root folder is "d:\projects\example\www\". So the configuration should be added to the file is:

 <VirtualHost *:80>
     DocumentRoot "d:/projects/example/www"
     ServerName example.dev
     ServerAlias www.example.dev
     <Directory  "d:/projects/example/www">
        AllowOverride All
 		  Require all granted
     </Directory>
 </VirtualHost>

Now this entry will enable the virtual host to redirect to your custome folder which is outside of the wamp installation directory and you can access your web root by typing example.dev in the browser address bar.


Step 3: Change the windows host file located at "C:\Windows\System32\drivers\etc". open notepad application in administrator mode and open the file "hosts" located in the above mentioned directory. Enter the below lines into it and then save it:

 

127.0.0.1       example.dev
::1                example.dev


Step 4: Restart all services in WAMP and now you should be able to access the index.php located in your project root directory by typing the example.dev in the browser's address bar.


How to access localhost?

Now since you have enabled the virtual host, you also need to enter the local host details in the httpd-vhosts.conf which is located under folder "C:\wamp\bin\apache\apache2.4.9\conf\extra". Below will be the entry for localhost:

 

<VirtualHost *:80>
     DocumentRoot "c:/wamp/www"
     ServerName localhost
     ServerAlias localhost
     <Directory  "c:/wamp/www">
        AllowOverride All
 		Require local
     </Directory>
</VirtualHost>


Note: Change your project's host name and root folder based on your need but don't forget to follow the steps mentioned.




Author
Categories ,

Posted
Comments None

Have you installed WAMP into your PC for developing a website and looking for how to send email with it for testing your email feature is working or not? Continue reading this blog.

 

Unlike XAMP, WAMP does not come integrated with sendmail feature and thus you need to do something extra when you want to test your development waork in your local machiine. To configure WAMP for sending email you need to follow the below steps (assuming WAMP is already installed and working okay):

  1. Download the Fake Sendmail for Windows.
  2. Use Gmail or any other email account to configure the sendmail.
  3. Change te Gmail setting to allow third party email sending feature.
  4. Update the PHP.ini configuration for your website or WAMP server.

Here is the detail elaboration of the steps involved.

Step 1: Download the Fake Sendmail for Windows and put the "sendmail" folder undr your WAMP installation path. Since most of you install WAMP under C:\ drive and assuming that move the "sendmail" folder to "C:\wamp\sendmail"


Step 2: Now configure the "sendmail.ini" file which can be found on "C:\wamp\sendmail". Use the below settings for Gmail. You can configure it for other email also. After changing the "sendmail.ini" file, it will look like below:

; configuration for fake sendmail

[sendmail]

smtp_server=smtp.gmail.com

smtp_port=465

smtp_ssl=ssl

default_domain=localhost

error_logfile=error.log

debug_logfile=debug.log

auth_username=youremail@gmail.com
auth_password=gmailpassword

pop3_server=
pop3_username=
pop3_password=

force_sender=
force_recipient=
hostname=localhost

Step 3: After setting the sendmail configuration, you need to change the setting (if not already done) in your gmail. Login to your gmail account and goto Settings and enable IMAP Access in your GMail’s Settings -> Forwarding and POP/IMAP -> IMAP Access: Enabled

Also go to google account setting -> Sign-in & Security -> Allow Less Secure Apps: turn it On

Step 4: Open php.ini from “C:\wamp\bin\apache\Apache2.4.9\bin” and configure it as following (The php.ini at “C:\wamp\bin\php\php5.3.x” would not work).

 

[mail function]
; For Win32 only.
; http://php.net/smtp
;SMTP = localhost
; http://php.net/smtp-port
;smtp_port = 25

; For Win32 only.
; http://php.net/sendmail-from
;sendmail_from = you@yourdomain

; For Unix only.  You may supply arguments as well (default: "sendmail -t -i").
; http://php.net/sendmail-path
sendmail_path = "C:\wamp\sendmail\sendmail.exe -t -i"

Step 5: Restart WAMP Server

Step 6: Create file "testmail.php" under www folder of WAMP and put the below code inside. Change the to and from email.

 

<?php
$to       = 'toemail@gmail.com';
$subject  = 'Testing sendmail feature in WAMP';
$message  = 'Hi, you just received an email using sendmail!';
$headers  = 'From: fromemail@gmail.com' . "\r\n" .
            'MIME-Version: 1.0' . "\r\n" .
            'Content-type: text/html; charset=utf-8';
if(mail($to, $subject, $message, $headers))
    echo "Email sent";
else
    echo "Email sending failed";
?>

Congratulations!! You have just send email using sendmail in WAMP.



Author
Categories ,

Posted
Comments 1

ASCII C Program

Have you wondered why the above program results in infinite loop? Apparently there is no reason to be! It is a very simple program to print the ASCII table and we know that the ASCII value of characters range from 0 to 255 and it is prominent that the loop is going from 0 to 255. So why the infinite loop?

In this article, we will learn the reason but before that notice the below variable declaration. 

unsigned char c;

Notice the data type is char but unsigned. The reason is simple as an char variable can store data from -128 to +127. Since we need to print the whole ASCII range from 0 to 255, we have to make it unsigned. This is making it possible to store values from 0 to 255 in variable c. But still the question remains why does it result in infinite loop? Before giving the answer. lets take a look at the correct program first.

 

//Print the ascii table
#include<stdio.h>

int main()
{
   unsigned char c;

   for(c=0; c <= 255; c++)
   {
      printf("%3d %c\t", c, c);

      if(c%5 == 0)
         printf("\n");

      if(c == 255)
         break;
   }

   return 0;
}


Notice the condition which is causing to stop the loop being infinite. 

if(c == 255)
   break;


This condition is necessary when the value of variable c is 255, and gets incremented with the expression c++, the value becomes 256. But the variable c which is unsigned character data dype, can not store the the value 256 thus it makes it the start range value which is zero (0). Thus the condition evaluates to true always resulting in infinite loop.

The if condition is stopping the value in the variable c to become 256 and thus coming out of the loop.


Watch the video tutorial to know in details.


The ouput of the ASCII table is shown below (I have put the table in 7 columns to display in one screenshot):

ASCII Table

Please put your questions and suggestions in the comment.



Author
Categories

Posted
Comments None

Udemy

There is a say in Sanskrit that learning is the only thing in the world which increases when shared. The crave for learning of the world never stops. Learning is a continuous process and the day you stop learning you stop progressing.

Many people find online learning convenient not only because it is flexible in timing, but also it brings the best to the students. You can imagine a student in a remote place can study Mathematics from the one of the best professor in the world or someone can learn programming from the expert at his own pace sitting in room.

There are two aspect of eLearning. The first one, self paced learning (SPL), is a convenient way to say that learning anywhere any time. Normally in this mode teachers record video tutorial and students watch the video to learn. Since the learning material is already recorded, people can watch and learn simply anytime.


Places for eLearning:

Udemy:


Udemy Generic 728x90


Udemy.com is an eLearning market place where you can find the course based on your need and join the course. There are Free as well as paid courses. You can enroll based on your preference.  Start learning on Udemy today!

Youtube: YouTube is another good option to learn by watching videos. There are many learning course available for free here. You can subscribe to our channel to be updated with many more learning videos for free.

The other aspect of eLearning is from Live Online Class (LOC). Since self learning require high motivation and lacks human interaction, LOCs are a nice alternative. In this mode still the teacher and the student connect through online but communication happens real time, live. The best part about this learning method is the student can clear any doubt just asking the instructor real time. But we really can not say the learning is anytime because the schedule time of the class has to be agreed by both the teacher and student.

MyOnlineEdu.com , a Place for eLearning and Education, provides live instructor based courses on various topics. You can view the current course offering by clicking here. MyOnlineEdu.com provides free demo class of each paid class before you pay. There are multiple options you can choose from. You can read the details here about the learning options.



Author
Categories ,

Posted
Comments None

Standardizing a software product is a nightmare of product manager or software leads. When many people are working to build a software application, each developer has its own style to write code or design. Setting a standard to follow across all development modules help minimizing the risk of being diverted from standardize products.

Any fool can write code that a computer can understand. Good programmers write code that humans can understand.
--Martin Fowler


A good programmer need not only to write code that computer understands but also humans can read and understand it easily. Here come the great aspect of code readability.


Watch this video to learn more on why do we need certain good practices to follow.



In the next video tutorial, I have discussed some best practices to follow to enhance the readability of your code. Why readability is important and how it affects the maintainability?



Here are few tips to follow which not only helps to increase readability of your code but also to enhance the maintainability of your code.


Since now you know the importance of good design, do you write your code keeping low maintenance in mind for the future of your product? A good programmer should take the aspect of low maintenance cost very seriously. Why do you think it is essential? It is about the value of money your client is putting on your product. Standardization helps a whole team to follow certain standards while designing or writing code which at the end produces a standards software.

Learn more about maintainability in the next video tutorial. Learn about the DRY (Do Not Repeat Yourself) principal.


Last but not the least, practice makes a programmer perfect. Practice, Practice and Practice should be the only mantra for beginner's.

Wish you Happy Coding!!

P.S: This full lecture is also available at Udemy. Click the link here to visit Udemy Course.



Author
Categories

← Older Newer →