Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Tsai yidas

View GitHub Profile
@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 / 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 / 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 / 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 / nginx-config-guide.md
Last active Nov 16, 2021
[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 / 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 / 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 / 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 / composer-install-vcs.md
Last active Oct 17, 2021
Composer install package via VCS such as GitLab (Private package requirement)
View composer-install-vcs.md

Composer install package via VCS such as GitLab

(Private package requirement)

1. Create composer.json:

{
    "repositories": [                                             
        {                                                         
            "type": "vcs",                                        
@yidas
yidas / nginx-80-to-443.config.md
Last active Nov 22, 2018
Ngnix 80 to 443 Configuration
View nginx-80-to-443.config.md
server {
    listen 80;
    listen [::]:80;
    server_name example.com www.example.com; 
    return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;