Skip to content

Instantly share code, notes, and snippets.

@boekkooi
boekkooi / Regex
Last active August 29, 2015 14:09
PHP RFC3986 regex
<?php
const PATTERN_RFC3986 = '~^
(?<scheme>[a-z][a-z0-9+-\.]*)
://
(?:
(?<userinfo>
([a-z0-9\-\._\~!\$&\'()*+,;=:]|%[0-9a-f]{2})*
)@ # *( unreserved / pct-encoded / sub-delims / ":" )
)?
@boekkooi
boekkooi / ConnectionKeepAlive.php
Last active October 19, 2023 23:17
Doctrine keep alive (MySQL server has gone away)
<?php
namespace Acme\Doctrine\DBAL;
use Doctrine\DBAL\Connection;
declare(ticks = 3000000);
class ConnectionKeepAlive
{
/**
@boekkooi
boekkooi / using
Created January 22, 2014 06:50
Django - A hack to apply custom templates to tags registered using inclusion_tag, this is related to https://code.djangoproject.com/ticket/9093
import sys
import ctypes
import types
from django.template import TemplateSyntaxError, Token, TOKEN_BLOCK
from django.template.defaulttags import register
if sys.version_info < (3,):
cb_func_code = 'func_code'
cb_func_closure = 'func_closure'