Skip to content

Instantly share code, notes, and snippets.

View phamngsinh's full-sized avatar

Pham Ng Sinh phamngsinh

View GitHub Profile
@phamngsinh
phamngsinh / golang tuts
Last active November 1, 2015 15:53 — forked from honkskillet/byte-sizetuts.md
A series of golang tutorials with youtube videos.
# byte-size tuts
by alexander white ©
## golang tutorials
- [0 - installation on a Mac](https://gist.github.com/honkskillet/bd1f72223dd8e06b5ce6#golang-0---installation-on-a-mac)
- [1 - packages](https://gist.github.com/honkskillet/bd1f72223dd8e06b5ce6#golang-1---packages)
- [2 - remote packages](https://gist.github.com/honkskillet/bd1f72223dd8e06b5ce6#golang-2---remote-packages)
- [3 - variable syntax](https://gist.github.com/honkskillet/bd1f72223dd8e06b5ce6#golang-3---variable-syntax)
- [4 - functions syntax](https://gist.github.com/honkskillet/bd1f72223dd8e06b5ce6#golang-4---functions-syntax)
- [5 - loops syntax](https://gist.github.com/honkskillet/bd1f72223dd8e06b5ce6#golang-5---loops-syntax)
@phamngsinh
phamngsinh / permissions-www
Created May 21, 2016 13:45
Correct permissions for /var/www
First, you should ensure that your username is included in www-data group. If not, you can add your username as www-data group
sudo adduser $USER www-data
After that, you should change the ownership of /var/www to your username
sudo chown $USER:www-data -R /var/www
@phamngsinh
phamngsinh / Pretty URLs Laravel
Last active May 23, 2016 03:32
Pretty URLs Laravel
.htaccess
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
apache2.conf //httpd.conf
@phamngsinh
phamngsinh / Key is already in use
Created May 24, 2016 04:16
Key is already in use
I know this problem. After add ssh key, add you ssh key to ssh agent too (from oficial docs https://help.github.com/articles/generating-ssh-keys/)
ssh-agent -s
ssh-add ~/.ssh/id_rsa
@phamngsinh
phamngsinh / Search all of Git history for a string
Last active June 2, 2016 11:45
Search all of Git history for a string?
git rev-list --all | (
while read revision; do
git grep -F 'password' $revision
done
)
====
git rev-list --all | GIT_PAGER=cat xargs git grep 'search_string'
@phamngsinh
phamngsinh / sudo-port-command-not-found
Created June 11, 2016 16:20
Mac, Linux command not found with ozhrc
if you use zsh.please add flowing string to the line 'export PATH="..."' in file '~/.zshrc'
:/opt/local/bin:/opt/local/sbin
@phamngsinh
phamngsinh / validate.datetime.
Created June 13, 2016 09:54
Laravel, PHP Validate Datetime
$time = null;
if($timestamps instanceof DateTime){
$time = new \Carbon\Carbon($timestamps);
}
if($timestamps instanceof \Carbon\Carbon){
$time = $timestamps;
}
if (is_integer($timestamps) && strtotime(date($format, $timestamps)) === (int)$timestamps) {
$dateTime = date($format, $timestamps);
$time = new \Carbon\Carbon($dateTime);
@phamngsinh
phamngsinh / run_and_start_all_docker
Created June 17, 2016 08:42
run and start all docker
docker stop $(docker ps -a -q)
docker rm $(docker ps -a -q)
@phamngsinh
phamngsinh / Get lastInserId in lararavel
Created June 28, 2016 10:02
Get lastInserId in lararavel
$deleteId = DB::getPdo()->lastInsertId();
OR
$id = DB::table('table')->insertGetId( $data );
/***
*
* smagic39.blogspot.com
@phamngsinh
phamngsinh / Mate Desktop for ubuntu
Created June 29, 2016 02:35
Mate Desktop for ubuntu
The Mate Desktop started as GNOME 2 fork back in 2011, when the Linux systems adopted GNOME 3. Today, MATE is available by default on Fedora, Arch Linux, Linux Mint and BSD (and forks of this systems).
Mate Desktop 1.12.1 has been recently released, bringing mostly bug-fixes.
Installation instructions:
The latest versions of Mate desktop are available via the Ubuntu MATE PPAs, so installing it on Ubuntu 15.10 Wily Werewolf and Ubuntu 16.04 Xenial Xerus should not be too difficult.
Just add the PPA to your system, update the local repository index and upgrade all the packages and install the mate-dock-applet package. Follow the instructions for your system exactly.