Monthly Archives: January 2016

How to do authorization in laravel 5.2?

Its very simple and can be done very easily.
In this tutorial we will look into followings:
How to define Abilities?
How to check Abilities?

  • Via The Gate Facade
  • Via The User Model
  • Within Blade Templates
  • Within Form Requests

What are policies?

How to check abilities/policies in Controller?

Before going to start tutorial just create Place Controller and Place model

php artisan make:controller PlaceController
php artisan make:model Place

How to define Abilities?
Ability means what user can do, operations permitted by user.
You can define abilities in your AuthServiceProvider boot method as below:
Continue reading How to do authorization in laravel 5.2?

How to recover mysql root password

If you are using linux then you can do this very easily
I have not done this on windows machine
First of all get path of mysqld
run following command


And it will output like this
Remember path can be changed
now stop mysql server using following command

sudo service mysql stop

now start mysql with option –skip-grant-tables, –skip-networking as below

sudo /usr/sbin/mysqld --skip-grant-tables  --skip-networking &

Now open new terminal
and run following commands

sudo mysql
SET PASSWORD FOR 'root'@'localhost' = PASSWORD('MyNewPass');


How to create virtual host using ubuntu/nginx

Create server block file named tutorials.local under path
and put following contents:

server {
        root /var/www/html/tutorials;
        server_name tutorials.local;
        index index.html index.htm index.php;
        charset utf-8;
    location / {
        try_files $uri $uri/ /index.php$is_args$args;
        location = /favicon.ico { access_log off; log_not_found off; }
        location = /robots.txt { access_log off; log_not_found off; }

   access_log off;

   sendfile off;

  client_max_body_size 100m;

 location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_index index.php;
        include fastcgi_params;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param REQUEST_SCHEME $scheme;
        fastcgi_intercept_errors off;
        fastcgi_buffer_size 16k;
        fastcgi_buffers 4 16k;

    location ~ /\.ht {
        deny all;

now run following command in terminal

sudo ln -s /etc/nginx/sites-available/tutorials.local /etc/nginx/sites-enabled/

Now restart nginx

sudo service nginx restart
Create hosts entry
sudo vi /etc/hosts

and add following at the end of file tutorials.local

How to change git url

I was searching about how to change url for git repo.
Then i came to a stackoverflow post
Its pretty easy to change url with only one command:

git remote set-url origin newurl

And thats it, you can verify newly set url by entering following command:

git remote show origin

How to upload file from local to remote machine or vise versa

How to upload file from local to remote machine??

By using following command we can upload file from local machine to remote machine using terminal.

scp username@remote.machine:/destination-derectory

This will use port 22 by default. But if you have to specify custom port then you can use following command.

scp -P 2000 username@remote.machine:/destination-derectory

By using following command we can download file from remote machine to local machine using terminal.

scp -P 22 user@remoteMachineAddressORIP:/fileDestinatio LocalMachineFolderPAth