Skip to content

Instantly share code, notes, and snippets.

@hadl
hadl / alter-twig.php
Last active May 27, 2021
patternlab node - engine-twig-php extend/alter twig
View alter-twig.php
<?php
/**
* @param Twig_Environment $env - The Twig Environment - https://twig.symfony.com/api/1.x/Twig_Environment.html
* @param $config - Config of `@basalt/twig-renderer`
*/
function addCustomExtension(\Twig_Environment &$env, $config) {
$env->addExtension(new \Twig_Extension_Debug());
/**
@hadl
hadl / slider-prev-next-buttons.js
Created Jul 1, 2020
Flickity next/prev buttons disable on "last page" when using contain
View slider-prev-next-buttons.js
import Flickity from 'flickity';
(() => {
const { PrevNextButton } = Flickity;
const parentUpdate = PrevNextButton.prototype.update;
PrevNextButton.prototype.update = function update() {
parentUpdate.call(this);
if (this.parent.slideableWidth < this.parent.size.innerWidth) {
@hadl
hadl / slider-lazysizes.js
Last active Jul 1, 2020
Flickity & Lazysizes
View slider-lazysizes.js
/* eslint-disable no-underscore-dangle,prefer-rest-params */
import Flickity from 'flickity';
(() => {
const oldFlickityCreate = Flickity.prototype._create;
Flickity.prototype._create = function create() {
const that = this;
if (this.element.addEventListener) {
View Color.php
<?php
/**
* Color Input Editable
*/
namespace AppBundle\Model\Document\Tag;
use Pimcore\Model\Document\Tag\Input;
class Color extends Input
@hadl
hadl / TranslateUpdateTrait.php
Last active Apr 9, 2019
[Pimcore 5 Migration] TranslateUpdateTrait
View TranslateUpdateTrait.php
<?php
/**
* TranslateUpdateTrait
*/
use Doctrine\DBAL\Schema\Schema;
/**
* Class TranslateUpdateTrait
*
@hadl
hadl / LanguageSwitcherExtension.php
Last active Jan 15, 2019
Pimcore 5 Basic Language Switcher with Twig Extension
View LanguageSwitcherExtension.php
/**
* Provides get_localized_links function in the Twig.
*
* Class LanguageSwitcherExtension
*/
class LanguageSwitcherExtension extends \Twig_Extension
{
/**
* Pimcore documents service which provide needed methods.
*
@hadl
hadl / gist:892a6ea257fa0c37fd517b150b8fb8dd
Created Aug 2, 2018
Split mp3 into x seconds parts with ffmpeg
View gist:892a6ea257fa0c37fd517b150b8fb8dd
ffmpeg -i file.mp3 -f segment -segment_time 7200 -c copy out%03d.mp3
# -segment_time in seconds
@hadl
hadl / gist:0c35bce6d3de698c92efca5873a557ee
Created Apr 27, 2016
Imagemagick convert pngs to progressive jpgs
View gist:0c35bce6d3de698c92efca5873a557ee
mogrify -strip -interlace Plane -format jpg -colorspace sRGB -quality 85 *.png
@hadl
hadl / Magento Fix Sendfriend Mail Sender
Created Apr 16, 2014
Magento: Fix Sendfriend Mail Sender. You can't send mails from your server with eg. gmail.com as sender mail address!
View Magento Fix Sendfriend Mail Sender
<?php
/**
* Mds_MagentoExtender_Model_Sendfriend_Sendfriend for our extension. Use your own name.
*/
class Mds_MagentoExtender_Model_Sendfriend_Sendfriend extends Mage_Sendfriend_Model_Sendfriend {
public function send()
{
if ($this->isExceedLimit()){
Mage::throwException(Mage::helper('sendfriend')->__('You have exceeded limit of %d sends in an hour', $this->getMaxSendsToFriend()));
View ba >> ET Movie
// good old times
http://www.youtube.com/watch?v=S1ULpM-lTMY