Skip to content

Instantly share code, notes, and snippets.

View scottalan's full-sized avatar

Scott Alan Henry scottalan

View GitHub Profile
@scottalan
scottalan / sqlbackup-s3.sh
Created November 4, 2014 15:46
Amazon S3 Database Backup
#!/bin/bash
# Make directories: log and backup at the $DIR.
# Move the '.s3cfg' file to the $DIR as well.
# NOTE: CHANGE ALL VARIABLES TO MATCH YOUR NEEDS!
# The name of the s3 bucket on Amazon.
S3BUCKET="REPLACE_BUCKET_NAME"
/**
* Change content from one input format to another, deleting the old at the end.
*
* @param string $old_format
* Name of the old input format.
* @param string $new_type
* Name of the new input format.
*/
function _myprofile_install_change_input_format($old_format, $new_format) {
// Change the format on all fields.
# - xdebug
RUN echo xdebug.remote_enable=1 >> /etc/php5/conf.d/20-xdebug.ini;\
echo xdebug.remote_autostart=0 >> /etc/php5/conf.d/20-xdebug.ini;\
echo xdebug.remote_connect_back=1 >> /etc/php5/conf.d/20-xdebug.ini;\
echo xdebug.remote_port=9000 >> /etc/php5/conf.d/20-xdebug.ini;\
echo xdebug.remote_log=/tmp/php5-xdebug.log >> /etc/php5/conf.d/20-xdebug.ini;
@scottalan
scottalan / drupal_query_alter.php
Created September 10, 2015 17:03
A crazy Mike Potter hook_views_query_alter()
<?php
/*** Implements hook_views_query_alter().
*/
function oa_media_views_query_alter(&$view, &$query) {
if (($query->base_table == 'file_managed') && (!empty($view->filter['og_group_ref_target_id']->options['exposed']))) {
// Modify file views with space filters to handle media attached to nodes and paragraphs
// Ensure we have a relationship between og_membership and oa_media file
if (!empty($query->table_queue['field_oa_media_file_managed__og_membership'])) {
// Table already exists because user is probably filtering on space already
diff --git a/includes/filesystem.inc b/includes/filesystem.inc
index 0f29036..03a8b5f 100644
--- a/includes/filesystem.inc
+++ b/includes/filesystem.inc
@@ -676,6 +676,8 @@ function drush_scan_directory($dir, $mask, $nomask = array('.', '..', 'CVS'), $c
$key = (in_array($key, array('filename', 'basename', 'name')) ? $key : 'filename');
$files = array();
+ $nomask = array_merge($nomask, array('node_modules', 'bower_components'));
+
@scottalan
scottalan / debug.md
Created March 1, 2016 16:10
Remote Debugging - PHPStorm

Remote Debugging - PHPStorm

PHPStorm Settings

Preferences >> Languages & Frameworks >> PHP >> Servers

Add a server:

Name: mydomain.dev

@scottalan
scottalan / 0_reuse_code.js
Created July 19, 2016 15:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@scottalan
scottalan / check_perm.php
Created July 20, 2016 15:15
Drupal8: Current user
// How to check for permission in Drupal 8
// Get the current user
$user = \Drupal::currentUser();
// Check for permission
$user->hasPermission('access administration menu');
@scottalan
scottalan / get_names.php
Created July 20, 2016 18:31
D8:configFactory - Example
<?php
/**
* Get the names of all categories.

*
* @return array

* A list of existing category IDs.

*/
function wysiwyg_template_category_get_names() {
$names = &drupal_static(__FUNCTION__);
if (!isset($names)) {
@scottalan
scottalan / new_module.md
Last active July 20, 2016 19:40
D8:Adding a new module to a build.
  • If this is a profile you will need to add the module to the PROFILE.info.yml file.
  • To ensure the module is enabled add it to sites/default/config/core.extension.yml
  • Now to actually add the module to the codebase:
  • If using a make file find the PROJECT.make file and add an entry there as well, e.g.,:
 flag:
  download:
    # 2016-7-20
    branch: "8.x-4.x"
revision: eceaa7d