Skip to content

Instantly share code, notes, and snippets.

View hanhpv's full-sized avatar

Hans Phung hanhpv

View GitHub Profile
hanhpv / .gitignore
Created April 20, 2019 05:54
Magento 2 .gitignore
hanhpv /
Last active May 24, 2017 03:03
git ignore globally

Set up your global core.excludesfile configuration file to point to this global ignore file.

git config --global core.excludesfile '~/.gitignore_global'

hanhpv /
Created April 11, 2017 15:46
Remove default Mac OS apache2

To stop the built-in Apache server in Mac OS X, use this command:

sudo apachectl -k stop

Then just enter your administrator password. And to prevent Apache from coming up again on if your system reboots/restarts just run this launchctl unload command; you’ll need your administrator password again:

sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

When that’s all done, check the output of sudo lsof -i:80 and the built-in Apache web server in Mac OS X should be completely stopped and disabled.

hanhpv /
Created March 27, 2017 03:05
How to login to sever using SSH key
  1. SSH Key

If you don’t (yet) have a SSH-key on your local workstation you need to create one. A SSH-key provides a safe way to connect with another computer. It exists of two parts: a private and a public key. The private key is stored on your local workstation, and the public key is put on the machine you wish to connect with. To create a SSH-key on your local workstation you must enter the following command:

$ ssh-keygen -t rsa -C ''
$ ssh-keygen -t rsa -C ''
Of course you fill in your own e-mail address here. A couple of questions are asked like where to store the key and which password you want to use.
With the next command you can read your public key (and copy/paste it to your clipboard):
hanhpv /
Created January 23, 2017 09:20
Magento 2 Nginx configuration on Mac (installed using Homebrew)

In /usr/local/etc/nginx/sites-enabled/magento2.conf:

server {
	listen 80;

	server_name magento2.local;
	set $MAGE_ROOT /Users/admin/htdocs/magento2;
	include /usr/local/etc/nginx/snippets/magento2.conf;
hanhpv / gist:85f6d64f2b934687802e21bf721af965
Created December 27, 2016 10:11
Fix Mysql error The user specified as a definer ... does not exist
sed -i -e 's/DEFINER=`root`@`10.%`/DEFINER=CURRENT_USER/g' filename.sql
hanhpv / varnish.params
Created November 29, 2016 04:03
Varnish config
# Varnish environment configuration description. This was derived from
# the old style sysconfig/defaults settings
# Set this to 1 to make systemd reload try to switch vcl without restart.
# Main configuration file. You probably want to change it.
# Default address and port to bind to. Blank address means all IPv4
hanhpv / xdebug.ini
Last active September 16, 2016 06:04
XDebug configuration
hanhpv /
Created September 15, 2016 07:55
Magento 1 nginx configuration
server { 
	listen 80; 
	root /Users/admin/htdocs/vax-uk;
	index index.php index.html index.htm;
	server_name vax.local; 
	access_log /usr/local/etc/nginx/logs/vax_access.log;
	access_log /usr/local/etc/nginx/logs/vax_error.log;
hanhpv / osx-nginx-phpfpm-mysql-aliases
Last active September 15, 2016 08:46
OSX nginx, php-fpm, mysql command aliases
# Nginx
alias nginx.start='sudo launchctl load /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.stop='sudo launchctl unload /Library/LaunchDaemons/homebrew.mxcl.nginx.plist'
alias nginx.restart='nginx.stop && nginx.start'
alias php-fpm.start="launchctl load -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist"
alias php-fpm.stop="launchctl unload -w ~/Library/LaunchAgents/homebrew.mxcl.php70.plist"
alias php-fpm.restart='php-fpm.stop && php-fpm.start'