Skip to content

Instantly share code, notes, and snippets.

View yidas's full-sized avatar

Nick Tsai yidas

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

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 January 31, 2023 14:22
[MySQL] Permanently change SQL Mode in MySQL (disable_strict_mode)

[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 August 1, 2018 05:36
[Yii2] Yii2 sample code of Error Action handling such 404 errors

[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 January 12, 2022 07:10
[Nginx] Nginx Configuration Guide & Samples (Subdirectory with PHP)

Nginx Configuration Guide & Samples

Subdirectory using Alias

root /var/www/html;

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

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 August 6, 2021 14:50
Yii2 Server Configuration for Nginx & Apache (Subdirectory)

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 November 26, 2018 02:52
Shift a giving months from your input datetime with month based

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 December 18, 2018 01:53
SQL Joins Explained Diagram
@yidas
yidas / js-nl2br-br2nl.md
Last active September 29, 2023 05:26
JavaScript nl2br & br2nl functions

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