Skip to content

Instantly share code, notes, and snippets.

@khoa-le
khoa-le / gist:8e8c13fd248ed15cfb49
Created February 20, 2016 04:56
reset git status change
git checkout .
git reset --hard HEAD
git clean -fdx
git pull origin master
@khoa-le
khoa-le / gist:0af44d7266c7591f58f6
Created January 22, 2016 04:42
How to update forked repository
# Add the remote, call it "upstream":
git remote add upstream https://github.com/whoever/whatever.git
# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:
git fetch upstream
# Make sure that you're on your master branch:
@khoa-le
khoa-le / install_php7_mac_os
Last active June 30, 2016 08:15
Install php7 on Mac OS X
./buildconf
'./configure' '--prefix=/usr/local/opt/php70' '--with-config-file-path=/etc' '--with-fpm-user=www-data' '--with-fpm-group=www-data' '--enable-fpm' '--enable-opcache' '--enable-mbstring' '--enable-zip' '--enable-pcntl' '--enable-ftp' '--enable-intl' '--enable-mbstring' '--with-curl' '--with-mcrypt' '--with-iconv' '--with-pdo-mysql=/usr/local/opt/mysql' '--with-gettext=/usr' '--with-zlib=/usr' '--with-mysqli=/usr/local/bin/mysql_config' '--with-gd' '--with-xsl=/usr' '--with-openssl=/usr/local/opt/openssl' '--with-freetype-dir=/usr/local/opt/freetype' '--with-gettext=/usr/local/opt/gettext' '--with-iconv-dir=/usr' '--with-jpeg-dir=/usr/local/opt/jpeg' '--with-kerberos=/usr' '--with-libedit' '--with-mhash' '--with-ndbm=/usr'
make && make install
@khoa-le
khoa-le / gist:78e3808d7faf098c5ab4
Last active January 2, 2016 14:24
Log In Restart docker instance and rebuild translation cache

cd /var/docker ./launcher ssh app

Inside the container:

sudo su - discourse cd /var/www/discourse RAILS_ENV=production bundle exec rake assets:clobber assets:precompile

Exit the container with exit twice.

@khoa-le
khoa-le / deploy.bash
Created December 16, 2015 08:09
Get file to deploy in Git repository
//Get change files
git archive --format zip -o /Users/khoalengoc/Data/dashboard.zip --prefix html_dashboard/ HEAD $(git diff --diff-filter=AM --name-only e8ea70d89e0225189243c929667d814c4365bf23 779de7332039ffacb605f16c56f94ab65dd8fde3)
//Get deleted files
git diff --diff-filter=D --name-only 9e6dda0f02bddcf56e135929820c52145a28111a 9adc36f930d0075e3484b8772f7148dc08abddba > /Users/khoalengoc/Data/detele.txt
@khoa-le
khoa-le / gist:0a11f8e20fa57d1ddee1
Last active July 11, 2016 04:10
Who is listening on a given TCP port on Mac OS X?
lsof -iTCP -i :port #To show all networking related to a given port:
lsof -i :22
lsof [email protected]
lsof -i| grep LISTEN
lsof -u daniel #username
lsof -p 10075 #pid
lsof +D /dir/ect/ory
lsof +d /dir/ect/ory #more simple view
lsof /file/name
//Generate Entity from exist database
php app/console doctrine:mapping:import --force LmkUserBundle annotation --filter=User
@khoa-le
khoa-le / git_undo_changes.bash
Last active February 20, 2021 22:38
Git undo all uncommitted changes
This will unstage all files you might have staged with git add:
git reset
This will revert all local uncommitted changes (should be executed in repo root):
git checkout .
You can also revert uncommitted changes only to particular file or directory:
git checkout [some_dir|file.txt]
Yet another way to revert all uncommitted changes (longer to type, but works from any subdirectory):
@khoa-le
khoa-le / ufw.sh
Last active November 17, 2015 10:20
Ufw config linux sercurity
//disable all incoming request
sudo ufw default deny incoming
//allow all outgoing request
sudo ufw default allow outgoing
//allow ssh
sudo ufw allow ssh
//or
sudo ufw allow 22/tcp
//allow http
php app/console doctrine:mapping:import --force LmkWebBundle annotation --filter=Post