Skip to content

Instantly share code, notes, and snippets.

View scottrigby's full-sized avatar
🤓

Scott Rigby scottrigby

🤓
View GitHub Profile
@scottrigby
scottrigby / gist:9378414
Created March 5, 2014 22:52
render array: Iframe inside div
$iframe_element = array(
'#type' => 'html_tag',
'#tag' => 'iframe',
'#attributes' => array(
'name' => check_plain('TEST'),
'src' => url('http://google.com', array('html' => TRUE)),
'height' => 200,
'width' => 200,
'id' => drupal_html_id('TEST'),
'class' => drupal_html_class('TEST'),
@scottrigby
scottrigby / unfeaturize.permissions.inc
Created March 7, 2014 06:35
Unfeaturize permissions
<?php
/**
* @file
* Unfeaturize permissions.
*/
/**
* Refactors an implementation of hook_user_default_permissions().
*
@scottrigby
scottrigby / restws_schema-example.md
Last active August 29, 2015 14:05
Example restws_schema variable

The restws_schema module requires a developer to set a restws_schema variable, which defining a custom schema for restws.

See restws_schema_get() for documentation on how this variable should be structured.

Here is an example value:

array(
  'show' => array(
    'label' => 'Show',
@scottrigby
scottrigby / restws_schema_map-example.md
Created August 20, 2014 14:45
Example restws_schema_map variable

The restws_schema module requires a developer to set a restws_schema_map variable, which maps their custom schema to Drupal entities, bundles, and their properties or fields.

This should correspond to the schema defined by the restws_schema variable, and can optionally be created using the UI provided by the included restws_schema_ui module.

See restws_schema_map_get() for documentation on how this variable should be structured.

Here is an example value:

array(
@scottrigby
scottrigby / video_expired.inc
Created April 15, 2015 21:11
Video expired plugin sites/all/modules/custom/nbcuuse_video/plugins/access/video_expired.inc
<?php
/**
* @file
* Plugin to provide access control based on video expiration.
*/
$plugin = array(
'title' => t('Video expired'),
'description' => t('Is this video expired.'),
@scottrigby
scottrigby / s3rten.drush
Last active February 16, 2016 23:22
Drush script shortens files with names that would be too long with s3 bucket added to uri.
#!/usr/bin/env drush
/**
* Shortens files with names that would be too long with s3 bucket added to uri.
*
* Problem:
* - In order to migrate existing files to s3 we must replace existing public://
* and private:// schemes to to s3://BUCKET_NAME/ in the uri column of the
* {file_managed} and {file_managed_revisions} tables.
* - However, some files that previously fit in these uri columns would now be
@scottrigby
scottrigby / EntityMetadateWrapper-isset.md
Last active September 22, 2016 16:38
EntityMetadateWrapper isset

For future ref, the source for this technique can be found on drupal.org:

Atomox commented 2 years ago Trying to load a field on an entity, but an unset field throws an exception, and breaks your page?

There doesn't seem to be a consistent way to check if the field is set. However, try these approaches:

For simple fields, entityMetadataWrappers have extended the isset() to work with simple fields.

Either use isset() as normal, or:

@scottrigby
scottrigby / plistDiff
Created January 7, 2017 22:15
Shows CLI diff between two plist files
#!/bin/bash
## @file
## Shows CLI diff between two plist files.
##
## Normally, Mac plist files are binary, so diffs do not display. However,
## there are cases where seeing diffs is important. For example, when tracking
## changes via Mackup's git storage option.
##
## Note this option allows seeing plist diffs without fully installing Xcode
@scottrigby
scottrigby / plistGitDiff
Created January 7, 2017 22:16
Shows git diff of tracked plist files
#!/bin/bash
## @file
## Shows git diff of tracked plist files.
##
## Normally, Mac plist files are binary, so git diffs do not display. However,
## there are cases where seeing diffs is important. For example, when tracking
## changes via Mackup's git storage option.
##
## @see http://confusatory.org/post/133141617492/git-diff-for-binary-apple-property-list-files
@scottrigby
scottrigby / k8s_charts_bump_dependency_version.sh
Last active September 3, 2017 18:31
kubernetes/charts dependency update script
#!/bin/bash
# @file
# See HELP().
# This script is useful until functionality is adopted into Helm.
#
# Follow @link https://github.com/kubernetes/helm/issues/1947 the issue. @endlink
# Define SCRIPT var for help and validation output.
SCRIPT=`basename ${BASH_SOURCE[0]}`