Skip to content

Instantly share code, notes, and snippets.

View thephucit's full-sized avatar

Thế Phúc thephucit

View GitHub Profile
upstream api_nodes {
ip_hash;
server 127.0.0.1:3010;
}
server {
listen 80;
listen [::]:80;
server_name domain.com;
underscores_in_headers on;
#!/bin/bash
# NOTE: The commands here only applicable for Ubuntu 16.04 Xenial, do not use it for other distros
# Update server to latest packages
sudo apt update
# Install nginx and git
sudo apt install -y nginx git
@thephucit
thephucit / UFW.md
Last active January 24, 2019 04:48

Cấu hình Firewall bằng UFW

apt-get install ufw

bật UFW lên

ufw enable

cho phép UFW chấp nhận tất cả các port của Nginx

#!/bin/bash
sudo apt-get install zsh
sudo apt-get install git-core
curl -L http://install.ohmyz.sh | sh
which zsh
chsh
git add [add những file muốn commit] && git commit
git rm -r --cached .
git add .
git commit -m "fixed untracked files"
============
git rm --cache /path/to/file
git commit -am "Remove file"
git push
@thephucit
thephucit / helper.ts
Last active January 14, 2019 05:08
some helper function in nodejs
/**
* Get random item in array
*
* @param {Object} array
* @param {Number} n
*
* @return {Object}
*/
random(array: any, n: number) {
let result = new Array(n),
sudo systemctl stop mysql
sudo apt-get remove --purge mysql-server mysql-client mysql-common
sudo apt-get autoremove
sudo apt-get autoclean
sudo rm -rf /var/lib/mysql/
sudo rm -rf /etc/mysql/
sudo apt-get install mariadb-server
@thephucit
thephucit / mariadb.md
Created January 11, 2019 02:09
Enabling remote access on mariadb server

create user USERNAME identified by 'PASSWORD'; grant all privileges on . to 'USERNAME';

@thephucit
thephucit / facade.php
Last active August 14, 2022 02:27
các design patterns thông dụng trong php
# đây là một mẫu lập trình biến việc sử dụng nhiều class với các phương thức khác nhau về một interface đơn giản với một phương thức,
# nói một cách đơn giản hơn là thay vì thực hiện nhiều lời gọi phương thức chúng ta chỉ thực hiện gọi một phương thức.
  1. stack là hàng đợi (last in first out) nghĩa là vào sau ra trước: ví dụ có hàm A triệu gọi hàm B, thì trạng thái hiện tại của hàm A được cất giữ trong stack và hàm B sẽ được chèn vào stack. Vì đây là hàng đợi LIFO nên B sẽ được xử lý trước A. Khi B xong và return thì mới đến lượt A được xử lý. Khi A được xử lý xong và return thì Stack rỗng và sẽ đợi các hàm tiếp theo được đẩy vào.

  2. Heap là vùng nhớ được dùng để chưa kết quả tạm phục vụ cho việc thực thi các hàm trong stack. Heap càng lớn thì khả năng tính toán càng cao. Heap có thể được cấp phát tĩnh hoặc cấp phát động bằng mấy lệnh kiểu alloc với malloc (đấy là những gì còn nhớ về C++).