Skip to content

Instantly share code, notes, and snippets.

View SpacemanPete's full-sized avatar

Piotr Butkiewicz SpacemanPete

View GitHub Profile
@SpacemanPete
SpacemanPete / brightcove_add_folder_filter.diff
Created November 24, 2020 00:19
Patch for drupal/brightcove module to enable folder filtering for custom enhancement module
diff --git a/src/Plugin/QueueWorker/BrightcovePlaylistQueueWorker.php b/src/Plugin/QueueWorker/BrightcovePlaylistQueueWorker.php
index 35fadb7..69dd27c 100644
--- a/src/Plugin/QueueWorker/BrightcovePlaylistQueueWorker.php
+++ b/src/Plugin/QueueWorker/BrightcovePlaylistQueueWorker.php
@@ -78,7 +78,7 @@ class BrightcovePlaylistQueueWorker extends QueueWorkerBase implements Container
BrightcovePlaylist::createOrUpdate($playlist, $this->playlistStorage, $this->videoStorage, $data['api_client_id']);
}
catch (\Exception $e) {
- throw new RequeueException($e->getMessage(), $e->getCode(), $e);
+ \Drupal::logger('brightcove_extras')->error('Playlist update error. Video does not exist locally.');
@SpacemanPete
SpacemanPete / gist:c6f576f3a176f7d2b8eb6784a1ab0c5f
Last active October 13, 2020 00:21
Adding first/last/odd/even classes to a twig loop in Drupal 8
{# Borrowed some syntax from https://gist.github.com/NikLP/cb9adc963036d1ffd8896928de2b9b7a and expanded upon it. #}
<div{{ attributes.addClass('container') }}>
{% for item in items %}
{# NB! notation: loop.index is 1 start, loop.index0 is zero start. #}
{# Add first/last/odd/even classes to elements in loop #}
{# odd/even #}
{% set loopClasses = [] %}
{% if loop.index is odd %}
{% set loopClasses = loopClasses|merge(["odd"]) %}
@SpacemanPete
SpacemanPete / Contract Killer 3.md
Created April 12, 2017 21:45 — forked from malarkey/Contract Killer 3.md
The latest version of my ‘killer contract’ for web designers and developers

Contract Killer

The popular open-source contract for web professionals by Stuff & Nonsense

  • Originally published: 23rd December 2008
  • Revised date: March 15th 2016
  • Original post

@SpacemanPete
SpacemanPete / urlobject.js
Last active November 13, 2015 21:28 — forked from aymanfarhat/urlobject.js
I changed the **decodeURI** method for decoding the search parameters to **decodeURIComponent** to match the encoding iplementation I'm using on a project, **decodeURI** alone didn't handle commas. Also added regex to replace the '+' encoded by Jquery's $.param() search encoding method. Surprising they don't have an easy $.deparam() method to ac…
// **********************************************************************************
//
// Javascript utility to parse page URL into Javascript Object for easy manipulation
//
// Written by: aymanfarhat
//
// Source: https://gist.github.com/aymanfarhat/5608517
//
// Dependencies:
// none