This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** Validate the extra register fields. */ | |
function wooc_validate_extra_register_fields( $username, $email, $validation_errors ) { | |
if ( isset( $_POST['billing_first_name'] ) && empty( $_POST['billing_first_name'] ) ) { | |
$validation_errors->add( 'billing_first_name_error', __( 'What\'s your first name?', 'woocommerce' ) ); | |
} | |
if ( isset( $_POST['billing_last_name'] ) && empty( $_POST['billing_last_name'] ) ) { | |
$validation_errors->add( 'billing_last_name_error', __( 'What\'s your last name?', 'woocommerce' ) ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# the upstream component NGINX needs to connect to | |
upstream django { | |
server unix:/run/uwsgi/django.sock; | |
} | |
server { | |
listen 80; | |
server_name www.vndeveloper.com; | |
charset utf-8; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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/example/djangodemo/djangodemo_uwsgi.ini | |
### Put below content in djangodemo_uwsgi.ini |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[uwsgi] | |
# Django-related settings | |
# the base directory (full path) | |
chdir = /var/www/vndeveloper/djangodemo/ | |
# Django's wsgi file | |
module =djangodemo.wsgi | |
# the virtualenv (full path) | |
home = /var/www/p3venv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from selenium import webdriver | |
driver = webdriver.Chrome(executable_path="C:/VNTesters/chromedriver.exe") | |
driver.get ("https://vntesters.com/") | |
print (driver.title) | |
driver.quit() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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 ***/ |
NewerOlder