PHP CodeSniffer – Coding Standard Tool

Install PHP-Coding-Standards

> pear install PHP_CodeSniffer-2.8.1

Install WordPress-Coding-Standards

> cd /var/www/html
> git clone -b master https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards.git wpcs
> phpcs –config-set installed_paths /var/www/html/wpcs

Install Codeigniter-Coding-Standards

> git clone https://github.com/thomas-ernest/CodeIgniter-for-PHP_CodeSniffer.git
> ant

or

> ant -Dphpcs.dir=”/usr/share/php/PHP/CodeSniffer”

Check Supported standards

> phpcs -i

Uninstall PHP-Coding-Standards

> pear uninstall PHP_CodeSniffer-2.8.1

Check Errors and Warnings

> phpcs file.php

Autofix Errors

> phpcbf file.php

Advertisements

Install MongoDB on Ubuntu 14.04

Step 1 — Importing the Public Key

sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 7F0CEB10

Step 2 — Creating a List File

echo "deb http://repo.mongodb.org/apt/ubuntu "$(lsb_release -sc)"/mongodb-org/3.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.0.list

Step 3 – Update the packages list

sudo apt-get update

Step 4 — Installing and Verifying MongoDB

sudo apt-get install -y mongodb-org

Step 5- Check status

service mongod status

If MongoDB is running, you’ll see an output like this(with a different process ID).
mongod start/running, process 8962

Start MongoDB

service mongod start

Stop MongoDB

service mongod stop

Restart MongoDB

sudo service mongod restart

Git Notes – Basics

Initial commit

mkdir my_project
cd my_project
touch .gitignore
git init
git add .
git commit -m "Initial commit"
git remote add origin youruser@yourserver.com:/path/to/my_project.git
git push origin master

———————————————————————
Clone to local repo

git clone git@github.com:whatever folder-name
git add .
git commit -m "Initial commit"
git push origin master

Clone a specific Git branch

git clone -b my-branch git@github.com:user/myproject.git

MySQL Export From Remote Server Through Terminal – Ubuntu

mysqldump from remote server

 mysqldump -P3306  -h192.168.20.151 -uroot -p database > /home/manager/Downloads/my.sql

mysqldump specfic table from remote server

 mysqldump -P3306  -h192.168.20.151 -uroot -p database tablename > /home/manager/Downloads/my.sql

mysqldump multiple tables from remote server

 mysqldump -P3306  -h192.168.20.151 -uroot -p database tablename1 tablename2 tablename3 > /home/manager/Downloads/my.sql

Validate xml via terminal – Ubuntu

To validate xml via terminal

install xmlstarlet or xmlint

To install xmlstarlet,
http://installion.co.uk/ubuntu/vivid/universe/x/xmlstarlet/install/index.html
or
install via ubuntu software center

> apt-get install xmlstarlet

> xmlstarlet val "test.xml"

Output:

test.xml - valid

xmlint,
http://www.linuxask.com/questions/how-to-validate-the-format-of-a-xml-file-in-linux
http://stackoverflow.com/questions/4092812/tool-to-validate-an-xsd-on-ubuntu-linux

> xmllint --noout "file.xml"