npm install – Please try running this command again as root/Administrator

If you are getting this error while running npm install, then you are not having write permission on .npm directory.

To get the ownership of this directory run following command

Also we need to give write permission to node_modules directory

ref –

Install Mcrypt PHP extension on Ubuntu (PHP-FPM + Nginx)

To install Mcrypt PHP extension on Ubuntu / Debian run following command ( this step is same for Nginx and apache )

This will create a mcrypt module in /etc/php5/mods-available directory. If it doesnt we need to create symlink for this.

Now enable mcrypt by running

After this restart php5-fpm service by


Upgrade Google Cloud Compute Engine VM Instance

There two ways you can upgrade or downgrade your VM instances.

a. Stop – configure – start

b. Minimum downtime ( by swapping the disk )

a. This is a very easy method to do this. The main disadvantage of this is, it requires downtime. If you are okay with a 5 – 10 minute of downtime then you can go with this method.

b. If you this to happen almost real time then follow these steps

If you have a Google cloud compute engine VM Instance and wants to upgrade or downgrade  Continue reading

How to access remote mysql server using local phpmyadmin

phpMyAdmin is a free and open source tool written in PHP intended to handle the administration of MySQL or MariaDBwith the use of a web browser. It can perform various tasks such as creating, modifying or deleting databases, tables,fields or rows; executing SQL statements; or managing users and permissions. source: wikipedia

To access remote mysql database from your local phpmyadmin, open file by

Add following line

You can refer this article to install phpmyadmin on Ubuntu:

Android Splash Screen

To add Splash Screen to you android application








Deploy WordPress button is disabled in Google Cloud Launcher

Google Cloud WordPress Launcher Screen

In order to use Click to Deploy with Google Compute Engine you need to make sure “Google Cloud Deployment Manager API” is enabled on your project. You can enable this API from Developer console->APIs page.

Google Cloud API Manager Screen

Moreover, if you have multiple accounts added in your browser try using Chrome Incognito tab to login in order to make sure your email has the right permissions.

Remove # from url in Angular JS and Laravel 5

To remove # from Angular JS application built with Laravel , add following line in your config.

Add this in your head tag

Now it will work fine till you do not refresh the page. If you refresh your page at this point, you will see page not found error, it is because now browser sends request to server and server doesn’t have the route.

To do this we will add this route at the end of routes.php



Force https on Google App Engine

To serve all request on https in Google App Engine, add following entry to your app.yaml file

For application developed in Laravel use following lines instead.

Enable password authentication and set root password – Ubuntu

To enable Password Authentication

Open file etc/ssh/sshd_config by

Search for PasswordAuthentication no, just change this to

To set root password

it will ask for new root password and confirm root password. To test this logout from current session and try to login using root as user and password that you have just assigned.


PHP Fatal error: Uncaught exception ‘UnexpectedValueExcepti$

After fresh installation of Laravel 5.1, it was not showing up the welcome page. Further investigating into this issue revealed that “storage” directory is not writable.

To make storage directory writable run following commands

Then run:

How to update Geary to latest version

Geary is an IMAP mail client for GNOME 3.

Geary recently released their new version 0.10, with various improvements. To update geary to new updated version add Yorba ppa.

Restart geary and you will see an updated version of geary.

Android Studio – Unable to run mksdcard SDK tool

When I was installing Android Studio on Ubuntu this error occurred which halted the installation

It happened twice and I thought sharing this might help others. It got resolved by running following command.



JDK Required: ‘tools.jar’ seems to be not in Studio classpath

I was installing android studio on ubuntu and come across this error.

After lots of searching I found this simple soutuion that worked for me.

This is caused by having JAVA JRE installed as opposed to JAVA JDK. Installing JDK resolve the problem.


Replace local branch with remote branch entirely


Assuming that “origin/master” is your remote branch you want to reset to. This updates your local HEAD branch to be the same revision as origin/master, and --hard will sync this change into the index and workspace as well.

ref –

Install composer on Ubuntu

To install composer on Ubuntu

Create an alias to call it by typing ‘composer’


Rename branch for both local and remote Git repositories


Get URL Query String with jQuery

To get query string value in an url, for example to get ‘user_id’ value from an url


Android – Command not found (Ubuntu)

If you encounter this error, it indicates that your environment variables are not properly set. We will add these environment variables by editing “.profile” file present in your home directory.

