Skip to content

Instantly share code, notes, and snippets.

View chrissnyder2337's full-sized avatar

Chris Snyder chrissnyder2337

View GitHub Profile
@chrissnyder2337
chrissnyder2337 / whiteboardCleaner.md
Created August 14, 2019 20:34 — forked from lelandbatey/whiteboardCleaner.md
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@wanze
wanze / AlterShippingData.php
Last active March 8, 2019 21:06
commerce_google_tag_manager: Example of an AlterEventData event subscriber
<?php
use Drupal\commerce_google_tag_manager\Event\AlterEventDataEvent;
class AlterShippingData implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
'commerce_gtm_enhanced_ecommerce.alter_event_data' => 'addShipping'
];
@wanze
wanze / AlterProductSubscriber.php
Last active March 8, 2019 21:06
commerce_google_tag_manager: Example implementation of an AlterProduct event subscriber
<?php
use Drupal\commerce_google_tag_manager\Event\AlterProductEvent;
class AlterProductSubscriber implements EventSubscriberInterface {
public static function getSubscribedEvents() {
return [
'commerce_gtm_enhanced_ecommerce.alter_product' => 'alterProduct'
];
@devudit
devudit / drupal.dialog.js
Created November 27, 2017 12:32
Create modal window in drupal 8 using Drupal.dialog function
/** EXAMPLE 1 ***/
var $myDialog = $('<div>My dialog text</div>').appendTo('body');
Drupal.dialog($myDialog, {
title: 'A title',
buttons: [{
text: 'Close',
click: function() {
$(this).dialog('close');
}
}]
@zerolab
zerolab / d8_my_advanced_tab.php
Created November 3, 2016 17:18
Drupal 8 move something to the advanced tabs on node forms
<?php
/**
* Implements hook_form_FORM_ID_alter().
*
* Move your field or group of fields to the node form options vertical tabs.
*/
function mymodule_form_node_form_alter(&$form, FormState $form_state, $form_id) {
$form['mygroup'] = [
@raphaellarrinaga
raphaellarrinaga / drupal_8_twig_cheatsheet.md
Last active February 23, 2025 02:49
[Drupal 8 Twig cheatsheet] #tags: drupal8, twig, cheatsheet

Drupal 8 Twig cheatsheet

Please note I created that sheet as a personal side note/draft and not everything is fully tested. There could be errors or better things to do. So if you spot something wrong or something that can be improved, feel free to comment below and I will do the changes.

Getting Drupal 8 field values in Twig

Image path: {{ file_url(content.field_name['#items'].entity.uri.value) }}

@rikki-iki
rikki-iki / drupal-preprocess.theme
Last active February 7, 2023 01:47
Useful preprocess theme functions (may use deprecated php)
<?php
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Template\Attribute;
use Drupal\Core\Url;
use Drupal\node\NodeInterface;
use Drupal\Core\Link;
/**
* Implements hook_preprocess_page() for page.html.twig.

Screen Quick Reference

Basic

Description Command
Start a new session with session name screen -S <session_name>
List running sessions / screens screen -ls
Attach to a running session screen -x
Attach to a running session with name screen -r