Skip to content

Instantly share code, notes, and snippets.

View frederickjh's full-sized avatar

Frederick Henderson frederickjh

  • Hawaiian Acres, HI USA
View GitHub Profile
@frederickjh
frederickjh / RoboConfig.php
Created March 16, 2018 12:58
Robo task runner backup Task and configuration files for Drupal 8, Drush 9 with a composer based workflow.
<?php
#### Configuration for MEOS Drupal 8 Backups with RoboFile
## Site URI
$siteuri='example.com';
## Folder where you want backups to be stored remotely. No trailing slashes!
$remotebackupbasepath='/home/user/backups/squidixvps';
## Remote backup user and server in the form of user@server
@frederickjh
frederickjh / hashsalt.fish
Created March 5, 2018 16:33
Fish shell function for generating hash_salt in a file for use with Drupal 8 websites.
function hashsalt --description 'Generate Drupal 8 hash salt in the current directory in the file, hash_salt.txt. Best to generate in composer project root and ignore in .gitignore. To use this file in settings.php use a line like: $settings[\'hash_salt\'] = file_get_contents(\'../hash_salt.txt\');'
drush eval "print_r(Drupal\Component\Utility\Crypt::randomBytesBase64(55))" > hash_salt.txt
echo 'hash_salt.txt has been generated. Best to generate in composer project root and ignore in .gitignore. To use this file in settings.php use a line like: $settings[\'hash_salt\'] = file_get_contents(\'../hash_salt.txt\');'
end
@frederickjh
frederickjh / themename.theme
Created July 3, 2017 08:07
This the code is from the "DrupalCon Baltimore 2017: Demystifying Rendered Content in Drupal 8 Twig Files" presentation by Amy Vaillancourt-Sals slide 30 "Create a custom file name suggestion". It adds Twig templates for block bundles.
/**
* This code is from the "DrupalCon Baltimore 2017: Demystifying Rendered Content in Drupal 8 Twig Files" presentation by Amy Vaillancourt-Sals slide 30 "Create a custom file name suggestion".
* Video: https://www.youtube.com/watch?v=qoeRpRkGwmk
* Slides: https://drive.google.com/file/d/0B8g8dQw8nc9eV3U4SjZKNWNEWGM/view?usp=sharing
* Drupalcon Baltimore Session: https://events.drupal.org/baltimore2017/sessions/demystifying-rendered-content-drupal-8-twig-files
* This code adds Twig templates for block bundles. Replace "themename" below with your theme's machine name.
* Implements hook_theme_suggestions_HOOK_alter() for templates.
* @param array $suggestions
* @param array $variables
*/
@frederickjh
frederickjh / bad-behavior.make.yml
Created August 22, 2016 21:43
make file to install bad-behavior module and library
api: '2'
core: 7.x
# Specify common subdir of "contrib"
defaults:
projects:
subdir: "contrib"
libraries:
bad-behavior:
download:
type: "file"
@frederickjh
frederickjh / .htaccess
Last active October 20, 2017 09:50 — forked from ScottPhillips/.htaccess
Common .htaccess Redirects
How to force HTTPS using the .htaccess file
To force all web traffic to use HTTPS insert the following lines of code in the .htaccess file in your website’s root folder.
Important:If you have existing code in your .htaccess, add this above where there are already rules with a similar starting
prefix.
# Redirect to SSL version of a site without needing to set the domain name,
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
@frederickjh
frederickjh / install_fish_shell_locally.sh
Last active November 15, 2019 00:18 — forked from eugenesvk/fish_shell_local_install.sh
Installs Fish Shell without root access
#! /bin/bash
# Bash script for installing Fish Shell on systems without root access
# Fish Shell will be installed in $HOME/local/bin
# It's assumed that wget and a C/C++ compiler are installed
set -e # exit on error
FISH_VER=2.2.0
mkdir -p $HOME/local $HOME/fish_shell_tmp # create our directories
cd $HOME/fish_shell_tmp
@frederickjh
frederickjh / tailor_your_backend_to_the_clients_needs-move_the_moderation_state_to_the_actions_region.php
Created March 17, 2015 21:59
Code from slide 49 of "Tailor your backend to meet the clients needs" - move the moderation state to the actions region
<?php
/** Text from slide 49 of "Tailor your backend to meet the clients needs"
* http://www.slideshare.net/stevenvdhout/durable-drupal-backend
* move the moderation state to the actions region
**/
$form['revision_information']['#collapsed'] = TRUE;
if (isset($form['revision_information']['workbench_moderation_state_new'])) {
$form['actions']['workbench_moderation_state_new'] = $form['revision_information']['workbench_moderation_state_new'];
unset($form['revision_information']['workbench_moderation_state_new']);
}
@frederickjh
frederickjh / tailor_your_backend_to_the_clients_needs-improve_the_url_selction_form.php
Created March 17, 2015 21:41
Code from slide 47 of "Tailor your backend to meet the clients needs" - Improve the URL selection form
<?php
/** Text from slide 47 of "Tailor your backend to meet the clients needs"
* http://www.slideshare.net/stevenvdhout/durable-drupal-backend
* Improve the URL selection form
**/
if (isset($form['#entity_type'])
&& $form['#entity_type'] == 'node'
&& isset($form['path'])
&& isset($form['path']['alias'])) {
unset($form['path']['#type']); // remove the fieldset
@frederickjh
frederickjh / tailor_your_backend_to_the_clients_needs-remove_items_from_vertial_tabs_and_add_to_another_fieldset.php
Created March 17, 2015 21:00
Code from slide 45 of "Tailor your backend to meet the clients needs" - remove items from vertical tabs, and add them to another fieldset
<?php
/** Text from slide 45 of "Tailor your backend to meet the clients needs"
* http://www.slideshare.net/stevenvdhout/durable-drupal-backend
* remove items from vertical tabs, and add them to another fieldset
**/
if (isset($form['#groups']['group_settings'])) {
$weight = 0;
foreach ($form as $key => $value) {
if(is_array($value) && isset($value['#group'])) {
unset($form[$key]['#group']);