Skip to content

Instantly share code, notes, and snippets.

View yidas's full-sized avatar

Nick Tsai yidas

View GitHub Profile
@ikhsanalatsary
ikhsanalatsary / setup_cmder_wsl.md
Last active January 17, 2024 16:31
Setup cmder with WSL 2

Using WSL 2

  1. Open cmder
  2. On the menu, open Settings option and then select Startup > Tasks from the menu tree (or just hit Win + Alt + T)
  3. Click the “+” button to add a new task and fill in the fields as follow:
  4. Name: {zsh::home}
  5. Task Parameters:
    /icon "%CMDER_ROOT%\icons\cmder.ico"
    
@yidas
yidas / js-encode-decode.md
Last active April 6, 2022 15:26
JavaScript HTML Entities Encode & Decode
@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

@AveYo
AveYo / .. MediaCreationTool.bat ..md
Last active April 26, 2024 17:20
Universal MediaCreationTool wrapper for all MCT Windows 10 versions - MOVED TO github.com/AveYo/MediaCreationTool.bat
@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 / 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 / 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 / yii2-migrate-by-web-controller.md
Last active July 6, 2018 07:29
Yii2 Migrate command called by Web controller
public function actionMigrate()
{
    // Keep current application
    $oldApp = \Yii::$app;
    // Load Console Application config
    $config = require \Yii::getAlias('@app'). '/config/console.php';
    new \yii\console\Application($config);
    $result = \Yii::$app->runAction('migrate', ['migrationPath' => '@app/migrations/', 'interactive' => false]);
 // Revert application
$ php some-bench.php
strtotime: 0.15609812736511
datetime: 0.31521701812744
datetime without instanciation: 0.11794400215149
custom: 0.70522284507751
@rkuzsma
rkuzsma / docker-bash-completion.md
Last active November 18, 2023 09:11
How to configure Bash Completion on Mac for Docker and Docker-Compose

How to configure Bash Completion on Mac for Docker and Docker-Compose

Copied from the official Docker-for-mac documentation (thanks Brett for the updated doc pointer):

Install shell completion

Docker Desktop for Mac comes with scripts to enable completion for the docker, docker-machine, and docker-compose commands. The completion scripts may be found inside Docker.app, in the Contents/Resources/etc/ directory and can be installed both in Bash and Zsh.

Bash

Bash has built-in support for completion To activate completion for Docker commands, these files need to be copied or symlinked to your bash_completion.d/ directory. For example, if you installed bash via Homebrew: