Skip to content

Instantly share code, notes, and snippets.


Nikhil Nikschavan

View GitHub Profile
View wp-plugin-mu-loader.php
* Plugin initialization file
* @package WP_Plugin_MU_Loader
* @since 1.0.0
* @wordpress-plugin
* Plugin Name: WP Plugin MU Loader
* Plugin URI:
davidegreenwald / WordPress-wp_posts-MySQL-data-size
Last active Jan 4, 2018
MySQL statement for WordPress wp_posts table breaking down data size for each post_type
View WordPress-wp_posts-MySQL-data-size
-- This will show you the size of post, revision, attachment and other fields in `wp_posts`
-- this method can be applied to any WordPress table to get a breakdown of clutter and data use
-- this will not get you index size, but WP indexes are typically a small fraction of overall table size
SELECT post_type
COUNT(*) AS NUM, -- adds a column with the number of rows for each key value for comparison
SELECT post_type, COUNT(*) AS NUM,
(SUM(LENGTH(ID) -- add all column data together to group the total row data by post_type
sheharyarn / nginx.overrides
Created Jun 27, 2015
Restart / Reload Nginx without Entering Sudo Password
View nginx.overrides
# Enter this command to create a sudoers override/include file:
# sudo visudo -f /etc/sudoers.d/nginx.overrides
# (Make sure you actually have this in your /etc/sudoers - Run `sudo visudo` to check)
# #includedir /etc/sudoers.d
# This file assumes your deployment user is `deploy`
# Nginx Commands
Cmnd_Alias NGINX_RESTART = /usr/sbin/service nginx restart
GaryJones / phpmd.xml
Created Sep 12, 2014
PHPMD Ruleset for a WordPress Theme
View phpmd.xml
<?xml version="1.0"?>
<ruleset name="phpmd.xml"
<description>PHPMD Ruleset for a WordPress Theme</description>
<rule ref="rulesets/cleancode.xml/BooleanArgumentFlag" />
<rule ref="rulesets/cleancode.xml/ElseExpression" />
<rule ref="rulesets/cleancode.xml/StaticAccess" />
mheadd /
Created May 13, 2013
Simple bash script to check whether MySQL is running.
UP=$(pgrep mysql | wc -l);
if [ "$UP" -ne 1 ];
echo "MySQL is down.";
sudo service mysql start
echo "All is well.";
View Track CPU usage by PID over time
# --- Version history ---
# 0.4: added variable to store file path, and $2 for base file name
# added variable to store desired reporting interval
# 0.3: added $1 to send in process ID at run time.
# 0.2: switched to $SECONDS for the loop. works.
# 0.1: didn't work well at all.
# --- Version history ---
# Usage: cputrack [PID] [filename]