Skip to content

Instantly share code, notes, and snippets.

@boreal321
boreal321 / redirect-to-index.php
Created December 3, 2015 04:21
Simple redirect plugin for wordpress. Redirects all requests back to the index except for login page or if already logged in.
<?php
add_action( 'template_redirect', 'redirect_to_index', 9 );
function redirect_to_index() {
if ( preg_match( "/login|admin/i", $_SERVER[ 'REQUEST_URI'] ) > 0 ) {
return false;
}
if ( !is_user_logged_in() ) {
wp_redirect( home_url() );
@boreal321
boreal321 / gist:80fcf7e4edcf1b37a796
Created May 24, 2014 03:38
ansible mysql_replication playbook
- name: Check if slave is already configured for replication
mysql_replication: mode=getslave
ignore_errors: true
register: slave
when: mysql_repl_role == 'slave'
tags: mysql
- name: Get the current master servers replication status
mysql_replication: mode=getmaster
delegate_to: "{{ mysql_repl_master }}"
<?php wp_register_script( $handle, $src, $deps, $ver, $in_footer ); ?>
for i in `find . -name "*.png"`; do optipng -o5 -quiet -keep -preserve -log optipng.log "$i"; done
@boreal321
boreal321 / mtr_boreal_1
Created October 29, 2012 16:56
mtr dump to boreal
Host Loss% Snt Last Avg Best Wrst StDev
1. 10.124.54.1 0.0% 13 8.0 9.0 7.0 12.7 1.4
2. vl-201.gw03.rchrd.phub.net.cable.rogers.com 0.0% 13 14.0 13.0 10.7 16.4 1.5
3. ???
4. ???
5. 2120.ae0.bdr01.tor.packetflow.ca 90.9% 12 11.2 11.2 11.2 11.2 0.0
6. ???
Host Loss% Snt Last Avg Best Wrst StDev
1. 10.124.54.1 0.0% 18 7.6 9.4 7.3 16.8 2.1
@boreal321
boreal321 / siege_performance_summary_log
Created October 27, 2012 08:20
Website Performance Tests using siege
04:17:11 Sat Oct 27
[vmg@beech Performance]> siege -b --time=30s --log=perf.log -f swplinks
** SIEGE 2.71
** Preparing 15 concurrent users for battle.
The server is now under siege...
Lifting the server siege... done.
Transactions: 59200 hits
Availability: 100.00 %
Elapsed time: 29.98 secs
@boreal321
boreal321 / debug-options_wp-config.php
Created September 28, 2012 17:03
debugging options for wp-config.php
/**
* Define where error logging will be written to.
*/
@ini_set('log_errors','On');
@ini_set('error_log','/path/to/logs/php_error.log');</code>
/**
* This will log all errors notices and warnings to a file called debug.log in
* wp-content only when WP_DEBUG is true. if Apache does not have write permission,
* you may need to create the file first and set the appropriate permissions (i.e. use 666).
@boreal321
boreal321 / make_root_CA.conf
Created September 27, 2012 21:00
OpenSSL configuration file to generate a root certificate for signing client and web server certificates.
[ req ]
default_keyfile = ./root_CA.key
default_md = sha1
distinguished_name = req_distinguished_name
x509_extensions = v3_ca
string_mask = nombstr
req_extensions = v3_req
[ req_distinguished_name ]
countryName = Country Name (2 letter code)
countryName_default = CA
@boreal321
boreal321 / make_root_CA.sh
Created September 27, 2012 18:30
Shell script to generate a root certificate for signing client and web server certificates.
#!/bin/sh
BITS=2048
DAYSVALID=7300
RANDDEV=/dev/urandom
CNF=./make_root_CA.conf
DER=./root_CA.der
PEM=./root_CA.pem
KEY=./root_CA.key
#
@boreal321
boreal321 / gravity_forms_example_1.php
Created September 17, 2012 01:49
Gravity Forms hook to stop a form from loading
add_filter('gform_pre_render', 'swp_populate_attendee_list');
function swp_populate_attendee_list($form){
$num = swp_get_the_amount();
if ( count( $num ) < 1 ) {
add_filter('gform_get_form_filter', create_function('', "return 'You have not met the condition! Please go to <a href=\"/?page_id=1\">this form.</a>';") );
}
return $form;