Skip to content

Instantly share code, notes, and snippets.

@daggerhart
daggerhart / _genCert.sh
Last active Sep 18, 2019
Simple script to generate a certificate used for local development on OSX
View _genCert.sh
#!/bin/bash
read -p 'Domain: ' DOMAIN
openssl req \
-newkey rsa:2048 \
-x509 \
-nodes \
-keyout "$DOMAIN".key \
-new \
@daggerhart
daggerhart / simple-js-template.js
Last active Mar 6, 2018
Simple javascript templating function
View simple-js-template.js
/**
* Very simple non-hierarchical templating engine
*
* @param name
* @param data
*
* @returns string
*/
@daggerhart
daggerhart / auto_entitylabel_eck_support.php
Last active Jul 7, 2017
Drupal 8 - How to add Automatic Entity Label support to ECK (Entity Construction Kit) created bundles
View auto_entitylabel_eck_support.php
<?php
/**
* Implements hook_entity_type_alter().
*/
function example_entity_type_alter(array &$entity_types)
{
foreach ($entity_types as $entity_type) {
if ($entity_type->getProvider() == 'eck' && !is_null($entity_type->getBundleOf())){
$entity_type->setLinkTemplate('auto-label', $entity_type->getLinkTemplate('edit-form') . "/auto-label");
@daggerhart
daggerhart / update-upgrade-reboot-wait.yml
Last active May 24, 2017
Ansible task for Debian/Ubuntu that updates package cache, then as necessary: upgrades, reboots, wait for server to come back up to continue.
View update-upgrade-reboot-wait.yml
# Upgrade Debian/Ubuntu based systems and reboot if necessary.
---
- name: "Update apt-get cache"
apt:
update_cache: yes
- name: "Check if there are packages available to be installed/upgraded"
command: /usr/lib/update-notifier/apt-check --package-names
register: packages
@daggerhart
daggerhart / WordPress Media Library
Last active May 17, 2017
Description of WP Media Library (In comments)
View WordPress Media Library
details in the first comment
@daggerhart
daggerhart / example-drupal-block.php
Last active Apr 21, 2017
WordPress Widget API vs Drupal 8 Block Plugin API
View example-drupal-block.php
<?php
namespace Drupal\example_block\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Block\BlockPluginInterface;
use Drupal\Core\Form\FormStateInterface;
@daggerhart
daggerhart / blog-not-public-admin-notice.php
Created Apr 12, 2017
Very simple WordPress plugin that warns a user if their blog can not be indexed by search engines.
View blog-not-public-admin-notice.php
<?php
/*
* Plugin Name: Blog not public admin notice
* Description: Because this checkbox costs real people real money
* Version: 1.0.0
* Author: daggerhart
*/
add_action( 'wp_ajax_dismiss_blog_not_public_notice', function(){
update_option('blog_not_public_notice_dismissed', 1);
@daggerhart
daggerhart / acf-allow-ui-to-override-local-on-output.patch
Last active Mar 15, 2017
Patch to Advanced Custom Fields 5.5.10 that allows changes to fields in the UI to affect output even if field is "local" JSON or PHP
View acf-allow-ui-to-override-local-on-output.patch
diff --git a/admin/views/field-group-options.php b/admin/views/field-group-options.php
index ae57dfa..c0871b8 100755
--- a/admin/views/field-group-options.php
+++ b/admin/views/field-group-options.php
@@ -127,6 +127,18 @@ acf_render_field_wrap(array(
));
+// db overrides local
+acf_render_field_wrap(array(
@daggerhart
daggerhart / drupal-useful-field-info.php
Last active Aug 22, 2017
Drupal 7 & 8 - useful field info on field management form: required, file uri_scheme, filefield_paths. Drupal 8 version in first comment
View drupal-useful-field-info.php
<?php
/**
* Implements hook_form_FORM_ID_alter().
*
* Indicate some details about the field on the field overview form
*/
function MYMODULE_form_field_ui_field_overview_form_alter(&$form, &$form_state, $form_id) {
$instances = field_info_instances( $form['#entity_type'], $form['#bundle'] );
$fields = field_info_fields();
@daggerhart
daggerhart / examplefilter.module.php
Created Feb 9, 2017
Example Drupal 7 input filter for inserting a node into an arbitrary formatted text field.
View examplefilter.module.php
<?php
/**
* Implements hook_filter_info().
*
* @link https://api.drupal.org/api/drupal/modules%21filter%21filter.api.php/function/hook_filter_info/7.x
*/
function examplefilter_filter_info() {
$filters['examplefilter_node_embed'] = array(
'title' => 'EPI node embed',