Skip to content

Instantly share code, notes, and snippets.

View veewee's full-sized avatar
👾
Parsing XML

Toon Verwerft veewee

👾
Parsing XML
View GitHub Profile
@veewee
veewee / crop-and-center-background-image.scss
Created March 21, 2014 13:11
Add a background-image to the element and this mixin will make sure that the image is cropped and displayed nicely.
@mixin crop-and-center-background-image($width, $height) {
display: block;
width: $width;
height: $height;
background-position: center center;
background-size: cover;
}
@veewee
veewee / ReferencedDocumentInterface.php
Last active June 12, 2016 13:49
Doctrine MongoDB Event Subscriber to Remove DBRefs of Deleted Documents
<?php
/**
* Interface ReferencedDocumentInterface
*
*/
interface ReferencedDocumentInterface
{
@veewee
veewee / module.config.php
Created March 28, 2014 12:37
Sample custom doctrine hydrator
<?php
return array(
'doctrine-hydrator' => array(
'MyApi\\V1\\Rest\\Assets\\AssetsHydrator' => array(
'entity_class' => 'Application\\Entity\\Asset',
'object_manager' => 'doctrine.documentmanager.odm_default',
'by_value' => true,
'strategies' => [
'categories' => 'DoctrineHydrationModule\Strategy\ODM\MongoDB\EmbeddedReferenceCollection',
'userGroups' => 'DoctrineHydrationModule\Strategy\ODM\MongoDB\EmbeddedReferenceCollection',
@veewee
veewee / list-zf2-routes.sh
Created July 8, 2014 14:58
List all ZF2 routes
php public/index.php config list | grep '^routes\.[a-zA-Z0-9_-.].*\.route'
#!/bin/bash
#
# ./filecount-stats [dir1] [dir2] ...
#
TOTAL_FILES=0
TOTAL_LINES=0
for DIR in "$@"
@veewee
veewee / .htaccess
Created August 5, 2014 15:06
CORS in Apache
# Enable CORS
# with AJAX withCredentials=false (cookies NOT sent)
<IfModule mod_headers.c>
Header always set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Methods "POST, GET, PUT, OPTIONS, PATCH, DELETE"
Header always set Access-Control-Allow-Headers "X-Accept-Charset,X-Accept,Content-Type,Accept,Accept-Charset,x-requested-with,Authorization"
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]]
</IfModule>
@veewee
veewee / BaseControllerSpec.php
Last active May 20, 2018 04:21
A base Phpspec class for Zend Framework 2 controllers.
<?php
namespace spec\Application\Controller;
use PhpSpec\ObjectBehavior;
use PhpSpec\Wrapper\WrapperInterface;
use Prophecy\Argument;
use Prophecy\Prophecy\ProphecyInterface;
use Prophecy\Prophet;
use Zend\Mvc\Controller\PluginManager;
@veewee
veewee / Breadcrumbs.php
Last active August 29, 2015 14:06
Spiffy Navigation - Breadcrumbs view helper
<?php
namespace Application\View\Helper;
use RuntimeException;
use SpiffyNavigation\Page\Page;
use SpiffyNavigation\View\Helper\AbstractHelper;
class Breadcrumbs extends AbstractHelper
{
@veewee
veewee / view-manager.global.php
Created October 1, 2014 08:18
Enable ZF exceptions
<?php
return [
'view_manager' => [
'display_not_found_reason' => true,
'display_exceptions' => true,
],
];
@veewee
veewee / postmessage-tester.html
Created March 24, 2015 09:54
PostMessage tester
<html>
<head>
<script>
var count=0;
function sendMessage() {
window.parent.postMessage(
JSON.stringify({"greeting": "hello world"}), // A stringified message to send.
"*" // The intended origin, in this example we use the any origin wildcard.
);
}