Skip to content

Instantly share code, notes, and snippets.

View tranghaviet's full-sized avatar

Hà Viết Tráng tranghaviet

View GitHub Profile
RSpec.configure do |config|
config.before(:suite) do
DatabaseCleaner.clean_with(:truncation)
end
config.before(:each) do
DatabaseCleaner.strategy = :transaction
end
config.before(:each, js: true) do

5 minutes PgAdmin4 Desktop install guide

Done on Linux (Ubuntu tested)

Virtualenv & install of Python package & its deps

cd $HOME
virtualenv --python=/usr/bin/python2.7 pgadmin4
source pgadmin4/bin/activate
@tranghaviet
tranghaviet / laravel
Created November 14, 2017 09:04 — forked from Repox/laravel
Laravel logrotate configuration (1 daily rotation, 7 days retention)
/home/laravel/app/storage/logs/laravel.log {
daily
missingok
rotate 7
maxage 7
compress
notifempty
create 755 user group
su user group
}
@tranghaviet
tranghaviet / gist:d8e7651ce0ae585254cfd90bd41615b0
Created December 17, 2017 13:30 — forked from alekpopovic/gist:ce3635c7e29596e6f65154b1785e5ef9
Installing Laravel 5.2 on Ubuntu 16.04 and Apache2
Installing Laravel 5.2 on Ubuntu 16.04 and Apache2
This post will document how I installed Laravel 5.2, on Apache2 on an Ubuntu 16.04 server. Will will also install MySQL, as we will need a database, and PHP which is required by Laravel. This will be the starting point of most of my posts, so if you’re following along from scratch…this is “scratch!”
First thing you need, of course, is the Ubuntu 16.04 server, with an SSH connection. Follow these excellent instructions and get yourself sorted out with one. Make sure you also give the server a static IP address (step 8., in the linked instructions). Come back when you’re done.
Welcome back! Lets get started.
@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)
@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 / 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 / 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 / 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');
});