Skip to content

Instantly share code, notes, and snippets.

View phamngsinh's full-sized avatar

Pham Ng Sinh phamngsinh

View GitHub Profile
@phamngsinh
phamngsinh / gitcheckout.md
Created October 2, 2016 14:42
how to check out a remote git branch

actually improves on this. With Git versions ≥ 1.6.6, you can just do:

git fetch git checkout test (User masukomi points out below that git checkout test will NOT work in modern git if you have multiple remotes. In this case use git checkout -b test remote-name/test)

======old version=====

Before you can start working locally on a remote branch, you need to fetch it as called out in answers below.

@phamngsinh
phamngsinh / create-user.md
Last active October 2, 2016 14:40
Create new user in MySQL and give it full access to one database

To create user in MySQL/MariaDB 5.7.6 and higher, use CREATE USER syntax:

CREATE USER 'new_user'@'localhost' IDENTIFIED BY 'new_password'; then to grant all access to the database (e.g. my_db), use GRANT Syntax, e.g.

GRANT ALL ON my_db.* TO 'new_user'@'localhost'; Where ALL (priv_type) can be replaced with specific privilege such as SELECT, INSERT, UPDATE, ALTER, etc.

Then to reload newly assigned permissions run:

@phamngsinh
phamngsinh / enabling.txt
Created October 2, 2016 06:32
apache2 - enabling and disabling sites
# enable site
sudo a2ensite
# disable site
sudo a2dissite
# enable an apache2 module
sudo a2enmod
# e.g. a2enmod php4 will create the correct symlinks in mods-enabled to allow the module to be used. In this example it will link both php4.conf and php4.load for the user
@phamngsinh
phamngsinh / grep.text
Created September 27, 2016 10:37
find all files containing specific text on Linux
grep -rnw '/path/to/somewhere/' -e "pattern"
-r or -R is recursive,
-n is line number, and
-w stands match the whole word.
-l (lower-case L) can be added to just give the file name of matching files.
Along with these, --exclude or --include parameter could be used for efficient searching. Something like below:
grep --include=\*.{c,h} -rnw '/path/to/somewhere/' -e "pattern"
This will only search through the files which have .c or .h extensions. Similarly a sample use of --exclude:
grep --exclude=*.o -rnw '/path/to/somewhere/' -e "pattern"
@phamngsinh
phamngsinh / symfony-ubuntu.txt
Last active January 16, 2018 11:06
install symfony on ubuntu linux step by step
1.Update souces list.
apt-get update and apt-get upgrade for new packages.
2.Installing Pear on you machine.
sudo apt-get install php-pear
3.Installation starts for Symfony
@phamngsinh
phamngsinh / host.txt
Created September 10, 2016 04:40
Multiple Sites on a Single Amazon EC2 Instance
<VirtualHost *:80>
ServerAdmin webmaster@yourdomain.com
DocumentRoot "/var/www/html/website1_folder"
ServerName yourdomain.com
ErrorLog "logs/yourdomain.com-error_log"
CustomLog "logs/yourdomain.com-access_log" common
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@yourdomain.com
@phamngsinh
phamngsinh / aws-certification.md
Created September 7, 2016 16:37 — forked from miglen/aws-certification.md
AWS Certification guide and notes on how to prepare for the aws associate certification architect, sysops and developer exams

AWS Certification notes

Those are my personal notes on AWS Solution Architect certification preparation. Hope you find them usefull.

To pass AWS certification, you should have:

  • Sound knowledge about most of the AWS services ( EC2, VPC, RDS, Cloudfront, S3, Route53 etc,)
  • Hands on experience with AWS services.
  • Good knowledge of disaster recovery, security and High availability architectures.

If you do not have prior hands-on experience and knowledge or you have little knowledge about AWS services, it is better to take an online course. If you already have experience in architecting solutions on AWS it is not necessary to take an online course.

@phamngsinh
phamngsinh / phpold.txt
Created September 6, 2016 08:06
Multi Php Version in Ubuntu 16
Install PHP 5.4
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php5-oldstable
$ sudo apt-get update
$ sudo apt-get install -y php5
Install PHP 5.5
$ sudo apt-get install python-software-properties
$ sudo add-apt-repository ppa:ondrej/php
@phamngsinh
phamngsinh / php5.6
Created August 23, 2016 03:51
Install php 5.6 on Ubuntu 16.04
sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt install php5.6 libapache2-mod-php5.6 php5.6-curl php5.6-gd php5.6-mbstring php5.6-mcrypt php5.6-mysql php5.6-xml php5.6-xmlrpc
sudo a2dismod php7.0
sudo a2enmod php5.6
sudo systemctl restart apache2
@phamngsinh
phamngsinh / xhprof
Created August 21, 2016 10:38
MAMP with XHProf
MAMP doesn't come with XHProf support by default and sometimes we need more than just a simple debug tool with Xdebug.
Just for the record, I'm posting this in the current version of MAMP, that is 2.1.1 and in the Mountain Lion OSX 10.8.1 version. I'm not sure if it works the same way on other versions, but you can leave a comment about it :)
So, how can we enable it and make it work?
Requirements
First of all you'll need Xcode and Command Line Tools. Download and install them.