Skip to content

Instantly share code, notes, and snippets.

View lechidung's full-sized avatar
⛰️
Go up and never stop....

Johnny Lê lechidung

⛰️
Go up and never stop....
  • Techbase Vietnam Company Limited
  • Ho Chi Minh City, Vietnam
  • 12:01 (UTC +07:00)
View GitHub Profile
@lechidung
lechidung / Union types
Last active November 29, 2020 18:19
PHP 8
/*** PHP 7 ***/
class Number {
/** @var int|float */
private $number;
/**
* @param float|int $number
*/
public function __construct($number) {
$this->number = $number;
/*** PHP 7 ***/
class Point {
public float $x;
public float $y;
public float $z;
public function __construct(
float $x = 0.0,
float $y = 0.0,
float $z = 0.0,
@lechidung
lechidung / Attributes
Last active November 29, 2020 18:20
PHP 8
/*** PHP 7 ***/
class PostsController
{
/**
* @Route("/api/posts/{id}", methods={"GET"})
*/
public function get($id) { /* ... */ }
}
/*** PHP 8 ***/
@lechidung
lechidung / Named arguments
Last active November 29, 2020 18:20
php 8
/*** PHP 7 ***/
htmlspecialchars($string, ENT_COMPAT | ENT_HTML401, 'UTF-8', false);
/*** PHP 8 ***/
htmlspecialchars($string, double_encode: false);
@lechidung
lechidung / generate.sh
Created October 13, 2020 16:12 — forked from Tucker-Eric/generate.sh
Script to generate nginx config
SED=`which sed`
CURRENT_DIR=`dirname $0`
echo "What is the domain?"
read DOMAIN
# check the domain is valid!
PATTERN="^(([a-zA-Z]|[a-zA-Z][a-zA-Z0-9\-]*[a-zA-Z0-9])\.)*([A-Za-z]|[A-Za-z][A-Za-z0-9\-]*[A-Za-z0-9])$";
if [[ "$DOMAIN" =~ $PATTERN ]]; then
DOMAIN=`echo $DOMAIN | tr '[A-Z]' '[a-z]'`
{
"url": "https://api.github.com/gists/408324817b197e9e6c3bc239e59fa880",
"forks_url": "https://api.github.com/gists/408324817b197e9e6c3bc239e59fa880/forks",
"commits_url": "https://api.github.com/gists/408324817b197e9e6c3bc239e59fa880/commits",
"id": "408324817b197e9e6c3bc239e59fa880",
"node_id": "MDQ6R2lzdDQwODMyNDgxN2IxOTdlOWU2YzNiYzIzOWU1OWZhODgw",
"git_pull_url": "https://gist.github.com/408324817b197e9e6c3bc239e59fa880.git",
"git_push_url": "https://gist.github.com/408324817b197e9e6c3bc239e59fa880.git",
"html_url": "https://gist.github.com/408324817b197e9e6c3bc239e59fa880",
"files": {
@lechidung
lechidung / sample-nginx-proxy-docker.conf
Last active April 24, 2020 17:31
sample nginx with SSL proxy docker
server {
listen [::]:443 ssl ipv6only=on;
listen 443 ssl;
server_name builder-docker.viovi.site;
location / {
proxy_pass http://0.0.0.0:8180;
}
ssl_certificate /etc/letsencrypt/live/builder-docker.viovi.site/fullchain.pem;
@lechidung
lechidung / Install-nginx-and-configure.md
Created April 24, 2020 17:09
Install nginx and configure

Install Nginx

sudo apt-get update
sudo apt-get install nginx

Adjust the Firewall

sudo ufw app list // Show list the applications configurations
sudo ufw allow 'Nginx Full' // opens both port 80 (normal, unencrypted web traffic) and port 443 (TLS/SSL encrypted traffic)
sudo ufw status // Verify the change
@lechidung
lechidung / guide.md
Created April 15, 2020 15:06
Install PHP 7.1/7.2/7.3/7.4 - Nginx - Configure Nginx to Process PHP Pages on Centos 7

Install Nginx

sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx

Install PHP (Multi version 7.1/7.2/ 7.3/ 7.4 )

Must be install epel-release

@lechidung
lechidung / gist:30b5d84a2fe2f1bf171acc201f0e3389
Created November 3, 2019 02:55
configure NGINX to reverse proxy connections from port 80 to other port
server {
listen 80;
server_name hoge.hoge.com; # or server_name subdomain.yourapp.com;
location / {
proxy_pass http://localhost:1337; # port > 1024
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;