Skip to content

Instantly share code, notes, and snippets.

View Saeven's full-sized avatar

Alexandre Lemaire Saeven

View GitHub Profile
@Saeven
Saeven / MultibyteGuard.php
Created March 23, 2017 16:26
MultibyteGuardFilter
<?php
namespace LDP\Form\Filter;
class MultibyteGuard implements \Zend\Filter\FilterInterface
{
public function filter($value)
{
if (!mb_check_encoding($value, 'utf-8')) {
$value = '';
@Saeven
Saeven / IndexControllerSpec.php
Created March 1, 2017 17:12
Sample dispatch test
<?php
namespace Spec\Application\Controller;
use Application\Controller\Plugin\JsonWrapper;
use Application\Entity\User;
use Application\Mapper\ConfigurationMapper;
use Application\Mapper\CouponMapper;
use Application\Mapper\UserServerPlanMapper;
use Application\Service\CartService;
@Saeven
Saeven / doctrine_memcached.php
Last active February 25, 2017 05:09
Doctrine & Memcached
<?php
/*
* Typical database config
*/
// ....
'doctrine' => [
@Saeven
Saeven / # php70 - 2016-09-26_21-45-45.txt
Created September 27, 2016 01:53
php70 (josegonzalez/php/php70) on macOS 10.11.6 - Homebrew build logs
Homebrew build logs for josegonzalez/php/php70 on macOS 10.11.6
Build date: 2016-09-26 21:45:45
@Saeven
Saeven / saeven.lua
Last active June 16, 2022 14:50
Hammerspoon script to launch and tile apps
local workApplications = { 'Mail','HipChat','PhpStorm','Safari','Charles'}
local workApplicationWatcher;
hs.hotkey.bind({"cmd", "alt", "ctrl"}, "H", function()
hs.notify.new({title="Hammerspoon", informativeText="Setting home layout"}):send()
local homeMonitor = "LG ULTRAWIDE"
local windowLayout = {
{"PhpStorm", nil, homeMonitor, {x=0, y=0, w=0.6, h=1}, nil, nil},
{"Charles", nil, homeMonitor, {x=0.6, y=0.6, w=0.4, h=0.4}, nil, nil},
@Saeven
Saeven / LazyControllerFactory.php
Last active April 11, 2016 20:45
Lazy controller factory that auto-injects dependencies based on controller params.
<?php
class LazyControllerFactory implements AbstractFactoryInterface
{
/**
* Determine if we can create a service with name
*
* @param ServiceLocatorInterface $serviceLocator
* @param $name
@Saeven
Saeven / AbstractControllerFactory.php
Created March 9, 2016 20:28
Abstract controller factory test, to help the migration to zend-mvc 2.7.1 that removes the service locator entirely.
namespace Application\Factory\Controller;
use Zend\ServiceManager\AbstractFactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
class AbstractControllerFactory implements AbstractFactoryInterface
{
/**
* Determine if we can create a service with name
@Saeven
Saeven / PHP Mcrypt AES-256
Created January 11, 2016 18:14
AES-256 should not be confused with Rijndael-256.
<?php
class Foo
{
const COOKIE_KEY = '839914B48AE583605F004C784FEF155B39A2C142AD7A747582160E6C14E7EF16';
const COOKIE_IV = '864C9BB8032792391B88C76CF73276F2';
public function encrypt( $what )
{
@Saeven
Saeven / Bootstrap.php
Last active August 29, 2015 14:24
Adjusted Bootstrap for ZF 2.5 that goes straight to zend-loader rather than the old autoloader factory path.
protected static function initAutoloader()
{
$vendorPath = static::findParentPath('vendor');
if (file_exists($vendorPath . '/autoload.php')) {
include $vendorPath . '/autoload.php';
}
include $vendorPath . '/zendframework/zend-loader/src/AutoloaderFactory.php';
AutoloaderFactory::factory(array(
/**
* Class UserFormFactory
* @package CirclicalUser\Factory\Form
*/
class UserFormFactory implements FactoryInterface, MutableCreationOptionsInterface
{
/**
* @var array
*/