Skip to content

Instantly share code, notes, and snippets.

View MikeNGarrett's full-sized avatar
🤘
Rocking this project.

Mike Garrett MikeNGarrett

🤘
Rocking this project.
View GitHub Profile
@MikeNGarrett
MikeNGarrett / find-your-ip
Created February 18, 2014 15:03
Find your IP vis curl
//Find your IP vis curl
curl ipecho.net/plain
@MikeNGarrett
MikeNGarrett / sanity.sh
Created May 7, 2014 03:54
Bring some sanity to a wget log. I'm pulling out all the files that are returning 404.
# 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 15:06
Stack trace anything
<?php
file_put_contents(__DIR__.'/stack.log', print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT), true));
?>
@MikeNGarrett
MikeNGarrett / script.js
Created August 24, 2014 01:36
Script for organizing abetterqueue.com
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 October 1, 2014 15:36
keybase.io verification

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 August 29, 2015 14:11
WordPress print all image sizes
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 August 29, 2015 14:23
Add a list of WordPress users from a CSV
# 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 / regex-strip-non-utf-8
Created November 16, 2012 21:04
Strip unknown/non-utf-8 characters
$new_text = preg_replace('/[^(\x20-\x7F)]*/','', $text);
@MikeNGarrett
MikeNGarrett / 404s.sh
Created November 18, 2015 22:50
Go and get the most frequent 404s
grep "HTTP/1.1\" 404" access.log | awk '{print $7 } ' | sort | uniq -c | sort -n
@MikeNGarrett
MikeNGarrett / .maintenance
Created February 20, 2013 21:56
Allow WordPress users to log in to wp-admin and wp-login.php while in maintenance mode. Stick this in your web root to put your site into maintenance mode.
<?php
function is_user_logged_in() {
$loggedin = false;
foreach ( (array) $_COOKIE as $cookie => $value ) {
if ( stristr($cookie, 'wordpress_logged_in_') )
$loggedin = true;
}
return $loggedin;
}
if ( ! stristr($_SERVER['REQUEST_URI'], '/wp-admin') && ! stristr($_SERVER['REQUEST_URI'], '/wp-login.php') && ! is_user_logged_in() )