Skip to content

Instantly share code, notes, and snippets.

Brian Fegter inspectorfegter

Block or report user

Report or block inspectorfegter

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@inspectorfegter
inspectorfegter / create_deployment.sh
Created Jun 29, 2018 — forked from kgorskowski/create_deployment.sh
recreate latest successful codedeploy deployment. needs awscli, jq and corresponding iam permissions
View create_deployment.sh
#!/bin/bash
#your variables here, you can set AWS credentials here as well
AWS_REGION=$YourAWSRegion
DEP_GROUP=$NameOfYourCodeDeployDeploymentGroup
APP_NAME=$NameOfYourCDApplication
# list successfull deployments only
STATUS=Succeeded
View coderrr-s3-convert.php
<?php
/*
Plugin Name: Coderrr S3 Conversion
Description: Converts previously uploaded attachments to work with amazon-s3-and-cloudfront plugin
Version: 0.1
Author: Brian Fegter
License: GPLv2+
*/
/**
View http-basic-auth-wordpress.php
<?php
function send_http_auth_headers(){
header('WWW-Authenticate: Basic realm="Your Website Name Restricted"');
header('HTTP/1.0 401 Unauthorized');
echo 'Please speak to an administrator for access to the this feature.';
exit;
}
add_action('template_redirect', 'maybe_add_http_auth_basic', 0);
function maybe_add_http_auth_basic(){
# Add your specific URI segment (i.e. http://example.com/segment-string/)
@inspectorfegter
inspectorfegter / psuedo-static-js.php
Last active Apr 7, 2017
Add a pseudo static JS file to WordPress
View psuedo-static-js.php
<?php
#Add a query var to sniff requests
add_filter( 'query_vars', 'my_query_var_callback', 10, 1 );
function my_query_var_callback( $vars ){
$vars[] = 'dynamic_js';
return $vars;
}
#Dynamic JavaScript
add_rewrite_rule( '^assets/js/dynamic\.js$', 'index.php?dynamic_js=1', 'top' ); //Note the hidden query variable
@inspectorfegter
inspectorfegter / regex-schtuff.txt
Created Sep 18, 2013
A basic, basic primer for regex and PHP.
View regex-schtuff.txt
_______ ______ __ _ ___ ___
|_ __ \ .' ____ \ [ | / |_ .' ..] .' ..]
| |__) | .---. .--./) .---. _ __ | (___ \_| .---. | |--. `| |-'__ _ _| |_ _| |_
| __ / / /__\\/ /'`\;/ /__\\[ \ [ ] _.____`. / /'`\] | .-. | | | [ | | |'-| |-''-| |-'
_| | \ \_| \__.,\ \._//| \__., > ' < | \____) || \__. | | | | | |, | \_/ |, | | | |
|____| |___|'.__.'.',__` '.__.'[__]`\_] \______.''.___.'[___]|__]\__/ '.__.'_/[___] [___]
( ( __))
---------------------------------------------------------------------------------------------------------------
@inspectorfegter
inspectorfegter / wp-config-switcher.php
Last active Dec 11, 2015
For use with multiple sub-folder WordPress installations. This allows you to store all wp-config.php in any folder on your server. WP config files are renamed to correspond with the server name. This approach helps you protect your wp-config files when you have multiple docroots in one folder.
View wp-config-switcher.php
<?php
# ------------------
# no shenanigans
# ------------------
if ( __FILE__ == $_SERVER['SCRIPT_FILENAME'] ) { die(); }
# ---------------
# server name
# ---------------
$server = $_SERVER['SERVER_NAME'];
@inspectorfegter
inspectorfegter / psuedo-buffer.php
Created Dec 31, 2012
Allows you to send the current user auth cookie along with a WP HTTP API remote request. This is useful for storing a page load for analysis in a psuedo-buffer if you are competing with cache plugins that use output buffering.
View psuedo-buffer.php
<?php
#Set your current WP install URL
$url = 'http://currentwpinstall.com';
#Create cookie string
$cookie_string = '';
foreach($_COOKIE as $k => $v)
#Assure we are setting the proper string if other cookies are set
if(preg_match('/(wordpress_test_cookie|wordpress_logged_in_|wp-settings-1|wp-settings-time-1)/', $k))
$cookie_string .= $k . '=' . urlencode($v) . '; ';
@inspectorfegter
inspectorfegter / wordpress-audit-attachments.php
Created Oct 20, 2012
WordPress Plugin - Audit Post Attachments
View wordpress-audit-attachments.php
<?php
/*
Plugin Name: Audit Attachments
Description: Reports on a set of post types and their respective attachments
Version: 0.1
Author: Brian Fegter
Author URI: http://coderrr.com/
*/
/**
@inspectorfegter
inspectorfegter / wordpress-remove-404-attachments
Created Oct 20, 2012
Remove attachment rows where the associated file on the disk doesn't exist.
View wordpress-remove-404-attachments
<?php
/**
* Usage when logged in: http://yourdomain.com/wp-admin/remove-404-attachments=secretpassword
*/
# Hook late into admin_init
add_action('admin_init', 'remove_404_attachments', 9999999);
function remove_404_attachments(){
@inspectorfegter
inspectorfegter / pug-bomb.php
Created Jun 24, 2012
Pug Bomb API Endpoint WordPress Plugin
View pug-bomb.php
<?php
/*
Plugin Name: Pug Bomb API Endpoint
Description: Adds an API endpoint at /api/pugs/$n_pugs
Version: 0.1
Author: Brian Fegter
Author URL: http://coderrr.com
*/
class Pugs_API_Endpoint{
You can’t perform that action at this time.