Skip to content

Instantly share code, notes, and snippets.

View juriansluiman's full-sized avatar

Jurian Sluiman juriansluiman

View GitHub Profile
@juriansluiman
juriansluiman / Module.php
Last active December 31, 2015 03:19
A Christmas #zf2 easter egg
<?php
namespace EasterEgg;
use DateTime;
class Module
{
public function onBootstrap(MvcEvent $e)
{
<?php
class DbResolver implements ResolverInterface
{
protected $adapter;
public function __construct(AuthAdapter $adapter)
{
$this->adapter = $adapter;
}
'slm_queue' => [
'worker' => [
'max_runs' => 100,
],
'queues' => [
'default' => [
'deleted_lifetime' => -1
],
],
@juriansluiman
juriansluiman / benchmark-beanstalkd.pull.php
Created January 24, 2014 07:24
Benchmarks ran for comparing Beanstalkd and Gearman
<?php
include 'vendor/autoload.php';
$pheanstalk = new Pheanstalk_Pheanstalk('127.0.0.1');
$pheanstalk->useTube('default');
$n = 1000000;
$start = microtime(true);
@juriansluiman
juriansluiman / Module.php
Created January 30, 2014 09:15
Example how to integrate an EmailService into the ArticleService
<?php
namespace MyEmailThingy;
class Module
{
public function onBootstrap($e)
{
$app = $e->getApplication();
$em = $app->getEventManager();
<?php
namespace MyModule\Service;
use ZfcRbac\Service\AuthorizationService as BaseAuthorizationService;
class AuthorizationService extends BaseAuthorizationService
{
protected $myDependency;
@juriansluiman
juriansluiman / Module.php
Last active August 29, 2015 13:56
Return response on route
<?php
use Zend\Mvc\MvcEvent;
class Module
{
public function onBootstrap($e)
{
$app = $e->getApplication();
$sl = $app->getServiceManager();
$em = $app->getEventManager();
<?php
class MyFactory implements FactoryInterface
{
public function createService()
{
$adapter = // get adapter based on config;
$service = new Service($adapter);
return $service;
}
@juriansluiman
juriansluiman / Tracker.js
Last active June 22, 2021 07:27
Track outbound links and form submits with Google Analytics Universal code
/**
* Create a Tracker module for Google Analytics
*
* This tracker enables to track clicks on links and submits on forms. Usually
* these events will not be recorded as the window.location is changed and the
* request to Google Analytics is cancelled. This module prevents default
* behaviour, tracks the Google Analytics event and then continues the link/submit.
*
* Data attributes are used to augment the event with category/action/label values.
* Use them as "data-track-category", "data-track-action" and "data-track-label".
<?php
namespace Foo;
use Zend\Http\Client as HttpClient;
use Zend\Http\Response as HttpResponse;
use Zend\Http\Exception\ExceptionInterface as HttpException;
use Zend\Json\Json;