Skip to content

Instantly share code, notes, and snippets.

View hoai's full-sized avatar

hoai hoai

View GitHub Profile
@hoai
hoai / README.md
Created June 5, 2023 07:53 — forked from jehaby/README.md
Debug PHP in Docker with PHPStorm and Xdebug

Debug your PHP in Docker with Intellij/PHPStorm and Xdebug

  1. For your local dev, create a Dockerfile that is based on your production image and simply install xdebug into it. Exemple:
FROM php:5

RUN yes | pecl install xdebug \
    && echo "zend_extension=$(find /usr/local/lib/php/extensions/ -name xdebug.so)" > /usr/local/etc/php/conf.d/xdebug.ini \
@hoai
hoai / guide.txt
Created December 28, 2022 08:29
[Fix] There is no script engine for file extension .JS – Error
When you attempt to run a .js (JScript Script File) file, one of the following errors may occur:
Can't find script engine "JScript" for script "filename.js".
There is no script engine for file extension ".js".
There is no script engine for file extension
RELATED: [Fix] Can’t find Script Engine Vbscript, and “no script engine for .vbs”
[Fix] There is no script engine for file extension .JS
The “script engine” error occurs if the .js file association data is missing or incorrect. Follow these steps to resolve the problem:
Open an elevated Command Prompt window.
@hoai
hoai / example.com
Created December 12, 2022 07:20 — forked from 1hakr/example.com
Supercharge your NGIX config
proxy_cache_path /tmp/cacheapi levels=1:2 keys_zone=microcacheapi:100m max_size=1g inactive=1d use_temp_path=off;
server {
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
server_name example.com;
location /api/ {
# Rate Limiting
limit_req zone=reqlimit burst=20; # Max burst of request
@hoai
hoai / credit-card-regex.md
Created July 28, 2022 08:12 — forked from michaelkeevildown/credit-card-regex.md
Credit Card Regex Patterns

Credit Card Regex

  • Amex Card: ^3[47][0-9]{13}$
  • BCGlobal: ^(6541|6556)[0-9]{12}$
  • Carte Blanche Card: ^389[0-9]{11}$
  • Diners Club Card: ^3(?:0[0-5]|[68][0-9])[0-9]{11}$
  • Discover Card: ^65[4-9][0-9]{13}|64[4-9][0-9]{13}|6011[0-9]{12}|(622(?:12[6-9]|1[3-9][0-9]|[2-8][0-9][0-9]|9[01][0-9]|92[0-5])[0-9]{10})$
  • Insta Payment Card: ^63[7-9][0-9]{13}$
  • JCB Card: ^(?:2131|1800|35\d{3})\d{11}$
  • KoreanLocalCard: ^9[0-9]{15}$
@hoai
hoai / le-renew-webroot.ini
Created July 19, 2022 09:55 — forked from nunomorgadinho/le-renew-webroot.ini
Install PHP56-FPM, Nginx, MySQL on EC2 with Amazon Linux AMI and SSL with letsencrypt
# adduser nginx
adduser nginx
# Install linux update, followed by GCC and Make
sudo yum -y update
sudo yum install -y gcc make
# Install Nginx and PHP-FPM
sudo yum install -y nginx php56-fpm
@hoai
hoai / nginx-tuning.md
Created July 17, 2022 08:02 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@hoai
hoai / counter.php
Created July 13, 2022 13:21 — forked from Fysac/counter.php
Database-less, sessionless way to count online users in PHP.
<?php
$timeout = 300; // 5 minutes
$time = time();
$ip = $_SERVER["REMOTE_ADDR"];
$file = "users.txt";
$arr = file($file);
$users = 0;
for ($i = 0; $i < count($arr); $i++){
if ($time - intval(substr($arr[$i], strpos($arr[$i], " ") + 4)) > $timeout){
@hoai
hoai / Download File with Node.md
Created July 6, 2022 09:22 — forked from gkhays/Download File with Node.md
Download a file from a URL using Node.js

Download File from URL

Proof-of-concept to download a file from a URL and save it locally. For example, I may wish to retrieve a JAR file from Nexus.

Uses the http package, which does the basics with raw HTTP protocol support.

Possible update: use request, it is like the Python's requests library. There is a companion package called node-request-progress that tracks download progress. See request-progress on GitHub.

Note: The request package has been deprecated.

@hoai
hoai / How to Extract Subtitles from Video.html
Created June 28, 2022 08:44
How to Extract Subtitles from Video
How to Extract Hardcoded Subtitles from Video Online
Apart from those desktop subtitle extractors mentioned above, there are lots of online subtitle extracting software available, like Subtitlevideo.
It is an online tool to help you extract subtitles from video or generate subtitles and close captions for video in simple steps. By using this program, you will find that it is extremely easy to take captions from MP4, WebM, FLV, MPEG, MOV, and other video files with ease.
Here are the steps to separate captions from video online:
Step 1. Go to its official webpage. https://www.subtitlevideo.com
Step 2. Select the spoken language in this video, and then click "Choose file" to upload your target video file that you want to take captions from.
@hoai
hoai / multiple-keys-gitlab.md
Created April 26, 2022 13:09 — forked from dotspencer/multiple-keys-gitlab.md
Multiple Gitlab accounts with multiple ssh keys

Gitlab won't allow reuse of a public ssh key for multiple accounts. To get around this you need to create a second ssh key for the second account.

Create or modify your ~/.ssh/config file:

# normal                                                                                                                                                                  
Host gitlab.com-work_username
     HostName gitlab.com
     PreferredAuthentications publickey
 IdentityFile ~/.ssh/id_rsa