Skip to content

Instantly share code, notes, and snippets.

View michaelbonner's full-sized avatar

Michael Bonner michaelbonner

View GitHub Profile
@michaelbonner
michaelbonner / gist:34470f824448ced5d2d0
Created September 11, 2014 14:42
Find replace mysql
update [table_name] set [field_name] = replace([field_name],'[string_to_find]','[string_to_replace]');
@michaelbonner
michaelbonner / wp_query loop
Created September 17, 2014 16:03
wp_query loop
// the query
$the_query = new WP_Query( $args );
// the loop
if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
// stuff
endwhile; endif;
@michaelbonner
michaelbonner / terminal-change-perms
Created October 14, 2014 14:50
Terminal | change all files' and folders' permissions in directory
find ./ -type d -exec chmod 755 {} \;
find ./ -type f -exec chmod 644 {} \;
@michaelbonner
michaelbonner / wp-go-live
Last active August 29, 2015 14:07
Wordpress queries to go live
update `prefix_posts` set `post_content` = replace(`post_content`, 'oldurl', 'newurl');
update `prefix_postmeta` set `meta_value` = replace(`meta_value`, 'oldurl', 'newurl');
update `prefix_options` set `option_value` = replace(`option_value`, 'oldurl', 'newurl');
@michaelbonner
michaelbonner / gist:867ae7ddced3389dfe87
Last active August 29, 2015 14:10
Stop WordPress Comment Spam
// check to see if the hidden input exists in submission
function preprocess_new_comment($commentdata) {
if(!isset($_POST['is_legit'])) {
die();
}
return $commentdata;
}
add_action('preprocess_comment', 'preprocess_new_comment');
// add hidden field to form
@michaelbonner
michaelbonner / Terminal - size directories and sort by largest
Created December 11, 2014 20:19
Terminal | size directories and sort by largest
du -h / | sort -h
@michaelbonner
michaelbonner / gist:8b2f9418a9c501521a31
Last active August 29, 2015 14:16
Terminal | ApacheBench - Send 1000 requests 5 at a time
ab -n 1000 -c 5 http://www.example.com/
SELECT TABLE_NAME, table_rows, data_length, index_length, round(((data_length + index_length) / 1024 / 1024 ), 2 ) "MB"
FROM information_schema.TABLES
WHERE table_schema = "schema_name"
ORDER BY (data_length + index_length) DESC;
# Add the following to your wp-config.php file
# Replace http://example.com/ with your url
if (!defined('WP_SITEURL')) {
define('WP_SITEURL', 'http://example.com/');
}
if (!defined('WP_HOME')) {
define('WP_HOME', 'http://example.com/');
}
// in .vscode/settings.json
{
"workbench.colorCustomizations": {
"titleBar.activeForeground": "#051935",
"titleBar.inactiveForeground": "#051935CC",
"titleBar.activeBackground": "#377ED1",
"titleBar.inactiveBackground": "#377ED1CC"
}
}