Skip to content

Instantly share code, notes, and snippets.

View mchelen's full-sized avatar

Mike Chelen mchelen

View GitHub Profile
@mchelen
mchelen / index.php
Last active January 17, 2017 16:36
multidimensional array dedupe
<?php
$array = [
0 => [
'id' => 'a'
],
1 => [
'id' => 'b'
],
<?php
public function testException() {
$this->expectExceptionMessage('DOMDocument::loadXML(): Opening and ending tag mismatch: baz line 3 and root in Entity, line: 4');
// invalid xml
$xml = '<root>
<foo>bar</foo>
<baz>
<?php
// php array union
// http://php.net/manual/en/language.operators.array.php
$foo = [
'bar',
'baz',
'qux',
];
@mchelen
mchelen / _my_view.html.erb
Last active November 7, 2016 14:37
ruby helper
<%= something do-%>
<h4>hello world</h4>
<% end -%>
$ composer exec phpunit test/SampleTest.php
PHPUnit 5.5.5 by Sebastian Bergmann and contributors.
.. 2 / 2 (100%)
Time: 10 ms, Memory: 4.00MB
OK (2 tests, 6 assertions)
@mchelen
mchelen / Foo.php
Created September 28, 2016 13:23
<?php
namespace Example;
class Foo {
private $logger;
__construct (\Psr\Log\LoggerInterface $logger = new \Psr\Log\NullLogger()) {
$this->logger = $logger;
}
public function bar($baz) {
$this->logger->addDebug($baz);
{
"data": [
{
"id": "1",
"title": "foo"
},
{
"id": "2",
"title": "bar"
},
@mchelen
mchelen / gist:3b908ec4b371b329352524bfdee570af
Last active August 30, 2016 17:24
Pipe cookie between curl commands

pipe cookie output to stdout with -c - and then read cookie from stdin with -b @-

curl -d "[email protected]&password=password" localhost:3000/login -c - | curl -b @- localhost:3000/account
drush mi acme --update
Invalid argument supplied for foreach() Iterator.php:26 [warning]
InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded with an array of [error]
values. in Drupal\Core\Database\Connection->expandArguments() (line 714 of
/var/www/html/drupal/web/core/lib/Drupal/Core/Database/Connection.php).
Placeholders must have a trailing [] if they are to be expanded with an array of values. [error]
(/var/www/html/drupal/web/core/lib/Drupal/Core/Entity/Sql/SqlContentEntityStorage.php:770)
Invalid argument supplied for foreach() Iterator.php:26 [warning]
InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded with an array of [error]
values. in Drupal\Core\Database\Connection->expandArguments() (line 714 of
$(document).ready(function(){
$('.pledge_submit').click(function () {
console.log("foo");
$('.pledge_modal_screen1').hide();
$('.pledge_modal_screen2').show();
});
});