If you have installed android sdk through Android Studio, it is likely to be present in /home/your_user_name/Android/sdk, otherwise in /home/your_user_name/android-sdk-linux.

If you have installed it through android studio then add following line in your “.profile” file
export ANDROID_HOME=$HOME/your_user_name/Android/sdk

else add this

$ export ANDROID_HOME=~/android-sdk-linux

Then add the paths to the platform-tools and tools sub-directories

export PATH=$ANDROID_HOME/platform-tools:$PATH

You should now be able to run android from the shell. Note that you might need to reopen the terminal to make it work

Installing node js on Ubuntu using NVM

Node JS can be installed using various methods, but in this post I am going to show you how to install it using NVM (Node Version Manager)

To install NVM through curl

curl -o- | bash

or Wget:

wget -qO- | bash

The script clones the nvm repository to ~/.nvm and adds the source line to your profile (~/.bash_profile, ~/.zshrc or ~/.profile).

After this restart PC / VPS to make command NVM available. You will get list of options when you type NVM in your terminal.

Now you can run

nvm install version_name

at the time of writing, latest version of nodejs is 0.12.3. So this can be

nvm install 0.12.3

dev@devenubuntu:~$ nvm install 0.12.3
######################################################################## 100.0%
Now using node v0.12.3 (npm v2.9.1)

You can verify the installation by running

dev@devenubuntu:~$ node -v

Ubuntu – what to do when everything freezes?

(this post is just for a personal reference)
If it locks up completely, you can REISUB it, which is a safer alternative to just cold rebooting the computer.


While holding Alt and the SysReq (Print Screen) keys, type REISUB.

R: Switch to XLATE mode
E: Send Terminate signal to all processes except for init
I: Send Kill signal to all processes except for init
S: Sync all mounted file-systems
U: Remount file-systems as read-only
B: Reboot
REISUB is BUSIER backwards, as in “The System is busier than it should be”, if you need to remember it. Or mnemonically – R eboot; E ven; I f; S ystem; U tterly; B roken.

In case you like mnemonics: Raising Elephants Is So Utterly Boring, or Reboot Event If System Utterly Broken. I’ve also seen it as RSEIUB (Raising Skinny Elephants is Utterly Boring)


“System program problem detected” – Ubuntu

Disabling error-reporting is not a desirable solution!

Ubuntu has an error reporting system called apport which tries to catch all program crashes in the background and report them to help the developers.

It seems that after a dist-upgrade there are stuck some reports that are tried to be resubmitted somehow, but disabling apport is not a desirable solution.

Remove old crash-reports

Open a terminal and remove all old crash-reports that might exist in the crash-report directory:

After a reboot the popups are gone.

If you don’t want to reboot, you can close all open popups with:

(Any further new pop-ups still should be investigated. If you want to see the details,
look in /var/crash/ for any new reports)

Ref :


IMDB movie search with Ionic and Angular JS


Ionic is a beautiful, open source front-end SDK for developing hybrid mobile apps with HTML5. ( from ionic website)

AngularJS is a JavaScript framework. It can be added to an HTML page with a <script> tag. AngularJS extends HTML attributes with Directives, and binds data to HTML with Expressions. ( From w3schools )

The IMDB movie search application

In this application we will accept movie name from user and send it to movie api. We will use The Open Movie Database (which is unofficial imdb api) to fetch movie details.

In this tutorial we will be using Ionic Card Showcase to show movie poster and other details like year of release, genre, actors etc. To fetch the movie information we will user Angular JS Factory.

Following is the codepen for this application

See the Pen Imdb Movie Search by Devendra Verma (@devendraverma) on CodePen.

Resize image in Laravel

To re size image in laravel we will use a library called Intervention.

Intervention Image is an open source PHP image handling and manipulation library. It provides an easier and expressive way to create, edit, and compose images and supports currently the two most common image processing libraries GD Library and Imagick. ( from their website)

So lets start with installation, the easiest way to install intervention is through composer. So run the following command in your terminal inside your application folder

composer require intervention/image

If it asks for specify version to be installed, add current stable version for this I will enter  2.1.2 (which is latest version at the time of writing this post) .

After you have installed Intervention Image, open your Laravel config file config/app.php and add the following lines.

In the $providers array add the service providers for this package.


Add the facade of this package to the $aliases array.

‘Image’ => ‘Intervention\Image\Facades\Image’

