Skip to content

Instantly share code, notes, and snippets.

<?php
namespace App\Providers;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use Doctrine\ORM\Tools\Setup;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\Mapping\Driver\AnnotationDriver;
use Doctrine\Common\Annotations\AnnotationReader;
@clemgrim
clemgrim / SerializerServiceProvider.php
Last active December 1, 2015 10:14
JMSSerializer provider for Silex
<?php
namespace App\Providers;
use Pimple\Container;
use Pimple\ServiceProviderInterface;
use JMS\Serializer\SerializerBuilder;
use Doctrine\Common\Annotations\AnnotationRegistry;
use JMS\Serializer\SerializationContext;
var maxId = setTimeout(function(){}, 0);
for(var i=0; i < maxId; i+=1) {
clearTimeout(i);
}
<?php
/**
* Based on https://gist.github.com/tovic/d7b310dea3b33e4732c0
*/
class Minify
{
public function minifyHtml($html, $processJs = true, $processCss = true)
{
$html = trim($html);
var div = document.createElement('div');
function escapeHtml(unsafe) {
div.innerText = unsafe;
return div.innerHTML;
}
$('.img-responsive').wrap('<div style="display: table-cell" />').parent().wrap('<div style=" display: table;table-layout: fixed;width: 100%;" />');
// layout for only 2 columns
function layout (container, selector) {
var ct = container.jquery ? container : $(container);
var themes = ct.find(selector);
var colLeft = 0;
var colRight = 0;
// resize and position `.theme` elements
themes.each (function (idx) {
var elm = $(this);
<?php
use Imagine\Image\ImageInterface;
use Monolog\Logger;
use Monolog\Handler\StreamHandler;
set_time_limit(60*10);
require 'vendor/autoload.php';
(function () {
var vars = [];
var reserved = [
'$',
'jQuery',
'History',
'Ext',
'CKEDITOR',
'applicationCache',
'caches',
// check if two values are equals (deep check)
function deepEquals(value, other) {
// first, check type
var areEquals = typeof value === typeof other;
if (areEquals) {
if (value instanceof Array && other instanceof Array) { // handle arrays
areEquals = other.length === value.length;
if (areEquals) {