Skip to content

Instantly share code, notes, and snippets.

Nick Tsai yidas

Block or report user

Report or block yidas

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@yidas
yidas / yii2-app-basic-env-switch.md
Created Jan 3, 2019
Yii2 App Basic Environment Setting Switch for WEB & Console
View yii2-app-basic-env-switch.md

Yii2 App Basic Environment Setting Switch for WEB & Console

Server Variable Solution

Add server variable condition for ./web/index.php & ./yii:

if (isset($_SERVER['APP_ENV']) && $_SERVER['APP_ENV']=='production') {
@yidas
yidas / js-encode-decode.md
Last active Dec 21, 2018
JavaScript HTML Entities Encode & Decode
View js-encode-decode.md
@yidas
yidas / js-nl2br-br2nl.md
Last active Apr 18, 2019
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

@yidas
yidas / sql-joins-diagram.md
Last active Dec 18, 2018
SQL Joins Explained Diagram
View sql-joins-diagram.md
@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 May 5, 2019
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 Aug 31, 2018
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 Aug 24, 2018
[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()
{
You can’t perform that action at this time.