Skip to content

Instantly share code, notes, and snippets.

View sarahg's full-sized avatar
🏂

Sarah German sarahg

🏂
View GitHub Profile
<?php
// No need to log this script operation in New Relic's stats.
// PROTIP: you might also want to use this snippet if you have PHP code handling
// very fast things like redirects or the like.
if (extension_loaded('newrelic')) {
newrelic_ignore_transaction();
}
$app_info = get_app_info( PANTHEON_ENVIRONMENT );
@sarahg
sarahg / foldersize.php
Created May 6, 2019 20:11 — forked from eusonlito/foldersize.php
PHP function to get the folder size including subfolders
<?php
$folder = $_ENV['HOME'] . '/files';
/**
* Recursive function to retrieve directory + subdirectory sizes.
*
* @param $dir
* Absolute filepath to directory we need to check.
*/
@sarahg
sarahg / fetch-pantheon-logs.sh
Created March 31, 2019 16:53
Continuously fetch log files from Pantheon. Handy when combined with "tail -F" for viewing (almost) real-time log output.
#!/bin/bash
# Usage:
# Run this script to fetch/sync Pantheon log files every
# two seconds. You can change the refresh rate by adjusting
# the "n" argument in the "watch" command.
# Running this script and then "tail -F" on your log file
# will return (nearly) real-time log output.
# Example: tail -F ~/logs/php-error.log
#!/bin/sh
# npm_post.sh
# This script finds any .info files in the node_modules directory and renames them so they don't
# conflict with drush. package.json runs this on completion of npm install.
# These files, if any are not actually needed to run grunt and compile LIbSass
# See this issue for more info: https://www.drupal.org/node/2329453
find -L ./node_modules -type f -name "*.info" -print0 | while IFS= read -r -d '' FNAME; do
mv -- "$FNAME" "${FNAME%.info}.inf0"
@sarahg
sarahg / resume_scp
Created March 28, 2016 15:33
Resume a stalled scp transfer
rsync --partial --progress --rsh=ssh user@host:remote_file local_file
InvalidArgumentException: The URI 'base://From left to right: Monique Coombs - Maine Coast Fishermen’s Association, Taylor Witkin - Eating with the Ecosystem, and Alan Lovewell - Real Good Fish talk about values' is malformed. in Drupal\Core\Url::fromUri() (line 298 of core/lib/Drupal/Core/Url.php).
_pathologic_replace(Array)
preg_replace_callback('~ (href|src|action|longdesc)="([^"]+)~i', '_pathologic_replace', '
Want to Catch Up on the goings on at the LocalCatch.org network's #LocalSeafoodSummit2016?
Check out our Community Organizer Shira Tiffany's <a href=" Monique Coombs - Maine Coast Fishermen’s Association, Taylor Witkin - Eating with the Ecosystem, and Alan Lovewell - Real Good Fish talk about values">blog post</a>.
')
_pathologic_filter('
@sarahg
sarahg / gist:6558f10c9d08a5dd5656
Created February 9, 2016 20:45
Stack trace for Fatal error: Call to undefined function fences_ctools_entity_field_content_type_formatter_options_submit()
#0 /var/www/annenberg/drupal/includes/form.inc(1459): form_execute_handlers('validate', Array, Array)
#1 /var/www/annenberg/drupal/includes/form.inc(1189): _form_validate(Array, Array, 'ctools_entity_f...')
#2 /var/www/annenberg/drupal/includes/form.inc(889): drupal_validate_form('ctools_entity_f...', Array, Array)
#3 /var/www/annenberg/drupal/includes/form.inc(385): drupal_process_form('ctools_entity_f...', Array, Array)
#4 /var/www/annenberg/drupal/sites/all/modules/contrib/ctools/includes/wizard.inc(125): drupal_build_form('ctools_entity_f...', Array)
#5 /var/www/annenberg/drupal/sites/all/modules/contrib/ctools/includes/content.inc(621): ctools_wizard_multistep_form(Array, 'step1', Array)
#6 /var/www/annenberg/drupal/sites/all/modules/contrib/panels/plugins/display_renderers/panels_renderer_editor.class.php(749): ctools_content_form('edit', Array, Array, Array, 'node:title_fiel...', Array, Array, 'step1')
#7 [internal function]: panels_renderer_editor->ajax_edit_pane('18', 'step1')
#8 /var/www/annenberg/d
@sarahg
sarahg / module_list.php
Last active October 14, 2015 18:09
Get a comma-separated list of enabled, non-core Drupal modules.
<?php
/**
* Return a comma-separated list of module machine names.
* This excludes core modules and disabled modules.
*/
$drupal_version = (int) VERSION;
$list_modules_function = '';
if ($drupal_version >= 7 && $drupal_version < 8) {
@sarahg
sarahg / delete_nodes.php
Last active August 29, 2015 14:27
Delete all nodes on a Drupal 8 site. We invoke this using "drush scr" while rolling back migrations as a workaround for migrate-rollback not being fully implemented in D8 yet. Could also be useful for awesome April Fool's Day pranks (just kidding, don't do that).
<?php
$query = \Drupal::entityQuery('node');
// Optionally, add the following line to delete only a certain type of node.
//->condition('type', 'event');
$nids = $query->execute();
$storage_handler = \Drupal::entityManager()->getStorage('node');
$entities = $storage_handler->loadMultiple($nids);
@sarahg
sarahg / gist:41a64aad79d954aa77c3
Created May 12, 2015 18:37
Drupalcon LA | Symfony toolkit notes
Speaker: Ryan Weaver (@weaverryan)
Drupalcon LA | Tuesday | Symfony toolkit
Install Symfony
1. download code (symfony new my_project)
2. start webserver (php app/console server:run)
Make a page
1. create a route (YML file)