Skip to content

Instantly share code, notes, and snippets.

@silenzium
silenzium / .htaccess
Created October 3, 2017 18:33
.htaccess for symfony 3 projects with LiipImagineBundle (performance boost by serving cached files directly from disc)
# Use the front controller as index file. It serves as a fallback solution when
# every other rewrite/redirect fails (e.g. in an aliased environment without
# mod_rewrite). Additionally, this reduces the matching process for the
# start page (path "/") because otherwise Apache will apply the rewriting rules
# to each configured DirectoryIndex file (e.g. index.php, index.html, index.pl).
DirectoryIndex app.php
# Disabling MultiViews prevents unwanted negotiation, e.g. "/app" should not resolve
# to the front controller "/app.php" but be rewritten to "/app.php/app".
<IfModule mod_negotiation.c>
@silenzium
silenzium / custom-react-toolbox.js
Created March 22, 2017 14:49
Import react-toolbox Components without Styles for use with react-toolbox-themr
export AppBar from 'react-toolbox/lib/app_bar/AppBar';
export Autocomplete from 'react-toolbox/lib/autocomplete/Autocomplete';
export Avatar from 'react-toolbox/lib/avatar/Avatar';
export Button from 'react-toolbox/lib/button/Button';
export BrowseButton from 'react-toolbox/lib/button/BrowseButton';
export IconButton from 'react-toolbox/lib/button/IconButton';
@silenzium
silenzium / objectfit-fallback.js
Last active November 4, 2019 04:36
This is a simple fallback for the object-fit property on responsive images inside picture elements (with srcset and media-query sources). It hides the img on browsers that don't support object-fit and sets the current used image as a background-image with background-size:cover.
$(function() {
'use strict';
// the css selector for the container that the image should be attached to as a background-image
var imgContainer = '.cover-img picture';
function getCurrentSrc(element, cb)
{
var getSrc;
if (!window.HTMLPictureElement) {
@silenzium
silenzium / zf2ClearFormErrors
Last active August 29, 2015 14:14
ZF2 helper function to remove all errors in a form or fieldset recursively
use Zend\Form\FieldsetInterface;
/**
* Remove all errors in a form recursively
* pass a form or a fieldset as parameter
*
* @param FieldsetInterface $form
* @return void
*/
public function clearFormErrors(FieldsetInterface $form)