Skip to content

Instantly share code, notes, and snippets.

View cyberhobo's full-sized avatar

Dylan Kuhn cyberhobo

View GitHub Profile
@cyberhobo
cyberhobo / basic.php
Created December 8, 2014 22:30
Attempt HTTP Basic Auth test WordPress plugin
<?php
/*
Plugin Name: Attempt Basic Auth
Description: This plugin will fail to activate if it can't use basic authentication with httpbin.org.
*/
register_activation_hook( plugin_basename( __FILE__ ), 'dkk_test_http_basic' );
function dkk_test_http_basic() {
@cyberhobo
cyberhobo / functions.php
Last active August 29, 2015 14:08
WordPress hook to geocode Gravity Forms fields for Geo Mashup
<?php
/**
* Example WordPress hook to geocode Gravity Forms fields for Geo Mashup.
*
* This example uses a form ID of 2, replace _2 with your form ID,
* 'address' and 'zip' with your Gravity Forms field names, and prefix
* with your unique namespace prefix.
*/
add_action( 'gform_after_submission_2' 'prefix_gform_after_submission_2', 10, 2 );
@cyberhobo
cyberhobo / custom-googlev3.js
Created June 6, 2014 16:08
WordPress Geo Mashup custom javascript for Google Maps API V3 map styles example
/**
* An example of applying custom styles to a Geo Mashup Google V3 map.
*
* There's a wizard for making your own style arrays at https://gmaps-samples-v3.googlecode.com/svn/trunk/styledmaps/wizard/index.html
**/
GeoMashup.addAction( 'loadedMap', function( properties, map ) {
var google_map = map.getMap();
var custom_styles = [
{
featureType: "landscape.natural",
@cyberhobo
cyberhobo / .htaccess
Created May 20, 2014 23:35
Hide .git repositories on an Apache server
RedirectMatch 404 "(?:.*)/(?:\.git|file_or_dir)(?:/.*)?$"
@cyberhobo
cyberhobo / init-repo
Created April 23, 2014 20:10
Set up a git repository on a server to deploy a branch with submodules when it receives a push.
#!/bin/sh
git init \
&& git config --bool receive.denyCurrentBranch false \
&& git config --path core.worktree ../
@cyberhobo
cyberhobo / config.yaml
Created April 15, 2014 22:57
nginx fastcgi_param environment variables are duplicated
---
vagrantfile-local:
vm:
box: ubuntu-precise12042-x64-vbox43
box_url: 'http://box.puphpet.com/ubuntu-precise12042-x64-vbox43.box'
hostname: null
network:
private_network: 192.168.56.101
forwarded_port:
mAShhAzrESTM:
@cyberhobo
cyberhobo / post-receive
Created April 14, 2014 10:37
Deploy a branch elsewhere after receiving a git push
#!/bin/sh
read oldrev newrev ref
echo "Deploying $ref..."
GIT_WORK_TREE=/path/to/app git checkout -f $ref
@cyberhobo
cyberhobo / .profile
Created April 13, 2014 21:31
Quick and dirty fix for "stdin: not a tty" in root .profile. Much deeper discussion at https://github.com/mitchellh/vagrant/issues/1673
tty -s && mesg n
@cyberhobo
cyberhobo / plugin.php
Created March 2, 2014 23:31
Wordpress Plugin activation dependency check stolen from http://danielpataki.com/2014/01/wordpress-plugin-activation-checks/
function my_activation_check() {
$php = '5.3';
if ( version_compare( PHP_VERSION, $php, '<' ) ) {
deactivate_plugins( basename( __FILE__ ) );
wp_die(
'' .
sprintf(
__( 'My Awesome Plugin can not be activated because it requires a PHP version greater than %1$s. Your PHP version can be updated by your hosting company.', 'textdomain' ),
@cyberhobo
cyberhobo / .htaccess
Last active February 1, 2018 17:38
Redirect requests for WordPress uploads to the staging server (WP Engine or otherwise).
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^wp-content/uploads/(.*)$ http://x.staging.wpengine.com/wp-content/uploads/$1 [L,R=301]
</IfModule>