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 / curl-timeout-error-handling.md
Last active Aug 20, 2019
CURL timeout error handling (Connection/Operation timed out)
View curl-timeout-error-handling.md

CURL timeout error handling (Connection/Operation timed out)

CURL parameter --max-time includes --connect-timeout to separate the timeout of the handshake phase.

CURL - Timeouts · Everything curl

In addition, CURL can distinguish timeout errors at different stages: "connection timeout" and "operation timeout".

For example, CURL command with 5 second connection timeout and 25 second maximum timeout setting:

@yidas
yidas / public-key-fingerprint-formula.md
Last active Aug 22, 2019
Public key's fingerprint formula
View public-key-fingerprint-formula.md

Public key's fingerprint formula

The public key file (key.pub) contains the binary key that is packaged into a base64 string.

Formula

The public key's fingerprint formula:

# SHA256
@yidas
yidas / line-pay-sample-codes.md
Last active Jul 24, 2019
LINE Pay sample code in multiple programing languages
View line-pay-sample-codes.md

PHP

HMAC:

<?php

$channelSecret = 'a917ab6a2367b536f8e5a6e2977e06f4';
$requestUri = '/v3/payments/request';
$jsonBody = json_encode([
@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:

You can’t perform that action at this time.