Skip to content

Instantly share code, notes, and snippets.

@geraintp
geraintp / apache_request_headers.php
Last active October 30, 2018 12:03 — forked from ivanrosolen/apache_request_headers.php
apache_request_headers
View apache_request_headers.php
<?php
if( !function_exists('apache_request_headers') ) {
function apache_request_headers() {
$arh = array();
$rx_http = '/\AHTTP_/';
foreach($_SERVER as $key => $val) {
if( preg_match($rx_http, $key) ) {
$arh_key = preg_replace($rx_http, '', $key);
$rx_matches = array();
// do some nasty string manipulations to restore the original letter case
@geraintp
geraintp / EmailAsserts.php
Created February 18, 2018 23:13
EmailAsserts Laravel Email test trait
View EmailAsserts.php
<?php
namespace Tests;
use Swift_Message;
trait EmailAsserts
{
protected $emails = [];
@geraintp
geraintp / gist:52547996a7e174fb8424
Created November 22, 2014 16:26
count post_types
View gist:52547996a7e174fb8424
SELECT `post_type`,COUNT(*) FROM `wp_posts` GROUP BY `post_type`;
@geraintp
geraintp / svn-to-git.sh
Last active August 29, 2015 14:02
Shell script to automatically (ish) convert a SVN repo to a a bare GIT repo
View svn-to-git.sh
#!/bin/sh
# based on http://john.albin.net/git/convert-subversion-to-git with a some tweeks
# (NB: its quick and dirty, has no error checking and only works on repos structured with a stdlayout i.e. a trunk folder)
# use:
#
# $:./svn-to-git.sh new-repo-name http://user@server/repo/
BARE_REPO_NAME="$1"
SVN_PATH="$2"
@geraintp
geraintp / fix_for_woo_launch_pad.php
Last active December 28, 2015 05:19
add the following code to your themes functions.php replace woo launch pad's re: http://woothemes.zendesk.com/entries/22733517-Maintenance-Launch-Pad-not-working-as-supposed-
View fix_for_woo_launch_pad.php
<?php // only add this line if you need to! i.e. the file is blank.. and doesnt already start with <?php
/**
* print_custom_html_code_head
* @return void
*/
add_action("init", "fix_launch_pad" , 1);
function fix_launch_pad()
{
global $woodojo_launch_pad;
View gist:7433502
<?
# Prepare the location of the slider's folder to enable movement accross folders
// $path = dirname(__FILE__);
// $path = str_replace('\\', '/', $path);
// $path = str_replace(str_replace('\\', '/', ABSPATH), '', $path);
// $path = trailingslashit(site_url()) . $path;
// $path = trailingslashit($path);
# Fix wrong path code!
$file = str_replace('\\','/', dirname(__FILE__)); // sanitize for Win32 installs