Installing and Configuring Laravel in Ubuntu

Laravel installation needs the Composer to be installed first. As the Composer will resolve the dependencies needs for the Laravel.

Install Composer
Composer is a popular dependency management tool for PHP, created mainly to facilitate installation and updates for project dependencies. It will check which other packages a specific project depends on and install them for you, using the appropriate versions according to the project requirements.
We will use composer to install Laravel and if any dependencies.

First do an update of Ubuntu package manager
sudo apt-get update

Now we need curl to download Composer.
Also we need php5-cli for installing and running Composer from command line.

sudo apt-get install curl php5-cli git

Now to download and install Composer as a system-wide command named composer, under /usr/local/bin execute the following command
curl -sS | sudo php -- --install-dir=/usr/local/bin --filename=composer

After the installation check it, everything works fine.
execute the command
if you see the composer version and other info on the command parameters, composer installation is perfect.

Laravel installation

To install Laravel, we shall use the laravel installer, as it is the officially recommended/preferred method
So, execute the command to install
composer global require "laravel/installer=~1.1"
This installs the Laravel globally

Laravel has following requirements
PHP >= 5.4
Mcrypt PHP Extension
OpenSSL PHP Extension
Mbstring PHP Extension
Tokenizer PHP Extension
PHP_JSON extension (for some OS distros, we need to install manually)


That’s it. we are ready to go. Laravel is setup in your system. You can create new projects using Laravel. for that refer Laravel documentation.

If you use Apache for serving your website, you would need to enable mod_rewrite module.

By default, the Laravel comes with the public/.htaccess file that is used to allow URLs without index.php. If this default file comes with Laravel, does not work with your Apache installation, then create a new .htaccess file with the following contents or make sure your .htaccesss has to he following contents

Options +FollowSymLinks
 RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
 RewriteCond %{REQUEST_FILENAME} !-f
 RewriteRule ^ index.php [L]


Fetch / Read all email addresses from a web page using JavaScript

Recently I was looking some consultants mails ids and found some sites, in which the list of job consultants’ mail ids were listed with their names, address and email ids. But it was a tedious job to go thru the websites, classified portals pages to copy each and every mail id and save it to Excel sheet for further reference/process.
So I came up with this small script, which can be run from the Firebug or Chrome console.
just copy and paste this snippet into the console and call the findEmails function.
Calling the script is very easy. call the script as findEmails(). Voila. Worked as a charm.

function findEmails(){
var StrObj = document.body.innerText; var separateEmailsBy = ", ";
var email = ""; // if no match, use this
var emailsArray = StrObj.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+\.[a-zA-Z0-9._-]+)/gi);
if (emailsArray) {
email = "";
for (var i = 0; i < emailsArray.length; i++) { if (i != 0) email += separateEmailsBy; email += emailsArray[i]; } } return email; }

you may need to tweak a little bit to make it work for all email address patterns.

SVN Quick Installation Guide in Ubuntu

For all of the installation and configuration process, you need to login as root.


apt-get install subversion (this will install the subversion package) Install any other dependencies if any as required for your system.

Server Configuration

The following steps assume that, the necessary packages are installed. Now we will create the folders and the repository. The SVN repository can be placed in several places in the server. Most common places are /var/svn/ , /svr/svn/,? /home/svn/ etc.

First of all create a new user group named ?subversion?
addgrp subversion
Then add youself and the www-data ( the apache user) to this groups. You can do this by doing the following steps

1 Choose System > Administration > Users and Groups from your Ubuntu menu.
2 Select the Group tab
3 Click the ‘Add Group’ button
4 Name the group ‘subversion’
5 Add yourself and www-data (the Apache user) to this group .

Note: As default, the user configuration does not show system users. To see the Apache user in this list, do the following
a) Start gconf settings editor: Alt+F2 gconf-editor Enter.
b) In the tree, locate /apps/gnome-system-tools/users.
c) Select the “showall” check-box.

Now logout and login again in order to the above changes to be applied.
Now we will create the folder where you can place the SVN repository.

mkdir /home/svn
cd /home/svn
mkdir projectname
chown -R www-data:subversion
chmod -R g+rws
projectname<-This command will set the gid for proper permissions on all new files added to your SVN repository.

Now issue the following command to create the SVN repository
svnadmin create /home/svn/projectname
chmod -R g+rws projectname Issue this command again, because svnadmin will create folders and files without the write access to the group.

Importing the Project into SVN

Now go the folder where your project folder is present. Then issue to following command to import your project into SVN repository.
svn import projectnamefile:///home/svn/projectname ?m ?Initial checkin of projectname into SVN?

