Skip to content

Instantly share code, notes, and snippets.

<?php
$request = <<<EOS
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://schemas.example.com"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<?xml version="1.0"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:tns="urn:order" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap-enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="order"
targetNamespace="urn:order">
<types>
<xsd:schema targetNamespace="urn:order">
<xsd:complexType name="OrderItem">
<xsd:all>
@cmbuckley
cmbuckley / so-8888349.sql
Last active September 29, 2015 15:37
Workaround MySQL solution for http://stackoverflow.com/q/8888349
CREATE TABLE `input` (`dt` DATETIME, `r` INT);
CREATE TABLE `output` (`dt` DATETIME, `r` INT);
LOAD DATA INFILE 'input.log' INTO TABLE `input` FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n';
LOAD DATA INFILE 'output.log' INTO TABLE `output` FIELDS TERMINATED BY ' ' LINES TERMINATED BY '\n';
(SELECT *
FROM `input`
INNER JOIN `output`
ON `output`.`dt` > `input`.`dt` + INTERVAL 5 SECOND
<?php
// file: ./Shape/Circle.php
namespace Shape;
class Circle extends Shape implements ShapeInterface {
public function __construct() {
var_dump($this);
}
@cmbuckley
cmbuckley / annotation.php
Created November 3, 2012 14:26
Erroneous exceptions in PHPUnit for http://stackoverflow.com/q/13198392
<?php
include 'fixture.php';
class AnnotationTest extends PHPUnit_Framework_TestCase {
/**
* @expectedException MyException
*/
public function testExceptionThrown() {
@cmbuckley
cmbuckley / switch-duck.php
Created November 3, 2012 18:08
Duck typing in a switch statement
<?php
$value = 0;
switch ($value) {
case 'hello':
echo 'hello world!';
break;
case '1':
#!/usr/bin/env php
<?php
$filename = ($argc > 1 ? $argv[1] : 'composer.json');
$content = str_replace('\\\\', '\\\\\\\\', file_get_contents($filename));
if (null === ($dependencies = json_decode($content, true))) {
throw new Exception(json_last_error());
}
<?php
// quick and dirty color generator
function getColors($count) {
$colors = array();
for ($i = 0; $i < $count; $i++) {
$colors[] = '#' . substr(md5("color$i"), 0, 6);
}

Keybase proof

I hereby claim:

  • I am cmbuckley on github.
  • I am cmbuckley (https://keybase.io/cmbuckley) on keybase.
  • I have a public key whose fingerprint is BC1C 8E2A FB9B A884 9B76 9234 2A57 C8E4 6506 FABA

To claim this, I am signing this object:

@cmbuckley
cmbuckley / transparent.sh
Last active September 5, 2018 14:56
ImageMagick convert black-on-white to black-on-transparent
convert input.png \( +clone -negate \) -alpha off -compose Copy_Opacity -composite output.png