Skip to content

Instantly share code, notes, and snippets.

View bradjones1's full-sized avatar
🤓

Brad Jones bradjones1

🤓
View GitHub Profile
@bradjones1
bradjones1 / gist:f8c16d640ca8d1f2d559
Last active January 30, 2016 00:21
Log simplesamlphp error info to syslog, for cross-reference to trackID
<?php
/**
* Class error_show
*
* A custom error show method to log some useful additional information.
*/
class error_show {
public static function show($config, $data) {
$additional = $data['error'] + ['cookie-headers' => $_COOKIE];
unset($additional['exceptionMsg']);
@bradjones1
bradjones1 / config.rb
Last active October 5, 2016 16:02
Compass inline svg with string replacement (e.g., for fills)
module Sass::Script::Functions
def inline_svg_image(path, repl = nil)
real_path = File.join(Compass.configuration.images_path, path.value)
svg = data(real_path)
if repl && repl.respond_to?('to_h')
repl = repl.to_h
svg = svg.to_s
repl.each_pair do |k, v|
@bradjones1
bradjones1 / drupal_unit_test.sh
Created March 10, 2016 06:51
Drupal 8 unit test script
#!/usr/bin/env bash
# see https://github.com/docker/compose/issues/374#issuecomment-174506025
set -e
echoerr() { echo "$@" 1>&2; }
echoerr wait-for-port: waiting for port 80 to open
((TIMEOUT=60*15))
@bradjones1
bradjones1 / .gitlab-ci.yml
Created March 10, 2016 06:52
GitLab CI yml for containerized Docker testing
stages:
- test
- spawn
- phpunit
- deploy
- cleanup
build_image:
cache:
untracked: true
global
lua-load /usr/local/etc/haproxy/acme-http01-webroot.lua
ssl-default-bind-ciphers AES256+EECDH:AES256+EDH:!aNULL;
tune.ssl.default-dh-param 4096
debug
defaults
mode http
option log-health-checks
option dontlognull
<?php
/**
* Temporary function to delete fields attached to entities that have already
* been deleted. This assumes there are no deleted fields that need to be
* purged as this won't actually remove their tables in the database. Use with
* caution and only when fully understanding what this does compared to
* field_purge_batch and field_purge_field_storage.
*/
function _fix_missing_entities_during_field_purge() {
diff --git a/src/Composer/Repository/Vcs/GitLabDriver.php b/src/Composer/Repository/Vcs/GitLabDriver.php
index 2044ff70..2d6329c5 100644
--- a/src/Composer/Repository/Vcs/GitLabDriver.php
+++ b/src/Composer/Repository/Vcs/GitLabDriver.php
@@ -203,11 +203,11 @@ public function getDist($identifier)
*/
public function getSource($identifier)
{
- if ($this->gitDriver) {
- return $this->gitDriver->getSource($identifier);
@bradjones1
bradjones1 / bash.sh
Created May 29, 2020 20:10
shim recursion
# Detect broken recursion.
if [ "$1" == "version" ] && [ ! -z "$FRU_DEV_SHIM_RECURSION" ]; then
exit 99
fi
# Use the next occurrence of docker-compose in the path.
DOCKER_COMPOSE=$(which -a docker-compose | sed -n '2p')
FRU_DEV_SHIM_RECURSION=1 docker-compose version 2> /dev/null || ( echo "Cannot find docker-compose; is it installed?" && exit 103)
@bradjones1
bradjones1 / LazyBuilders.php
Last active June 15, 2020 13:45
BigPipe for field items
<?php declare(strict_types=1);
namespace Drupal\bigpipe_field;
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Access\AccessResultInterface;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
@bradjones1
bradjones1 / jsonapi-url-builder.js
Last active January 12, 2022 22:50
Drupal JSON API URL Builder for orbit.js
import {JSONAPIURLBuilder} from "@orbit/jsonapi";
import {QueryExpressionParseError} from "@orbit/data";
export default class DrupalJSONAPIURLBuilder extends JSONAPIURLBuilder {
buildFilterParam(filterSpecifiers) {
const filters = [];
filterSpecifiers.forEach((filterSpecifier, index) => {
if (filterSpecifier.kind === 'passthrough') {