Skip to content

Instantly share code, notes, and snippets.

@alanzhaonys
alanzhaonys / gist:b69cf996ae6cdbfbd386a745da2b3bd6
Last active October 30, 2020 21:14
WordPress Admin Bar, Dashboard, head and footer Clean Up
<?php
//
//
// Below is the code that cleans up dashboard and admin bar
//
//
//
// Remove admin bar from frontend
@alanzhaonys
alanzhaonys / gist:bd6621dcdc110aeaf03b5e89278049e6
Created February 14, 2020 15:12
WordPress Frontend Compression and Caching via .htaccess
# Start compression
<IfModule mod_deflate.c>
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
AddOutputFilterByType DEFLATE application/x-font
AddOutputFilterByType DEFLATE application/x-font-opentype
AddOutputFilterByType DEFLATE application/x-font-otf
AddOutputFilterByType DEFLATE application/x-font-truetype
AddOutputFilterByType DEFLATE application/x-font-ttf
@alanzhaonys
alanzhaonys / gist:bed46b6cb70e6edb01e96daa976339fc
Last active July 22, 2020 14:40
WordPress Hardening via .htaccess
# Block the include-only files.
# https://wordpress.org/support/article/hardening-wordpress/#securing-wp-includes
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^wp-admin/includes/ - [F,L]
RewriteRule !^wp-includes/ - [S=3]
RewriteRule ^wp-includes/[^/]+\.php$ - [F,L]
RewriteRule ^wp-includes/js/tinymce/langs/.+\.php - [F,L]
RewriteRule ^wp-includes/theme-compat/ - [F,L]
@alanzhaonys
alanzhaonys / s3-bucket-access-iam-policy.json
Last active April 7, 2020 18:24
Allow S3 Bucket Access IAM Policy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AddPerm",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::www.damin.com/*"
}
@alanzhaonys
alanzhaonys / s3-bucket-access-iam-policy.json
Created June 26, 2019 04:10
Allow S3 Bucket Access IAM Policy
{
"Version": "2012-10-17",
"Statement":[{
"Effect": "Allow",
"Action": "s3:*",
"Resource": ["arn:aws:s3:::my_bucket",
"arn:aws:s3:::my_bucket/*"]
}
]
}
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
//////Author Parameters - Show posts associated with certain author.
" syntax highlighting
syntax on
filetype plugin indent on
" show existing tab with 4 spaces width
set tabstop=2
" when indenting with '>', use 4 spaces width
set shiftwidth=2
" On pressing tab, insert 4 spaces
set expandtab
@alanzhaonys
alanzhaonys / gist:58df5a24249b80020e700bea7a3e6ee9
Created December 7, 2018 15:23
Create new DB, User and Permission
CREATE DATABASE database_name; GRANT ALL ON database_name.* TO 'database_user'@'%' IDENTIFIED BY 'database_password';
@alanzhaonys
alanzhaonys / gist:4f59ba9e0237c212f832d6afbd9bfaf7
Created December 5, 2018 16:05
Install NODE on Amazon Linux 2
curl --silent --location https://rpm.nodesource.com/setup_8.x | sudo bash -
sudo yum -y install nodejs
@alanzhaonys
alanzhaonys / gist:2bc0192b76c15c1ec721aee2ae5adc0b
Created November 29, 2018 00:36
Maintenance page redirect
RewriteEngine on
RewriteCond %{REQUEST_URI} !/maintenance.php$
RewriteCond %{REMOTE_HOST} !^000\.000\.000\.000
RewriteRule $ /maintenance.php [R=302,L]