Skip to content

Instantly share code, notes, and snippets.

@rafaelbiriba
rafaelbiriba / tree-report.sh
Last active March 7, 2024 03:19
Generate tree report file on NAS and send it by email (optional)
#!/bin/bash
# Creates DISK0.tree, DISK1.tree, DISKx.tree inside each disk, with the output of tree command.
# After generating the report, it send via email using mail.
# To add more disks, just add DISK[x]=/full/path to the disk. Just make sure that the array index are sequencial.
# Why this?
# With the reports from tree, in case of disk failure, you will know which file got lost and you can recover them, downloading or via backups.
# GIST: https://gist.github.com/rafaelbiriba/0ee7ca2baec1ef80a878c825295f09e1
EMAIL_ADDRESS="" # EMAIL_ADDRESS="email@gmail.com" or leave it blank "" to disable email
DISKS[0]="/srv/dev-disk-by-id-ata-WDC_WD80EMAZ-00WJTA0_ABC123-part1"
@DavidWells
DavidWells / netlify.toml
Last active February 7, 2024 08:50
All Netlify.toml & yml values
[Settings]
ID = "Your_Site_ID"
# Settings in the [build] context are global and are applied to all contexts unless otherwise overridden by more specific contexts.
[build]
# This is the directory to change to before starting a build.
base = "project/"
# NOTE: This is where we will look for package.json/.nvmrc/etc, not root.
# This is the directory that you are publishing from (relative to root of your repo)
@richshea
richshea / AlmaPermalink.php
Last active June 21, 2018 22:47
Permalink to Primo using Alma MMS ID
@opi
opi / drupal8_views_exposed_form_theme_suggestions.php
Created November 28, 2017 11:13
Drupal8 - Custom views exposed form suggestions
<?php
/**
* Implements hook_theme_suggestions_HOOK_alter().
*/
function MYTHEME_theme_suggestions_views_exposed_form_alter(array &$suggestions, array $vars) {
// form[#id] pattern is views-exposed-form-VIEWNAME-DISPLAY
// We need to remove the 'views-exposed-form-' part
// and to replace underscores with dashes
$suggestions[] = 'views_exposed_form__' . str_replace(
@swichers
swichers / rebuild_field_map.d8.drush.inc
Created November 23, 2017 00:07
drush 8 command to rebuild Drupal 8 field mappings
<?php
/**
* @file
* Drush command implementation for rebuild-field-map.
*
* This will allow rebuilding the field mapping stored in the key value store
* for a given entity type. This is helpful when trying to repair a corrupted
* field map store without having to add and remove fields.
*/
@slucero
slucero / BlockContentPlacementSubscriber.php
Created May 22, 2017 19:24
YAML Content - Block Placement Event Subscriber
<?php
namespace Drupal\yaml_content\EventSubscriber;
use Drupal\block\Entity\Block;
use Drupal\block_content\Entity\BlockContent;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Entity\EntityStorageException;
use Drupal\yaml_content\Event\EntityPostSaveEvent;
use Drupal\yaml_content\Event\YamlContentEvents;
@jibran
jibran / FileEntity.php
Created March 24, 2017 00:39
Migrating Drupal 7 File Entities to Drupal 8 Media Entities
<?php
// modules/custom/my_custom_module/src/Plugin/migrate/source/FileEntity.php
namespace Drupal\my_custom_module\Plugin\migrate\source;
use Drupal\Core\Database\Query\Condition;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
/**
* Drupal 7 file_entity source from database.
@keithws
keithws / mkto.form.listener.html
Last active November 22, 2023 18:59
Marketo Form Listener for Google Tag Manager (GTM)
<script>
/**
* push events to Google Tag Manager when the Marketo Forms 2 Javascript is
* loaded and executed and when Marketo form events occur
* uses the Marketo Forms 2.0 API
* http://developers.marketo.com/documentation/websites/forms-2-0/
*
* @author Keith W. Shaw <keith.w.shaw@gmail.com>
* @license MIT
*/
@Eyal-Shalev
Eyal-Shalev / ComboForm.php
Created June 7, 2016 19:41
An example form object (Drupal 8) that combines multiple forms into itself.
<?php
namespace Drupal\sandbox\Form;
use Drupal\Core\Form\FormBase;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormState;
use Drupal\Core\Form\FormStateInterface;
use Drupal\node\Entity\Node;
use Drupal\user\Entity\User;