Skip to content

Instantly share code, notes, and snippets.

View mchelen's full-sized avatar

Mike Chelen mchelen

View GitHub Profile
@mchelen
mchelen / config
Created January 27, 2016 23:12
~/.ssh/config
Host github.com
IdentityFile ~/.ssh/github.key
@mchelen
mchelen / README.md
Created January 25, 2016 04:20
svg manual test

hello

@mchelen
mchelen / index.php
Last active January 4, 2016 22:44
set option values only if defined
<?php
// pass array of key/value pairs in #options array
// object should set the value if its found
$options = array(
'bar'=>'baz',
'qux'=>'fuzz',
);
<?php
if ()
<?php
namespace Foo;
class XMLToDrupalTest extends \PHPUnit_Framework_TestCase
{
public function provider() {
return array(
'default.xml',
@mchelen
mchelen / data.xml
Created December 29, 2015 22:07
xml with html entities
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE root-element [
<!ENTITY % w3centities PUBLIC
"-//W3C//ENTITIES Combined Set//EN//XML"
"http://www.w3.org/2003/entities/2007/w3centities.ent"
>
%w3centities;
]>
<doc>
<body>Copyright &copy; 2008</body>
@mchelen
mchelen / README
Last active December 30, 2015 03:34
xml with html entities
xmllint success:
xmllint example.xml --loaddtd --noout
xmllint example.xml --loaddtd --dropdtd
@mchelen
mchelen / .gitignore
Last active November 30, 2015 16:33
handling optional logger object with null logger
vendor
<?php
// when no query parameters, don't show any results
function my_module_search_api_query_alter($query) {
// check if we are on the faceted search
// @TODO don't hardcode path
if (current_path() == 'search') {
if (count(drupal_get_query_parameters()) === 0) {
$query->range(0,0);
$query->setOption('skip result count', TRUE);
@mchelen
mchelen / index.php
Created November 20, 2015 19:42
PHP self:: vs static::
<?php
class Foo {
public static function run() {
print('Hello');
}
public static function maybe() {
static::run();
}