Skip to content

Instantly share code, notes, and snippets.

View yidas's full-sized avatar

Nick Tsai yidas

View GitHub Profile
@yidas
yidas / curl-timeout-error-handling.md
Last active August 20, 2019 07:27
CURL timeout error handling (Connection/Operation timed out)

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 August 22, 2019 08:54
Public key's fingerprint formula

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 / codeigniter-set-env-for-cli.md
Last active March 27, 2020 17:17
Codeigniter - Set environment when running in CLI mode

Codeigniter - Set environment when running in CLI mode

There are some ways to set environment when running in CLI mode for Codeigniter 3:

Set Var in Command Way:

$ CI_ENV="production" php index.php welcome/index
{
/*
// Place your snippets for PHP here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "log",
"body": [
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class PhotoController extends Controller
{
/**
* Display a listing of the resource.
@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 / zip-slip-php.md
Last active August 7, 2021 17:38
ZIP Slip - File Generation Sample Code by PHP

ZIP Slip - File Generation Sample Code by PHP

Sample Code

<?php

$zip = new ZipArchive();
$filename = "./zip-slip-test.zip";
@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 / js-encode-decode.md
Last active April 6, 2022 15:26
JavaScript HTML Entities Encode & Decode
@yidas
yidas / ssl_cipher.md
Last active August 26, 2022 10:41
Web Server TLS/SSL Cipher Suite Setting - Best Practice

Web Server TLS/SSL Cipher Suite Setting - Best Practice

nginx seting:

ssl_prefer_server_ciphers on;
ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-CHACHA20-POLY1305:ECDHE-ARIA256-GCM-SHA384:DHE-RSA-ARIA256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-ARIA128-GCM-SHA256:DHE-RSA-ARIA128-GCM-SHA256:DHE-RSA-AES256-CCM8:DHE-RSA-AES256-CCM:DHE-RSA-AES128-CCM8:DHE-RSA-AES128-CCM';