Skip to content

Instantly share code, notes, and snippets.

View sanis's full-sized avatar
🔥

Justinas Bolys sanis

🔥
View GitHub Profile
@sanis
sanis / gist:6256559
Created August 17, 2013 11:50 — forked from uu59/gist:2375573
<?php
// http://nob-log.info/2012/04/12/phper-filter-validate-email/
$times = 10000;
$result = array();
// preg_match
// regexp is stolen from:
// https://github.com/php/php-src/blob/master/ext/filter/logical_filters.c#L525
<?php
function strip_word_html(
$text,
$allowed_tags = '<a><ul><li><b><i><sup><sub><em><strong><u><br><br/><br /><p><h2><h3><h4><h5><h6>'
) {
mb_regex_encoding('UTF-8');
//replace MS special characters first
$search = array('/&lsquo;/u', '/&rsquo;/u', '/&ldquo;/u', '/&rdquo;/u', '/&mdash;/u');
$replace = array('\'', '\'', '"', '"', '-');
$text = preg_replace($search, $replace, $text);
@sanis
sanis / CachingBench.php
Last active July 5, 2017 19:04
Just a quick benchmark if it's worth to cache oxid category in redis
<?php
/**
* composer require phpbench/phpbench
* php vendor/bin/phpbench run CachingBench.php --report=default
*/
/*
PhpBench 0.13.0. Running benchmarks.
\CachingBench