Skip to content

Instantly share code, notes, and snippets.

View wjzijderveld's full-sized avatar

Willem-Jan Zijderveld wjzijderveld

View GitHub Profile
@wjzijderveld
wjzijderveld / vault-merge.sh
Last active February 20, 2019 10:16 — forked from benzado/vault-merge.sh
A shell script for merging encrypted Ansible vault files in a git repository
#!/bin/sh
set -euo pipefail
# vault-merge
# Benjamin Ragheb <ben@benzado.com>
# This shell script handles conflicts generated by attempts to merge encrypted
# Ansible Vault files. Run `git merge` as usual; when git warns of a merge
# conflict, run this command to attempt a merge on the unencrypted versions of
@wjzijderveld
wjzijderveld / .weechat-naughty-notifier.conf
Created October 16, 2015 11:25
Weechat notifier config
# ~/.weechat-naughty-notifier.conf
variables:
blue: "#0060a0"
gray: "#606060"
green: "#00a020"
purple: "#600060"
red: "#a00020"
color_default: ${green}
@wjzijderveld
wjzijderveld / keybase.md
Created October 8, 2014 07:32
keybase.md

Keybase proof

I hereby claim:

  • I am wjzijderveld on github.
  • I am wjzijderveld (https://keybase.io/wjzijderveld) on keybase.
  • I have a public key whose fingerprint is 6F51 FBF3 BA51 8264 9038 DAD6 BC36 7471 B018 E4E6

To claim this, I am signing this object:

<?php
// assumes $form available and $this->validator injected
// ConstraintViolationList
$violationList = $this->validator->validate($form);
$violationMapper = new ViolationMapper();
foreach ($violationList as $violation) {
$violationMapper->mapViolation($violation, $form);
}
<?php
function xpathEscape($query,$default_delim = '"')
{
if((strpos($query,'\'') !== FALSE) ||
(strpos($query,'"') !== FALSE))
{
$quotechars = array('\'','"');
$parts = array();
$current_part = '';
@wjzijderveld
wjzijderveld / gist:4167640
Created November 29, 2012 08:45
Doctrine: SingleTable Inheritance, ClassMetaData, APC problem
I'll try to explain:
We have ProductTaxonomyTerm and CategoryTaxonomyTerm, which both extend BaseTaxonomyTerm.
BaseTaxonomyTerm is configured with SingleTableInheritance with a discriminator column type.
Local env works without issues, but on our staging it sometimes happens, that the ClassMetaData is 'corrupt'.
The Base/Category (in this example) metadata looks fine (when I look at the value stored in APC), but the ProductTaxonomyTerm has no parentClasses defined anymore (in ClassMetadata).
Apache graceful (APC clear) solves the issue, but only half. The problem re-arises on another website (we have a mutli-site solution), which site it is, seems pure random.
The missing parentClasses causes, that Doctrine generates a faulty SQL query (empty WHERE IN()).
@wjzijderveld
wjzijderveld / SoapClientTimeout.class.php
Created October 27, 2012 11:13 — forked from RobThree/SoapClientTimeout.class.php
PHP SoapClient with timeout
<?php
//Drop-in replacement for PHP's SoapClient class supporting connect and response/transfer timeout
//Usage: Exactly as PHP's SoapClient class, except that 3 new options are available:
// timeout The response/transfer timeout in milliseconds; 0 == default SoapClient / CURL timeout
// connecttimeout The connection timeout; 0 == default SoapClient / CURL timeout
// sslverifypeer FALSE to stop SoapClient from verifying the peer's certificate
class SoapClientTimeout extends SoapClient
{
private $timeout = 0;
private $connecttimeout = 0;