Skip to content

Instantly share code, notes, and snippets.

View michaelbonner's full-sized avatar

Michael Bonner michaelbonner

View GitHub Profile
@michaelbonner
michaelbonner / create-wordpress-user.php
Created March 12, 2024 18:12
Create WordPress user function
<?php
add_action('init', function () {
$user = 'Bootpack';
$pass = '{{someRandomPassword}}';
$email = 'dev@bootpackdigital.com';
if (!username_exists($user) && !email_exists($email)) {
$user_id = wp_create_user($user, $pass, $email);
$user = new WP_User($user_id);
$user->set_role('administrator');
}
@michaelbonner
michaelbonner / why-isnt-position-sticky-working.js
Last active June 5, 2024 17:18
Why isn't position sticky working
// Postition sticky won't work if any of that elements ancestors have overflow hidden, auto, or scroll
let parent = document.querySelector('.sticky').parentElement;
while (parent) {
const hasOverflow = getComputedStyle(parent).overflow;
if (hasOverflow !== 'visible') {
console.log(hasOverflow, parent);
}
parent = parent.parentElement;
echo "GET https://example.com" | vegeta attack -rate 50 | tee results.bin | vegeta report
watch "cat results.bin | vegeta report"
#!/bin/bash
# Instructions
## Save this file to the root of where your projects are stored
## cd to the projects root directory and run chmod +x _timelog.sh
## Change Michael Bonner to your name as it's set in your git config
#
AUTHOR="Michael Bonner"
TWO_MONTHS_AGO=`date -j -v-2m`
# Legend:
## {USER_NAME} replace with the user you log in to the system as
## {APPLICATION_DIRECTORY} : replace with the project directory name
# Installing bindfs (just the first time)
$ sudo apt-get update
$ sudo apt-get -y install bindfs
# Creating the application mount point
$ mkdir -p /home/{USER_NAME}/sites/{APPLICATION_DIRECTORY}
// in .vscode/settings.json
{
"workbench.colorCustomizations": {
"titleBar.activeForeground": "#051935",
"titleBar.inactiveForeground": "#051935CC",
"titleBar.activeBackground": "#377ED1",
"titleBar.inactiveBackground": "#377ED1CC"
}
}
# 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/');
}
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;
@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/
@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