Skip to content

Instantly share code, notes, and snippets.

Avatar
🤘
Rocking this project.

Mike Garrett MikeNGarrett

🤘
Rocking this project.
View GitHub Profile
@MikeNGarrett
MikeNGarrett / find-your-ip
Created Feb 18, 2014
Find your IP vis curl
View find-your-ip
//Find your IP vis curl
curl ipecho.net/plain
@MikeNGarrett
MikeNGarrett / sanity.sh
Created May 7, 2014
Bring some sanity to a wget log. I'm pulling out all the files that are returning 404.
View sanity.sh
# Working with data like this:
# HTTP request sent, awaiting response... .--2014-05-06 16:41:58-- http://xxx.com/xxx.jpg
# Resolving xxx.com... 1.1.1.1
# Connecting to xxx.com|1.1.1.1|:80... ...............connected.
# HTTP request sent, awaiting response... .. .......... .... ....... .......--2014-05-06 16:41:58-- http://xxx.com/xxx.jpg
# Resolving xxx.com... .... .1.1.1.1
# Connecting to xxx.com|1.1.1.1|:80... .........404 Not Found
# 2014-05-06 16:41:58 ERROR 404: Not Found.
#
# .....200 OK
@MikeNGarrett
MikeNGarrett / example.php
Created May 29, 2014
Stack trace anything
View example.php
<?php
file_put_contents(__DIR__.'/stack.log', print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT), true));
?>
@MikeNGarrett
MikeNGarrett / script.js
Created Aug 24, 2014
Script for organizing abetterqueue.com
View script.js
var out = ''; jQuery('.rating').each(function(a){ out += "<b data-rating="+jQuery(this).text().trim().replace('%', '')+">"+jQuery(this).text().trim().replace('%', '')+","+jQuery(this).children().attr('href')+"</b><br>" }); jQuery('body').html(out);
@MikeNGarrett
MikeNGarrett / keybase.md
Created Oct 1, 2014
keybase.io verification
View keybase.md

Keybase proof

I hereby claim:

  • I am MikeNGarrett on github.
  • I am mikengarrett (https://keybase.io/mikengarrett) on keybase.
  • I have a public key whose fingerprint is EC65 0153 F732 6C65 E9AD 7362 A8AC 3E70 563A 657D

To claim this, I am signing this object:

@MikeNGarrett
MikeNGarrett / output-all-wp-image-styles
Last active Aug 29, 2015
WordPress print all image sizes
View output-all-wp-image-styles
add_action( 'shutdown', function() { global $_wp_additional_image_sizes; var_dump($_wp_additional_image_sizes); die; });
@MikeNGarrett
MikeNGarrett / import-wp-users-by-role
Last active Aug 29, 2015
Add a list of WordPress users from a CSV
View import-wp-users-by-role
# CSV format: username, email, password
export IFS=","; cat /path/to/test.csv | while read a b c; do wp user create $a $b --user_pass=$c --role=administrator; done
@MikeNGarrett
MikeNGarrett / gist:9405070
Last active Sep 8, 2015
Insert new user administrator account into WordPress via the database
View gist:9405070
# Grabbed for reference from http://www.wpbeginner.com/wp-tutorials/how-to-add-an-admin-user-to-the-wordpress-database-via-mysql/
# Check the table prefix
# Check the user_id to make sure it is the next in sequence
# Replace my name and email to your own
# Username will be demo and the password will be 1234
INSERT INTO `wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_url`, `user_registered`, `user_activation_key`, `user_status`, `display_name`) VALUES ('4', 'mgarrett', MD5('1234'), 'Mike Garrett', 'test@yourdomain.com', '', '2011-06-07 00:00:00', '', '0', 'Mike Garrett');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_capabilities', 'a:1:{s:13:"administrator";b:1;}');
INSERT INTO `wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '4', 'wp_user_level', '10');
# Troubleshooting
@MikeNGarrett
MikeNGarrett / regex-strip-non-utf-8
Created Nov 16, 2012
Strip unknown/non-utf-8 characters
View regex-strip-non-utf-8
$new_text = preg_replace('/[^(\x20-\x7F)]*/','', $text);
@MikeNGarrett
MikeNGarrett / 404s.sh
Created Nov 18, 2015
Go and get the most frequent 404s
View 404s.sh
grep "HTTP/1.1\" 404" access.log | awk '{print $7 } ' | sort | uniq -c | sort -n
You can’t perform that action at this time.