Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Tsai yidas

View GitHub Profile
@yidas
yidas / nginx-config-guide.md
Last active Nov 16, 2021
[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 / js-nl2br-br2nl.md
Last active Nov 16, 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 / codeiginter-server-config.md
Last active Nov 11, 2021
Codeigniter 3 server configuration for Nginx & Apache
View codeiginter-server-config.md

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 / js-encode-decode.md
Last active Nov 11, 2021
JavaScript HTML Entities Encode & Decode
View js-encode-decode.md
@yidas
yidas / csr.conf.md
Last active Nov 2, 2021
Certificate(CSR) configuration file
View csr.conf.md

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 / composer-install-vcs.md
Last active Oct 17, 2021
Composer install package via VCS such as GitLab (Private package requirement)
View composer-install-vcs.md

Composer install package via VCS such as GitLab

(Private package requirement)

1. Create composer.json:

{
    "repositories": [                                             
        {                                                         
            "type": "vcs",                                        
@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 / 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 / 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 / yii2-server-config.md
Last active Aug 6, 2021
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: