Skip to content

Instantly share code, notes, and snippets.

View Chapabu's full-sized avatar

Matt Chapman Chapabu

  • East Sussex, United Kingdom
View GitHub Profile
@Chapabu
Chapabu / example_install.php
Created August 30, 2017 11:46
Revert feature programatically in Drupal 8.
/**
* Revert Blog and Permission features.
*/
function example_update_8005() {
/** @var \Drupal\features\FeaturesManagerInterface $manager */
$manager = \Drupal::service('features.manager');
$manager->import([
'example_roles_permissions',
'example_blog',
]);
@Chapabu
Chapabu / preprocess_block.php
Created October 26, 2016 09:47
Add sensible block template suggestions for Views blocks with long machine names.
// Courtesy of Clive at https://drupal.stackexchange.com/questions/56408/why-block-id-is-generating-with-encrypted-id
/**
* Implements hook_preprocess_block().
*/
function MYTHEME_preprocess_block(&$variables) {
if ($variables['block']->module == 'views') {
// Add some template suggestions that are a little easier to manage than
// the default dom ID added by views.
$delta = $variables['block']->delta;
@Chapabu
Chapabu / drupal_date_formats.php
Created June 16, 2016 10:29
Custom date formats in Drupal 7
/**
* Implements hook_date_formats().
*/
function MODULE_date_formats() {
return [
[
'type' => 'MODULE_standard',
'format' => 'M d, Y',
'locales' => [],
],
@Chapabu
Chapabu / svg-background-with-fallback.scss
Last active November 18, 2015 15:47
Add an SVG background image with a fallback for browsers that don't support SVG.
/// Add an SVG background image with a fallback for browsers that don't support SVG.
/// Note: This requires classes that Modernizr provides.
/// @author Matt Chapman
/// @param {String} $svgPath - The path to the SVG image.
/// @param {String} $pngPath - The path to the PNG image
/// @requires $svgPath
/// @requires $pngPath
/// @link https://gist.github.com/Chapabu/4923ac3a5d81d72a452e - Gist
@mixin svg-background-with-fallback($svgPath, $pngPath) {
@Chapabu
Chapabu / toggle_xdebug.sh
Created August 27, 2015 11:41
Enable and disable xdebug
#! /usr/bin/env bash
PATH_TO_XDEBUG_SETTINGS="/usr/local/etc/php/5.6/conf.d/ext-xdebug.ini"
restart_apache(){
echo "Restarting Apache"
sudo apachectl restart
}
all_done(){
echo "All done!"
{
"viewports": [
{
"name": "phone",
"width": 320,
"height": 480
},
{
"name": "tablet_v",
"width": 568,
@Chapabu
Chapabu / Laravel 5 env providers
Created January 23, 2015 22:00
Binding environment specific providers in Laravel 5
<?php namespace Farm\Providers;
use Illuminate\Support\ServiceProvider;
/**
* Class LocalServiceProviderProvider
*
* Service provider to allow us to register local environment specific providers (i.e. development dependencies).
*
* @package Farm\Providers