Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Tsai yidas

View GitHub Profile
@yidas
yidas / zip-slip-php.md
Last active Aug 7, 2021
ZIP Slip - File Generation Sample Code by PHP
View zip-slip-php.md

ZIP Slip - File Generation Sample Code by PHP

Sample Code

<?php

$zip = new ZipArchive();
$filename = "./zip-slip-test.zip";
@yidas
yidas / java-http-client-samples.md
Last active Oct 14, 2021
JAVA HTTP Client Sample codes
View java-http-client-samples.md

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
 */
@yidas
yidas / deep-link_app_examples.md
Last active Oct 30, 2020
Mobile App Deep Link Table (URL Scheme | App link | Universal link)
View deep-link_app_examples.md
@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 Sep 9, 2021
LINE Pay API (v3) sample codes in multi-languages
View line-pay-sample-codes.md
@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 Sep 27, 2021
JavaScript HTML Entities Encode & Decode
View js-encode-decode.md
@yidas
yidas / js-nl2br-br2nl.md
Last active Sep 7, 2021
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