Now the Image Class will be auto-loaded by Laravel.

Now we are done with the installation part, lets create a route to test our image re sizing.

// usage inside a laravel route

Route::get(‘/’, function() {

$img = Image::make(‘foo.jpg’)->resize(300, 200);

return $img->response(‘jpg’);


This will resize the provided image into 300 * 200 jpeg image. There some other options also, lets see them.

// To resize only the width of the image
$img->resize(300, null);

// To resize only the height of the image

$img->resize(null, 200);

// To resize the image to a width of 300 and constrain aspect ratio (auto height)
$img->resize(300, null, function ($constraint) {

// To resize the image to a height of 200 and constrain aspect ratio (auto width)
$img->resize(null, 200, function ($constraint) {

Besides image resize, intervention provides whole lot of functions to perform image manipulation. No matter if you want to create image thumbnails, watermarks or format large image files Intervention Image helps you to manage every task in an easy way with as little lines of code as possible.

Installing teamviewer 9 on Ubuntu 14.04

Do install Teamviewer 9 on your Ubuntu 14.04 box, following these steps

1. Download it

2. Install gdebi (GDebi can install local .deb packages with automatic dependency resolution (it automatically downloads and installs the required packages)

3. In the same directory you download the .deb file just run



Adding SMTP header in Laravel 4

I was working with Mandrill api to send emails, to track the emails I needed to add smtp header. Here is how you can add smtp header to emails.


How to remove multiple deleted files in Git repository

To delete files which are visible in git status can be deleted by using this simple command

You can use these commands also

This will ONLY remove the deleted files from the git.

It could be also be used for adding ONLY modified files also.

These commands also works on gitbash for windows.


How to know which port MySQL is running on – Ubuntu

To find a listener on a port, do this:

You should see a line that looks like this if mysql is indeed listening on that port.


Install Curl on Ubuntu 14.04

Open your terminal and run following command

and then restart apache


There are stopped jobs

There are stopped jobs

Sometimes when you try to logout with the logout command, you’ll get the message There are stopped jobs. This means that you have left some suspended jobs hanging around, and you should finish them off before you log out. Type jobs as above to get a list of what jobs are stopped; then, you can bring them to the foreground one at a time (with `fg %1′ and so on) and exit each normally.You can also type

% kill %3

to kill job number 3, which will cause it to exit prematurely.

If you get stuck or are in a hurry you can use the logout command twice in a row and you’ll be able to log out in spite of your stopped jobs. The jobs will be killed automatically by the shell. You really should clean them up yourself though.

If you have background jobs running (as opposed to stopped jobs) they will continue to run after you log out.


Login with GitHub, twitter or facebook in Meteor

Meteor comes with an authentication system , which supports login with external services like

  • Facebook (accounts-facebook)
  • Github (accounts-github)
  • Google (accouts-google)
  • Meetup (accounts-meetup)
  • Twitter (accounts-twitter)
  • Weibo (accounts-weibo)

Meteor also provides forms for login, signup, password change, and password reset. To add the accounts and login controls in your application you need to add ‘account-ui’ package in your application

Now to add login support from one of the above listed external services, you just need to run this command

Now you will see, it will guide you through the required configuration. Similarly you can add other services also. To show the login buttons on our webpage we need to add

in our html file.


Meteor: Error: Not permitted. Untrusted code may only remove documents by ID

You’re also not allowed to call remove({}) from any client side code. If your app accumulates a bunch of crufty data while you’re prototyping, you might be sad about this. Client side code and the console fall under the concept “Untrusted Code” introduced by Meteor in 0.5.8.

“Trusted Code” includes the server code and method code. The key to the solution is that you can call methods defined on the Meteor server from the client using the Meteor.callmethod. Therefore, this will work in the console

Assuming you define removeAllPosts on the server like so


Deploying Laravel on Heroku

Use Buildpack

Download Heroku client tool

Try by typing heroku in command prompt

Log into Heroku

enter your account username and password

Now neter

This buildpack also supports custom Document Roots in your application. Simply add an environment variable. If your document root is public in the root of your repo, then run

Composer Warning: openssl extension is missing

While installing Laravel via composer on Wamp server I got this error

You must enable the openssl extension to download files via https

To resolve this issue, go to

c:/wamp/bin/php/{your php version} and open php.ini file. Uncomment the line by removing the semi colon in front of it


restart all service, it should work. Remember do not edit php.ini file from Wamp UI because it edits apache’s php.ini file.


How to check if jQuery is loaded and what version?

To check if the Jquery is loaded or not and version of the loaded Jquery, use following code snippet( found it on stackoverflow)


Laravel Migration : add column to existing table

To add a new column to an existing table after specific column user ‘after’  using Schema builder in Laravel 4


Removing – LF will be replaced by CRLF in git

In Unix systems the end of a line is represented with a line feed (LF). In windows a line is represented with a carriage return (CR) and a line feed (LF) thus (CRLF). when you get code from git that was uploaded from a unix system they will only have a LF. It’s nothing to worry about.

— (stackoverflow)

To deactivate this use following command



Invalid command ‘RewriteEngine’, perhaps misspelled or defined by a module not included in the server configuration

Apache shows this error message when you don’t have mod_rewrite enabled. To enable it follow below steps

1. cd to apache2 (usually in cd /etc/apache2 )

2. enter this command – sudo a2enmod rewrite

3. now restart the apache service – sudo service apache2 restart

That’s it !


Ubuntu – Brightness is reset to Maximum on every Restart

I need to manually reset the brightness setting on each restart on my Ubuntu desktop, I found following solution mentioned on stackoverflow.

To see the current settings,

then I modified the code in /etc/rc.local

——- BEGIN FILE —————————–

——- END FILE —————————–

Ref –


PhpMyadmin is not working after installation on Ubuntu

I have installed Phpmyadmin on  my Ubuntu Server, but while accessing it I am getting

The requested URL /phpmyadmin was not found on this server.

Error message, I have found following solution which worked for me.

  1. Add the following line to the end of of file /etc/apache2/apache2.conf:
  2. to add this line enter this command  sudo nano /etc/apache2/apache2.conf
  3. Include /etc/phpmyadmin/apache.conf

  4. Restart Apache by giving this command on the command line:sudo /etc/init.d/apache2 restart

(As an alternative to step 2, you can command



How to enable mod_rewrite in Apache?

To enable it the rewrite module, run “apache2 enable module rewrite”:

You need to restart the webserver to apply the changes:

If you plan on using mod_rewrite in .htaccess files, you also need to enable the use of .htaccess files by changing AllowOverride None to AllowOverride FileInfo. For the default website, edit/etc/apache2/sites-available/default:


After such a change, you need to restart Apache again.


Ubuntu – deb command-not-found

While installing New Relic‘s server monitoring on my Ubuntu server. After entering following command given at New Relics installtion instrcutions

I was getting this this error “deb command no found”, after searching for solution on internet I found following answer

Deb is not a command. You need to edit your /etc/apt/sources.list file and add the line

to the end of the file.

Get the text of selected option in JQuery

To get the text of selected option of a dropdown in Jquery,

For example following is the dropdown containing  cities

to get the text of the selected option, in JQuery


Installing meteor

According to Meteor documentation, you can easily install it by using following command in your terminal

$ curl | /bin/sh

To create a Meteor application simply run

$ meteor create myapp

To run your application

$ cd myapp $ meteor Running on: http://localhost:3000/

Now you can view your application at


Laravel artisan commands

A quick refrence for Laravel artisan commands for database migration

Create a migration

Create a migration with table name

To run the migration

To rollback last migration

To rollback all migrations

Rollback all migrations and run them again

 Database seeding




CodeIgniter – accessing $config variable

To access the variables defined in the applocation/config/config.php in the other places in your application,

for example I have declared on config item called ‘api_key’  in our config file

to access this in your controller or views


Convert latitude and longitude from decimal to Deg and vice versa in Jquery

Following code snippet will convert decimal latitude and longitude into degree, min and sec

To convert a latitude and longitude in degree min sec to decimal


Laravel : Install laravel 4 on a shared host

I have been trying to figure out to install Laravel 4 on a shared hosting, but there was not enough information available for this, so I talked with people in Laravel IRC and install the Laravel 4 on a shared hosting by only exposing public content and hiding application files.

Normally on Linux shared hosting we have following directory structure


|- accesss-logs

|- etc

|- public_ftp

|- public_html

|- www

Whatever we save under public_html folder becomes available for world. In the Laravel documentation it has been mentioned that we should upload application files outside public folder.

Note: Laravel is designed to protect your application code, and local storage by placing only files that are necessarily public in the public folder. It is recommended that you either set the public folder as your site’s documentRoot (also known as a web root) or to place the contents of public into your site’s root directory and place all of Laravel’s other files outside the web root.

So, now cut paste all the contents of public folder in the root of your application, If you are working on Xampp your path will be

Now we need to upload all these files on server, for this create a folder

say your folder name is “your-application”, after this upload app, bootstrap, packages, vendor in this directory. Now upload all remaining files in

So far so good, the only remaining task is to change the paths, open index.php files under


We need to change the path in one more file to configure public folder path. Now open a file in


Since, we have pasted all our files in public folder in this directory, we are mentioning this path to locate public files of our application.

that’s it, now open this in your browser and you will see the default welcome page.

Remove index.php from Codeigniter url

To remove “index.php” from codeigniter url

Open application/config/config.php file and look for following section in the file

Remove the index.php and save the file

Now create an .htaccess file and paste  following lines

Save this file into root directory of your project, after creating this file restart your web server.

Set,Read & Delete Cookie in Jquery

Recently in one of my project, I happened to use Cookie in Jquery. So, I though it would helpful for future references and to others also.

To set, read and delete cookie in Jquery I found this plugin very useful, you can download this from here,

First include this plugin on your page by

To set a cookie

first parameter is the name of the cookie, which we will use further to read / delete, second parameter is the value for this cookie.

If we want a cookie to get expire after a time interval, we do this by setting time limit

Now this cookie will get expired after 5 days.

To read a cookie’s value, just pass the cookie name

To delete a cookie

Redirect website to https from cpanel or htaccess file or php

If you want to redirect using htaccess, add following lines in the htacess files

We can also redirect  using php code in out header file

To redirect from cPanel,

Log into your websites control panel, then go to “Domains” section. Click on “Redirects” option

– Select type “Permanent (301)” from dropdown menu

– Select domain name which you want to redirect

– And finally enter the url to which you want the above select domain redirect to




Open link in new tab using jquery

To open a link in new tab, using Jquery, use and pass the url


PHP Date format

This is my list of useful date formats in PHP for my own reference, I update it whenever I come across to new ones, so that I don’t need to search for it on web.

To get the Day of a date

To get a date in this format

22 April 2013

To get, Jul 18

Adding no of days to a PHP date, In this example we are adding 2 days to a PHP date







Useful git resources

List of useful git resources, that I have come across.

37 single’s

Git refcard on DZone
Git – the simple guide

Git reference

Getting started about version control

Git in 15 minutes

Add other useful resources known to you in the comment below 🙂


Install FriendsApp on Ubuntu 12.10 & 13.04

To install FriendsApp on Ubuntu 12.10, follow these commands

It is much easier to install on Ubuntu 13.04, just use this one line command


Get current page title, url and meta description using JQuery

To get the title of current page, there is a one line of JQuery code

To read the meta description of current, use following code

To get the url of current page


Install Phpmyadmin on Ubuntu

phpMyAdmin is a free and open source tool written in PHP intended to handle the administration of MySQL with the use of a web browser. It can perform various tasks such as creating, modifying or deleting databasestablesfields or rows; executing SQL statements; or managing users and permissions. (from Wikipedia)

To install Phpmyadmin, execute following command in your terminal

sudo apt-get install phpmyadmin

To see it working open your browser and type



Install MySQL Workbench 5.2.44 from PPA

MySQL Workbench enables a DBA, developer, or data architect to visually design, model, generate, and manage databases. It includes everything a data modeler needs for creating complex ER models, forward and reverse engineering, and also delivers key features for performing difficult change management and documentation tasks that normally require much time and effort.

We will see how to install MySQL Workbench 5.2.44 from PPA using Olivier Berten’s PPA which is supported by the following distributions:

  • Ubuntu 12.10/12.04
  • Linux Mint 14/13

To install MySql Workbench, issue following commands

sudo add-apt-repository ppa:olivier-berten/misc

sudo apt-get update

sudo apt-get install mysql-workbench


LAN messenger for Ubuntu

When I shifted from Windows to Ubuntu, I was looking for a lightweight messenger. On Windows I was using IP Messenger, and was quit happy with it. After failed to install ip messenger available for Ubuntu, I settled for iptux.

Here is simple command to install iptux,

sudo apt-get install iptux

Here is the screenshot

iptux messenger