Skip to content

Instantly share code, notes, and snippets.

View driskell's full-sized avatar

Jason Woods driskell

View GitHub Profile
<?php
/**
* Load a playlist's videos from the API, or return from the playlist if EXPLICIT
*
* @param \Drupal\brightcove\BrightcovePlaylistInterface<mixed> $entity
* @return array<\Drupal\brightcove\BrightcoveVideoInterface<mixed>>
*/
function load_brightcove_playlist_videos(\Drupal\brightcove\BrightcovePlaylistInterface $entity): array {
// Only perform API lookup for smart playlists - for others the display will render the explicitly linked videos
@driskell
driskell / composer-raise-version-constraints.sh
Last active November 29, 2020 11:53
Raise minimum composer version constraint to match lock file
#!/usr/bin/env php
<?php
// Raise minimum dependency version to that within the lock file
// Be sure to update lock file hash with composer update --lock
$composerJsonPlain = file_get_contents('composer.json');
$composerJson = json_decode($composerJsonPlain, true);
$lockJson = json_decode(file_get_contents('composer.lock'), true);
@driskell
driskell / setphp.sh
Last active November 29, 2020 11:51
Brew helper for switching php versions
# Requires ZSH
# Install your PHP versions via: brew install [email protected]
# Where x.x is the version such as 7.4
# Do not need to link them it's harmless
# Add the below to your .profile or something
# Then run setphp x.x when you need to change php version - it will update php version in all terminal sessions
# Add to PATH to prefer over any system installed
export PATH="$HOME/bin/php:$PATH"
@driskell
driskell / clean_magento_images.py
Last active November 29, 2020 11:51
Clean unused catalog images from the Magento 1 media folder. Run inside the media folder. Supports ability to scan attributes with custom backends.
# yum install mysql-connector-python
import ConfigParser
from contextlib import contextmanager
import getopt
import getpass
import io
from mysql.connector import connection
import os
import re