Skip to content

Instantly share code, notes, and snippets.

View hadl's full-sized avatar

Andreas Bibow hadl

View GitHub Profile
@hadl
hadl / alter-twig.php
Last active May 27, 2021 13:47
patternlab node - engine-twig-php extend/alter twig
<?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 July 1, 2020 08:23
Flickity next/prev buttons disable on "last page" when using contain
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 July 1, 2020 08:20
Flickity & Lazysizes
/* 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) {
<?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 April 9, 2019 09:18
[Pimcore 5 Migration] TranslateUpdateTrait
<?php
/**
* TranslateUpdateTrait
*/
use Doctrine\DBAL\Schema\Schema;
/**
* Class TranslateUpdateTrait
*
@hadl
hadl / LanguageSwitcherExtension.php
Last active January 15, 2019 11:14
Pimcore 5 Basic Language Switcher with Twig Extension
/**
* 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 August 2, 2018 14:07
Split mp3 into x seconds parts with ffmpeg
ffmpeg -i file.mp3 -f segment -segment_time 7200 -c copy out%03d.mp3
# -segment_time in seconds
@hadl
hadl / gist:0c35bce6d3de698c92efca5873a557ee
Created April 27, 2016 09:42
Imagemagick convert pngs to progressive jpgs
mogrify -strip -interlace Plane -format jpg -colorspace sRGB -quality 85 *.png
@hadl
hadl / Magento Fix Sendfriend Mail Sender
Created April 16, 2014 09:48
Magento: Fix Sendfriend Mail Sender. You can't send mails from your server with eg. gmail.com as sender mail address!
<?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()));
// good old times
http://www.youtube.com/watch?v=S1ULpM-lTMY