Skip to content

Instantly share code, notes, and snippets.

View michaelperrin's full-sized avatar

Michaël Perrin michaelperrin

View GitHub Profile
@michaelperrin
michaelperrin / regex-markdown-example.php
Last active February 10, 2020 16:59
Advanced regex features for Markdown links, example
<?php
$text = 'Text with two links [inline1](https://www.nrk.no) and [inline2](https://www.yr.no), may occur.';
$regex = <<<'REGEX'
(?<text_group> # Text group, including square brackets
\[
(?> # (?> defines an atomic group, this is a performance improvement when using recursion
[^\[\]]+ # Look for any char except closing square bracket
|(?&text_group) # OR: find recursively an other pattern with opening and closing square brackets
@michaelperrin
michaelperrin / apcu.Dockerfile
Last active December 16, 2018 21:43
PHP extension recipes for Docker
FROM php:7.2-fpm
RUN pecl install apcu \
&& docker-php-ext-enable apcu
@michaelperrin
michaelperrin / Dockerfile
Last active February 13, 2017 15:20
Dockerfile to build Symfony documentation with Sphinx
# Usage:
# docker build -t symfony_docs_generator .
# docker run --rm -v `pwd`:/var/www/symfony-docs symfony_docs_generator make html
FROM python:3.6
MAINTAINER Michaël Perrin <contact@michaelperrin.fr>
RUN pip install sphinx~=1.3.0 git+https://github.com/fabpot/sphinx-php.git
# Install LaTeX PDF for PDF build
<?php
/** @Entity **/
class User
{
// ...
}
/** @Entity **/
class Order
{
@michaelperrin
michaelperrin / MyObject.php
Created October 11, 2012 14:57
Singleton class
<?php
class MyObject
{
protected static $instance;
protected function __construct() { }
/**
* Returns an instance of this class
* (this class uses the singleton pattern)