Skip to content

Instantly share code, notes, and snippets.

View tranghaviet's full-sized avatar

Hà Viết Tráng tranghaviet

View GitHub Profile
@tranghaviet
tranghaviet / bootstrap-4-sass-mixins-cheat-sheet.scss
Created October 4, 2018 11:35 — forked from anschaef/bootstrap-4-sass-mixins-cheat-sheet.scss
Bootstrap 4 Sass Mixins [Cheat sheet with examples]
/* -------------------------------------------------------------------------- */
// All Bootstrap 4 Sass Mixins [Cheat sheet]
// Updated to Bootstrap v4.1.x
// @author https://anschaef.de
// @see https://github.com/twbs/bootstrap/tree/v4-dev/scss/mixins
/* -------------------------------------------------------------------------- */
// Grid variables
$grid-columns: 12 !default;
$grid-gutter-width: 30px !default;
@tranghaviet
tranghaviet / php7-fpm_xdebug_nginx.md
Created September 29, 2018 03:44 — forked from rahilwazir/php7-fpm_xdebug_nginx.md
Quick guide to setup Nginx with PHP7-FPM and XDebug

PHP7

  • Ubuntu 16.04+
$ sudo add-apt-repository ppa:ondrej/php
$ sudo apt update
$ sudo apt install nginx php7.1-fpm php7.1-cli php7.1-common php7.1-json php7.1-opcache php7.1-mysql php7.1-phpdbg php7.1-mbstring php7.1-gd php7.1-imap php7.1-ldap php7.1-pgsql php7.1-pspell php7.1-recode php7.1-soap php7.1-tidy php7.1-dev php7.1-intl php7.1-curl php7.1-zip php7.1-xml php-xdebug
@tranghaviet
tranghaviet / config
Created September 28, 2018 04:46
.git/config for source different than origin
[remote "tranghv"]
url = git@tranghv:owner_user_name/repo.git
fetch = +refs/heads/*:refs/remotes/my_user_name/*
# it will use ssh with config as tranghv in ~/.ssh/config (e.g default config is bitbucket.org instead of tranghv)
# usage: git pull tranghv branch-name
@tranghaviet
tranghaviet / laravel.conf
Last active October 19, 2021 07:43
Nginx block config for laravel
# Permission for laravel project
# sudo chgrp -R www-data storage bootstrap/cache
# sudo chmod -R ug+rwx storage bootstrap/cache
# OR: sudo chown -R <user>:www-data storage bootstrap/cache
# Allow current user edit file
# sudo usermod -a -G www-data <username>
# sudo chmod 775 -R storage
# After created, enable this configuration
@tranghaviet
tranghaviet / vue.conf
Created September 27, 2018 04:35
Nginx config for vue js build files
server {
# port listening
listen 8090;
server_name _;
root /path/to/dist/;
index index.html;
location / {
@tranghaviet
tranghaviet / jQuery Change Event: Proper Binding
Created September 21, 2018 02:06 — forked from brandonaaskov/jQuery Change Event: Proper Binding
jQuery's change() event doesn't work as expected with input text fields. This, however, does work.
/*
For some reason, the change() event only fires when the input field loses focus.
Binding to other options ('change keypress paste focus textInput input') will
fire the event several times, which is bad. The below code works even when
content is pasted into the text field, and only fires once as expected.
*/
$('#search-form .term').bind('input', function(){
console.log('this actually works');
});
@tranghaviet
tranghaviet / gist:632ad392947b57d4b15c8d7778ac75c3
Created August 20, 2018 06:33 — forked from kamipo/gist:61ee662ee0b1127f0989
MySQL Unicode Collation Behavior

MySQL Unicode character set has following collations mainly:

  • xxx_bin: compare all characters by these code point as weight.
  • xxx_general_ci: compare almost characters by these code point as weight.
  • xxx_unicode_ci: compare all characters by these collating weight.

ref. http://dev.mysql.com/doc/refman/5.6/en/charset-unicode-sets.html

When xxx is utf8, can treat only BMP characters.

@tranghaviet
tranghaviet / README.md
Created July 15, 2018 05:43 — forked from yang-wei/README.md
ES6 destructing (and rest parameter)

We will first discussed how destructing and rest parameters can be used in ES6 - in arrays and objects. Then we will look at a few examples and also discuss some quiz.

arrays

var array = [1, 2, 3, 4];
var nestedArray = [1, 2, 3, 4, [7, 8, 9]];

var [a, b, c, d] = array;
console.log(a, b, c, d)
@tranghaviet
tranghaviet / .htaccess
Created May 29, 2018 04:13 — forked from thoop/.htaccess
Official prerender.io .htaccess for Apache.
# Change YOUR_TOKEN to your prerender token and uncomment that line if you want to cache urls and view crawl stats
# Change http://example.com (at the end of the last RewriteRule) to your website url
<IfModule mod_headers.c>
#RequestHeader set X-Prerender-Token "YOUR_TOKEN"
</IfModule>
<IfModule mod_rewrite.c>
RewriteEngine On
@tranghaviet
tranghaviet / accessing-virtualbox.md
Last active May 22, 2018 03:34
Accessing your Virtualbox Guest from your Host OS

Accessing your Virtualbox Guest from your Host OS

As a developer you want to ping and access the webserver on your virtual machine. This is a very simple solution to enable the bridge to the guest VM.

Requirements

  • VirtualBox (latest version)
  • A guest operation system (e.g. Ubuntu)