Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Tsai yidas

View GitHub Profile
@yidas
yidas / mysql-change-datadir.md
Created Jul 11, 2018
MySQL change data-dir for Ubuntu 16.04
View mysql-change-datadir.md

MySQL change data-dir for Ubuntu 16.04

1. Change mysql.cnf

/etc/mysql/mysql.conf.d/mysql.cnf:

set datadir = /home/mysql
@yidas
yidas / mysql-change-sqlmode.md
Last active Jul 12, 2018
[MySQL] Permanently change SQL Mode in MySQL (disable_strict_mode)
View mysql-change-sqlmode.md

[MySQL] Permanently change SQL Mode in MySQL (disable_strict_mode)

Set into [mysqld] of MySQL config, for Ubuntu your could create a file /etc/mysql/conf.d/disable_strict_mode.cnf:

[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION

SQL mode example: STRICT_TRANS_TABLES,ERROR_FOR_DIVISION_BY_ZERO,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION

@yidas
yidas / yii2-actionError.md
Last active Aug 1, 2018
[Yii2] Yii2 sample code of Error Action handling such 404 errors
View yii2-actionError.md

[Yii2] Yii2 sample code of Error Action handling such 404 errors

/**
 * Error action
 *
 * @return void
 */
public function actionError()
{
@yidas
yidas / nginx-config-guide.md
Last active Jan 12, 2022
[Nginx] Nginx Configuration Guide & Samples (Subdirectory with PHP)
View nginx-config-guide.md

Nginx Configuration Guide & Samples

Subdirectory using Alias

root /var/www/html;

location /site2/ {
    
    alias /srv/www/project2/;
@yidas
yidas / openssl-dhparam.md
Last active Jan 15, 2019
[OpenSSL] Diffie–Hellman (DH) key exchange with at least 2048 bits
View openssl-dhparam.md
@yidas
yidas / laravel-server-config.md
Last active Nov 17, 2019
Laravel Server Configuration for Nginx & Apache (Subdirectory)
View laravel-server-config.md

Laravel Server Configuration for Nginx & Apache (Subdirectory)

It's easy to configurate a Laravel server site with directory protection:

Laravel Web Server Configuration

Sub Directory Site Application

Laravel smartly detects the current base url so that you don't need to set the base url for subdirectoy:

@yidas
yidas / yii2-server-config.md
Last active Aug 6, 2021
Yii2 Server Configuration for Nginx & Apache (Subdirectory)
View yii2-server-config.md

Yii2 Server Configuration for Nginx & Apache (Subdirectory)

It's easy to configurate a Yii2 server site with directory protection:

Yii2 Web Server Configuration

Sub Directory Site Application

With using Sub Directory for Yii2, you could set sub-directory path into yii2's config:

@yidas
yidas / PHP-DateTime-shiftMonths.md
Last active Nov 26, 2018
Shift a giving months from your input datetime with month based
View PHP-DateTime-shiftMonths.md

Shift a giving months from your input datetime with month based

If the target month is smaller than the original month, the extra days will be discarded.

/**
 * Shift a giving months from your input datetime with month based
 * 
 * If the target month is smaller than the original month, the extra days will be discarded.
 * 
@yidas
yidas / sql-joins-diagram.md
Last active Dec 18, 2018
SQL Joins Explained Diagram
View sql-joins-diagram.md
@yidas
yidas / js-nl2br-br2nl.md
Last active Jan 7, 2022
JavaScript nl2br & br2nl functions
View js-nl2br-br2nl.md

JavaScript nl2br & br2nl functions

The exchange of new line & br HTML tag could refer to PHP - nl2br() function, which uses to inserts HTML line breaks before all newlines in a string.

These JavaScript functions consider whether to use insert or replace to handle the swap.

nl2br