Skip to content

Instantly share code, notes, and snippets.

View yidas's full-sized avatar

Nick Tsai yidas

View GitHub Profile
@yidas
yidas / java-http-client-samples.md
Last active April 24, 2024 10:32
JAVA HTTP Client Sample codes

JAVA HTTP Client Sample codes

HttpURLConnection

/**
 * @see https://docs.oracle.com/javase/8/docs/api/java/net/URLConnection.html
 * @see https://docs.oracle.com/javase/8/docs/api/java/net/HttpURLConnection.html
 * @see https://www.baeldung.com/java-http-request
 * @see https://www.baeldung.com/httpurlconnection-post
@yidas
yidas / curl-timeout-error-handling.md
Last active April 24, 2024 09:57
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 / composer-install-vcs.md
Last active April 23, 2024 04:45
Composer install package via VCS such as GitLab (Private package requirement)

Composer install package via VCS such as GitLab

(Private package requirement)

1. Create composer.json:

{
    "repositories": [                                             
        {                                                         
 "type": "vcs", 
@yidas
yidas / codeiginter-server-config.md
Last active March 1, 2024 01:30
Codeigniter 3 server configuration for Nginx & Apache

Codeigniter 3 server configuration for Nginx & Apache

Web Server Site Configuration

Recommended Apache Configuration

Use the following configuration in Apache's httpd.conf file or within a virtual host configuration. Note that you should set DocumentRoot and ServerName fit to your environment:

@yidas
yidas / line-pay-sample-codes.md
Last active February 27, 2024 09:08
LINE Pay API (v3) sample codes in multi-languages
@yidas
yidas / csr.conf.md
Last active December 13, 2023 10:35
Certificate(CSR) configuration file

Openssl commands:

openssl genrsa -out self-ssl.key
openssl req -new -key self-ssl.key -out self-ssl.csr -config csr.conf
openssl x509 -req -days 365 -in self-ssl.csr -signkey self-ssl.key -out self-ssl.crt -extensions req_ext -extfile csr.conf

Sign from Root CA: openssl x509 -req -days 365 -extensions req_ext -extfile csr.conf -CA RootCA.crt -CAkey RootCA.key -in self-ssl.csr -out self-ssl.crt

@yidas
yidas / deep-link_app_examples.md
Last active November 24, 2023 23:21
Mobile App Deep Link Table (URL Scheme | App link | Universal link)
@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

@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 / 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