Skip to content

Instantly share code, notes, and snippets.

Hien D. Nguyen hiendnguyen

Block or report user

Report or block hiendnguyen

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@hiendnguyen
hiendnguyen / djangodemo_uwsgi.ini
Last active Jun 6, 2019
Configure uWSGI as service
View djangodemo_uwsgi.ini
# Create 'uwsgi' user: unprivileged user
useradd -s /bin/false -r uwsgi
# Emperor mode
## create a directory for the vassals
- mkdir -p /etc/uwsgi/vassals
## Configuring uWSGI to run with a .ini file
vi /var/www/vndeveloper/djangodemo/djangodemo_uwsgi.ini
### Put below content in djangodemo_uwsgi.ini
@hiendnguyen
hiendnguyen / nginx-uwsgi-django.conf
Last active Jun 6, 2019
NGINX config for uWSGI and Django
View nginx-uwsgi-django.conf
vi /etc/nginx/conf.d/django.conf
# Put below content in it.
# the upstream component NGINX needs to connect to
upstream django {
server unix:/run/uwsgi/django.sock;
}
# configuration of the server
server {
@hiendnguyen
hiendnguyen / Virtual-RAM.sh
Last active Apr 2, 2019
CentOS 7 Virtual RAM
View Virtual-RAM.sh
# In this case, I use 2G swapfile or virtual RAM
sudo dd if=/dev/zero of=/swapfile count=1024 bs=1MiB
sudo chmod 600 /swapfile
sudo mkswap /swapfile
sudo swapon /swapfile
sudo sh -c 'echo "/swapfile none swap sw 0 0" >> /etc/fstab'
@hiendnguyen
hiendnguyen / LEMP.sh
Last active Jan 11, 2018
CentOS 7 LEMP
View LEMP.sh
# Install Nginx
sudo yum install epel-release
sudo yum install nginx
sudo systemctl start nginx
sudo systemctl enable nginx
# Install MySQL (MariaDB)
sudo yum install mariadb-server mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb
@hiendnguyen
hiendnguyen / uwsgi.service
Last active Jul 31, 2017
Configure uWSGI server and let's make it runs as a service
View uwsgi.service
vi /etc/systemd/system/uwsgi.service
# Put below as its content
[Unit]
Description=uWSGI Emperor service
[Service]
ExecStartPre=/usr/bin/bash -c 'mkdir -p /run/uwsgi; chown uwsgi:nginx /run/uwsgi'
ExecStart=/var/www/p3venv/bin/uwsgi --emperor /etc/uwsgi/vassals
Restart=always
KillSignal=SIGQUIT
Type=notify
@hiendnguyen
hiendnguyen / registration-form.php
Created Mar 7, 2017
WooCommerce Registration Custom Fields Utilities
View registration-form.php
<?php
/*** Change default login url to WooCommerce My Account ***/
function my_login_page( $login_url, $redirect ) {
$myaccount_url = get_permalink(wc_get_page_id('myaccount'));
return $redirect == '' ? $myaccount_url : $myaccount_url . '?redirect_to=' . $redirect;
}
add_filter( 'login_url', 'my_login_page', 10, 2 );
/*** We don't want "account page" displays after login by default. We want to display homepage instead ***/
@hiendnguyen
hiendnguyen / woocommerce-registration-custom-fields.php
Created Mar 7, 2017
WooCommerce Registration Custom Fields
View woocommerce-registration-custom-fields.php
<?php
/* Plugin Name: WooCommerce Registration Custom Fields
* Plugin URI: https://vndeveloper.com
* Description: Add Fist Name, Last Name, Phone, Company, Role fields as well as Privacy Policy and Terms of Use links into WooCommerce Registration form.
* Version: 1.0.0
* Author: VNDeveloper
* Author URI: https://vndeveloper.com
* Requires at least: 4.1
* Tested up to: 4.7
* Text Domain: vndev-wooc-signup
@hiendnguyen
hiendnguyen / reCAPTCHA_Wooc.php
Last active May 5, 2017
Add reCAPTCHA to WooCommerce Signup Form
View reCAPTCHA_Wooc.php
<?php
/* wooc_reCAPTCHA */
// Add reCAPTCHA to WooCommerce Signup Form
function wooc_reCAPTCHA(){
?>
<script src='https://www.google.com/recaptcha/api.js' defer'></script>
<label>ARE YOU HUMAN?</label>
<div class="g-recaptcha" data-sitekey="[reCAPTCHA Site Key]"></div>
@hiendnguyen
hiendnguyen / vndeveloper.conf
Last active Mar 31, 2017
NGINX Server Block File
View vndeveloper.conf
server {
listen 80;
server_name vndeveloper.com www.vndeveloper.com;
root /var/www/vndeveloper.com/html;
index index.html index.htm index.php;
location / {
View info.php
<?php
// outputs the username that owns the running php/httpd process
// (on a system with the "whoami" executable in the path)
echo exec('whoami');
?>
You can’t perform that action at this time.