Skip to content

Instantly share code, notes, and snippets.

View jameswilson's full-sized avatar

James Wilson jameswilson

View GitHub Profile
@nsciacca
nsciacca / #github-to-acquia
Last active May 5, 2023 22:48
GitHub to Acquia workflow recipe and helper scripts
Project structure:
.github/workflows/deploy-acquia.yml
scripts/ci/push.sh
scripts/composer/ScriptHandler.php
.gitignore
composer.json
@datvance
datvance / install-libraries.php
Created January 20, 2022 15:56
A composer post-update/post-install command to find, download, copy, whatever front-end library files specified in a drupal module's "composer.libraries.json" file (which is non-standard).
<?php
/**
* A hack.
*
* A composer post-update/post-install command to find, download, copy, whatever front-end library files
* specified in a drupal module's "composer.libraries.json" file (which is non-standard). This is a replacement
* for the wikimedia/composer-merge-plugin package which is deprecated and causes issues on Pantheon
* See: https://www.drupal.org/project/webform/issues/3088336#comment-13312823
* And: https://www.drupal.org/project/documentation/issues/2605130
@peterlozano
peterlozano / lambda @ edge
Last active April 6, 2018 22:52
Redirect to www domain using AWS CloudFront Lambda @ Edge. Attach this function to the Viewer Request event.
exports.handler = (event, context, callback) => {
const request = event.Records[0].cf.request;
if (request.headers['host'][0].value !== 'www.example.com') {
/*
* Generate HTTP redirect response with 302 status code and Location header.
*/
const response = {
status: '302',
statusDescription: 'Found',
@WengerK
WengerK / databaseService.php
Created September 4, 2017 09:46
Drupal 8 - Print raw SQL queries for debugging
<?php
/**
* Debugging using the database connection.
*/
/** @var \Drupal\Core\Database\Connection */
$connection = \Drupal::service('database');
$query = $connection->select('node', 'node');
$query->fields('node', ['nid'])
@frjo
frjo / contact.php
Last active January 20, 2023 07:22
PHP script for contact form
<?php
// Set the e-mail address that submission should be sent to.
$address = 'info@example.com';
// Set the e-mail subject prefix.
$prefix = 'Website feedback';
// DO NOT EDIT ANYTHING BELOW UNLESS YOU KNOW WHAT YOU ARE DOING.
@peterlozano
peterlozano / drupal_8_send_email.php
Created June 23, 2016 14:03
Sending mail from drupal 8
<?php
// To be passed to hook_mail
$params = array();
// To be passed to hook_mail
$key = 'my_mail_key';
$langcode = \Drupal::languageManager()->getDefaultLanguage();
\Drupal::service('plugin.manager.mail')
@jameswilson
jameswilson / MrMoneyMustache.css
Last active December 10, 2015 14:32
MrMoneyMustache.com CSS file for GreaseMonkey Script https://greasyfork.org/en/scripts/13870-mr-money-mustache
body {
background: #fff;
}
.postbg {
background: transparent;
box-shadow: none;
}
.header_area {
@jameswilson
jameswilson / pager.tpl.php
Last active August 19, 2020 15:42
Drupal 7 Accessible Pager (Backport from Drupal 8)
<?php
// Place this file your theme's "templates" folder.
/**
* @file
* Theme override to display a pager.
*
* This is a backport of pager.html.twig from Drupal 8 to Drupal 7, which add
* accessibility support for WCAG 2.0 section 2.4.9.
*
@joelpittet
joelpittet / _autocomplete.base.scss
Last active August 29, 2015 14:06
Throbber replacement
// Animated throbber
html.js .form-autocomplete {
background-image: image-url('svg/throbber-inactive.svg');
background-position: 95% center;
background-position: -webkit-calc(100% - 5px) center;
background-position: calc(100% - 5px) center;
background-repeat: no-repeat;
}
html.js .throbbing {
@jameswilson
jameswilson / columns.css
Created August 1, 2014 22:53
Columns based on number of siblings
/**
* Technique from http://lea.verou.me/2011/01/styling-children-based-on-their-number-with-css3/
*/
/* one item */
li:first-child:nth-last-child(1) {
width: 100%;
}
/* two items */