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
//* Get post view counts | |
function getPostViews($postID){ | |
$count_key = 'post_views_count'; | |
$count = get_post_meta($postID, $count_key, true); | |
if($count==''){ | |
delete_post_meta($postID, $count_key); | |
add_post_meta($postID, $count_key, '0'); | |
return "0 Views"; | |
} | |
return $count.' Views'; |
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
add_filter( 'generate_post_date_output', 'tu_show_modified_date' ); | |
function tu_show_modified_date() { | |
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>'; | |
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) { | |
$time_string = 'Updated on: <time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>'; | |
} | |
$time_string = sprintf( $time_string, | |
esc_attr( get_the_date( 'c' ) ), |
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
// Display Tag code | |
function ahmedkaludi_structured_data_keyword() { | |
if ( is_single() ) { | |
$tags = '"keywords" : [' . strip_tags(get_the_tag_list('"','", "','"')) . ']'; | |
} else { } | |
echo $tags; | |
} | |
function ahmedkaludi_structured_data_output() { |
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
# GOAL: On a CentOS 6.7 minimal install, set up nginx as a reverse proxy to uWSGI Emperor with python 2.7.11 as a plugin to run Flask apps | |
# ::NOTE:: All instructions below are run as a sudoer, not as root. Talk to your sysadmins if you're not a sudoer. | |
# Install bare essentials: | |
sudo yum install -y epel-release | |
sudo yum groupinstall 'Development Tools' | |
sudo yum install -y vim openssl unzip nginx openssl-devel zlib-devel sqlite-devel bzip2-devel libffi-devel lapack-devel blas-devel libpng-devel freetype-devel | |
# Set SELINUX=disabled in the file below, and reboot, or this tutorial will get unnecessarily complicated: |
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
# Look for client IP in the X-Forwarded-For header | |
real_ip_header X-Forwarded-For; | |
# Ignore trusted IPs | |
real_ip_recursive on; | |
# Trusted list | |
set_real_ip_from 199.27.128.0/21; | |
set_real_ip_from 173.245.48.0/20; | |
set_real_ip_from 103.21.244.0/22; |
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
http { | |
map $whitelist $limit { | |
default $binary_remote_addr; | |
1 ""; | |
} | |
limit_conn_zone $limit zone=conn_limit_per_ip:10m; | |
limit_req_zone $limit zone=req_limit_per_ip:10m rate=5r/s; | |
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
# Kernel sysctl configuration file for Linux | |
# | |
# Version 1.16 - 2018-10-23 | |
# Michiel Klaver - IT Professional | |
# Modified by VirtuBox | |
# | |
# Instructions available on https://github.com/VirtuBox/ubuntu-nginx-web-server | |
# | |
# Sources : | |
# https://klaver.it/linux/sysctl.conf |
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
for i in `curl https://www.cloudflare.com/ips-v4`; do csf -a $i; done | |
for i in `curl https://www.cloudflare.com/ips-v6`; do csf -a $i; done |
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
[mysqld] | |
port = 3306 | |
socket = /var/lib/mysql/mysql.sock | |
back_log = 50 | |
max_connections = 100 | |
max_connect_errors = 10 | |
table_open_cache = 2048 | |
max_allowed_packet = 16M | |
binlog_cache_size = 1M | |
max_heap_table_size = 2G |
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
#! /usr/bin/env python | |
import MySQLdb | |
host = "localhost" | |
passwd = "" | |
user = "root" | |
dbname = "mydbname" | |
db = MySQLdb.connect(host=host, user=user, passwd=passwd, db=dbname) | |
cursor = db.cursor() |
OlderNewer