Skip to content

Instantly share code, notes, and snippets.

View woodworker's full-sized avatar
💭
Brömpf!

Martin Holzhauer woodworker

💭
Brömpf!
View GitHub Profile
@woodworker
woodworker / php_switch_hate.php
Created February 17, 2011 14:44
Sometimes i really hate PHP :D
<?php
$a = 0;
switch ($a) {
case 'test':
$b = 'TEST';
break;
default:
$b = 'DEFAULT';
}
<?php
namespace Acme\ContentBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Acme\BaseBundle\Annotations\RDF as RDF;
/**
* Acme\ContentBundle\Entity\Article
*
* @RDF\Type(name="http://schema.org/Article")
@woodworker
woodworker / parseHttpAcceptHeader.php
Last active December 19, 2015 13:59
simple accept header parser
<?php
function parseHttpAcceptHeader($string) {
$pattern = '#(?P<maintype>[a-z\*]*)/(?P<fullsubtype>(?P<subtype>[a-z0-9.\*-]*)([+](?P<submediatype>[a-z]*))?)(;q=(?P<quality>[0-9.]*))?#i';
preg_match($pattern, $string, $matches);
return $matches;
}
$string = 'application/vnd.github.full+json;q=0.8';
@woodworker
woodworker / raw.html
Last active December 20, 2015 18:19
GitHub Bookmark Plugin
<li>
<div class="select-menu js-menu-container js-select-menu">
<span class="minibutton select-menu-button js-menu-target">
Bookmark
</span>
<div class="select-menu-modal-holder js-menu-content js-navigation-container" data-pjax="">
###
# MainData Graph
'0' -> STRING SendString(strings/SendString)
'20' -> INTERVAL RunInterval(core/RunInterval)
'axes' -> KEY ReadAxes(objects/ExtractProperty)
'buttons' -> KEY ReadButtons(objects/ExtractProperty)
RunInterval() OUT -> IN SendString(strings/SendString)
SendString(strings/SendString) OUT -> GAMEPAD ReadGamepad(interaction/ReadGamepad)
ReadGamepad() OUT -> IN GamepadData(core/Split)
GamepadData() OUT -> IN ReadAxes(objects/ExtractProperty)
@woodworker
woodworker / Test_FilterByValue.coffee
Created September 20, 2013 18:57
FilterByBalue test
test = require "noflo-test"
test.component("packets/FilterByValue").
discuss("given the value, indicating the outport of the filtered value").
send.connect("filterValue").
send.data("filterValue", 1).
send.disconnect("filterValue").
discuss("provide some data packets").
send.connect("in").
send.data("in", 0).
♢ packets/FilterByValue
✗ Errored » callback not fired
in given the value, indicating the outport of the filtered value provide some data packets
in packets/FilterByValue
in test/FilterByValue.js
✗ Errored » 6 honored ∙ 1 errored ∙ 1 dropped
@woodworker
woodworker / dic_config.php
Created September 23, 2013 19:41
Sample DIC Config
<?php
return array(
Doctrine\Common\Annotations\AnnotationReader::class => [
'provider' => [
'class' => Acme\Provider\AnnotationReaderProvider::class
]
],
Symfony\Component\HttpFoundation\Request::class => [
'provider' => [
<?php
namespace Acme\Provider;
use Doctrine\Common\Annotations\AnnotationReader;
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver as MdbAnnotationDriver;
use gthm\partlets\system\Config;
use rg\injektor\Provider;
/**
@woodworker
woodworker / PartletHandler.php
Created September 23, 2013 20:05
Sample of preparing and rendering
$this->preparer->prepare($partlet);
$content = $this->render($partlet);
if (is_array($content)) {
return new JsonResponse($content);
} else {
$containerClass = $partlet->getContainerPartlet();
$containerWidget = $this->dic->getInstanceOfClass($containerClass);
$this->preparer->prepare($containerWidget, ['content' => $content]);