Skip to content

Instantly share code, notes, and snippets.

View juriansluiman's full-sized avatar

Jurian Sluiman juriansluiman

View GitHub Profile
@juriansluiman
juriansluiman / docker-compose.yml
Last active February 26, 2023 17:35
Traefik 2.2 with openvpn failover with udp+tcp protocol
version: '3'
networks:
web:
external: true
bridge:
external: true
services:
traefik:
@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".
@juriansluiman
juriansluiman / comments.tag
Created January 28, 2015 10:49
The react tutorial for riot
<comment-box>
<h1>{ opts.title }</h1>
<comment-list url={ opts.url } comments={ comments } />
<comment-form url={ opts.url } />
this.comments = []
add(comment) {
this.comments.push(comment)
@juriansluiman
juriansluiman / Module.php
Created July 11, 2012 13:14
Set a default locale for your application in Zend Framework 2
<?php
namespace Application;
use Locale;
use Zend\EventManager\Event;
use Zend\ModuleManager\Feature;
class Module implements
Feature\BootstrapListenerInterface
{
@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 / Readme.md
Last active March 17, 2016 09:06
Expl SlmMail

Transport vs service

Service is API client implementation. Does not correspond with any Zend\Mail transport interface. The HTTP transport class is an impl. of the Transport interface, accepting any of the SlmMail API client services. Actually, the SlmMail transport is a bridge between Zend Mail and all supported API service.

  1. Use the transport if you have previously have used Zend\Mail. It enables you to simply swap the Sendmail / SMTP transport and switch instantly to a 3rd party mail service
  2. Use the services if you only need the service implementation and have no need to further utilize Zend\Mail features

Using without Zend\Mail transport

'slm_queue' => [
'worker' => [
'max_runs' => 100,
],
'queues' => [
'default' => [
'deleted_lifetime' => -1
],
],
<?php
class DbResolver implements ResolverInterface
{
protected $adapter;
public function __construct(AuthAdapter $adapter)
{
$this->adapter = $adapter;
}
@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)
{
@juriansluiman
juriansluiman / BarController.php
Last active December 16, 2015 17:49
Standard CRUD methods in Controllers / Services / Repositories for Zend Framework 2
<?php
namespace Foo\Controller;
use Foo\Repository\BarInterface as Repository;
use Foo\Form\BarInterface as Form;
use Foo\Service\BarInterface as Service;
use Foo\Options\ModuleOptions;
use Zend\Mvc\Controller\AbstractActionController;