Creating Users

Now we have created the repository and imported the project into it successfully. Now we have to control the access to the repository by creating users.

If the SVN is just now installed the passwd file will not exist and it should be created first,?? under the /etc/subversion folder. This is the file that will contain the authentication details for the users.

to create the the password file, use the command
htpasswd ?c /etc/subversion/passwd username (Enter the username here)

this will prompt us to enter the password for the user. Enter the password. Now the user is added. To add more users use the same command above without using the ?c switch. For example to add another user, use the following.

htpasswd /etc/subversion/passwd username2 (Enter the second username here)

Checking out from Repository

We have created the repository, imported out project into SVN and created the users also. Now to check with the installation and repository, we have to checkout our project from the repository. Go to any of your working folder(not to the svn repository folder) first. To checkout use the following command

svn co file:///home/svn/projectname (this will checkout the projectname from SVN repository)

That?s it we are done with the our basic things to use SVN.? To access SVN over various protocols like http://, https://. svn:// and svn:+ssh// we can refer ubuntu or SVN documentation. For an example I?ll explain how to access our SVN repository over http:// (WebDAV).

Access the SVN via WebDAV (http://)

To access the SVN repository via WebDAV, we must configure the Apache server.
First we have to install the libapache2-svn package
apt-get install libapache2-svn

Then add the following snippet to the /etc/apache2/mods-available/dav_svn.conf file.

<Location /svn/projectname>
DAV svn
SVNPath /home/svn/
AuthType Basic
AuthName “
projectname subversion repository”
AuthUserFile /etc/subversion/passwd
Require valid-user

Hope this will help somebody who would like to get all the basic, necessary steps to start using the SVN. Let me know your feeback.

For further reference see the following links

Printing from a popup window

Recently one of my buddy tried to use window.print from a popup window
he were working on in webpage. And everytime he called window.print, it
doesn’t worked and the pop window went blank. He asked me to sort this out.

I tried out with this below technique and it worked.
Actually, window.print doesn’t work in a child window which is opened using the method
we have to use it as

function printChildWindow() {
var newWindow ="yourhtmlhere.html", "newWindow", "height=200,width=300");
The window.print command stalls because the new window is still open
for input. If it is closed with windowName. document. close ; then the print
command will work as expected.

Read data from a CSV file in PHP

// open the text file
$fd = fopen ("pilots.csv", "r");
// initialize a loop to go through each line of the file
while (!feof ($fd)) {
$buffer = fgetcsv($fd, 4096); // declare an array to hold all of the contents of each
//row, indexed
echo "n";
// this for loop to traverse thru the data cols
// when this is re-created with MySQL use the mysql_num_fileds() function to get
// this number
for ($i = 0; $i < 5; ++$i){
if ($buffer[$i] == ""){
$buffer[$i] = " ";
// print 's with each index
echo "$buffer[$i]n";
echo "n";
fclose ($fd);

How to Uninstall IE7 Beta

How to Uninstall IE7 Beta. Here is a simple way to uninstall IE7 Beta. uninstalling IE7 first seemed to be a hectic task and i thought that my system would crash. But it was as simple like uninstalling a normal software. Thank God. I got the IE6 back.

1. Go to Control Panel
2. Click Add or Remove Programs
3. Click Show Updates checkbox
4. Click whatever version of IE7 you have. For example “Internet Explorer 7 Beta 2 Preview”
5. Click the Change/Remove button

Functions find Left and Right position of an Object

When a layer is inside another layer, it’s style.left and positions can both be ‘0’
but the layer itself can be 500 pixels away from the actual margin. These functions will return
the true offset.
// To find the left position, add this snippet to your code:

function getPositionLeft(This){
var el = This;var pL = 0;
return pL

// To find the top position, add this snippet to your code:

function getPositionTop(This){
var el = This;var pT = 0;
return pT

How to Disable the browsers’ back button

You can Disable the browsers’ back button if you want to prevent your users to go back for some reasons like the registration page or for some pages once they are submitted should not be reversed back, which might lead into unwanted problems .

There is a little hack to achieve this, you can use the following js code.


Close Window in IE from javascript. (Small Hack)

When trying to close an window from javascript in IE, which is opened manually,
a security warning “The web page you are viewing is trying to close the window. Do you want to close this window? Yes|No ” is popping up. Is there any possibility to close a window silently? Yes.

A simple hack i found on the web will help to get rid of this situation.

self.opener = this;

but in Firefox you can do this. Firefox will not allow you to close using the above code. Maybe anybody found/having any code post it here.