Skip to content

Instantly share code, notes, and snippets.

@markisatacomputer
markisatacomputer / entity_tag.action.inc
Last active January 4, 2016 07:39
tag entities - vbo custom action
<?php
/*
* Helper function
*/
function entity_tag_action_format_tid_array($tids) {
$formatted = array();
foreach ($tids as $tid) {
if (is_numeric($tid)) {
$formatted[] = array('tid' => $tid);
} else if (is_array($tid) && $tid['tid'] == 'autocreate') {
@markisatacomputer
markisatacomputer / debug_module.views.inc
Last active September 8, 2016 22:07
alter and debug a views query
<?php
/**
* Alters the past events view query to look up event type nodes with a featured program tagged with the contextual filter value
* @param [type] &$view [description]
* @param [type] &$query [description]
* @return [type] [description]
*/
function debug_module_views_query_alter(&$view, &$query) {
if (in_array('after_dark_context_past', $query->options['query_tags'])) {
$value = isset($query->where[0]['conditions'][0]['value'][':field_data_field_event_series_field_event_series_tid1']) ? $query->where[0]['conditions'][0]['value'][':field_data_field_event_series_field_event_series_tid1'] : false;
@markisatacomputer
markisatacomputer / backgroundz.scpt
Last active March 7, 2017 13:32
osx webcam 2 bg
on run argv
tell application "System Events"
set desktopCount to count of desktops
repeat with desktopNumber from 1 to desktopCount
tell desktop desktopNumber
set picture to item 1 of argv
end tell
end repeat
end tell
--beep
@markisatacomputer
markisatacomputer / deploy.sh
Last active August 18, 2017 18:17
deploy changes to pantheon - an attempt to do as little as possible by hand - this way we can test more often
#!/bin/bash
PANTHEON_ENV="$1"
# delete old calendar nodes to free up aliases
echo 'node_delete_multiple(array(13,82,3186,3219,3250,3251,3264,4656,4838,4858,4955,5216,5248,5250,5261,5292,6794,6795,8360,8361,8362,8358,8352,8355,9147));' | drush @pantheon.exploratorium.$PANTHEON_ENV php-script -
# enable features
drush @pantheon.exploratorium.$PANTHEON_ENV en explo_feature_event_calendar_views -y
# revert features
drush @pantheon.exploratorium.$PANTHEON_ENV fr explo_feature_event_type -y
# remove old event views made for after dark
drush @pantheon.exploratorium.$PANTHEON_ENV dis explo_event_views -y
@markisatacomputer
markisatacomputer / export-mongo-to-remote.sh
Created July 1, 2017 23:20
Copy mongo db from local to remote server (container instance with limited memory)
#!/bin/bash
# dump
mongodump -vvv -d hmm-local-beta --gzip --excludeCollection=users --archive=/Path/to/mongo/archive.gz
# old way, container runs out of memory :(
#scp -i ~/.ssh/cert_rsa ~/Path/to/mongo/archive.gz root@[remote host]:/root/import/
##ssh -i ~/.ssh/cert_rsa root@[remote host] "mongorestore -vvv --drop --gzip --stopOnError --archive=/root/import/hmm.gz"
# new way - tunnel - this way we use local memory :)
@markisatacomputer
markisatacomputer / update-aliases.sh
Created July 31, 2017 17:58
Drupal 7 - update url alias for entity bundle and bulk update all aliases for that bundle
#!/bin/bash
ALIAS_PATTERN="$1"
ENTITY_TYPE="$2"
ENTITY_BUNDLE="$3"
PANTHEON_ENV="$4"
drush @pantheon.exploratorium.$PANTHEON_ENV vset pathauto_${ENTITY_TYPE}_${ENTITY_BUNDLE}_pattern $ALIAS_PATTERN
drush @pantheon.exploratorium.$PANTHEON_ENV vset pathauto_update_action 2
SCR=" \$query = new EntityFieldQuery();
\$query->entityCondition('entity_type', '${ENTITY_TYPE}')->entityCondition('bundle', '${ENTITY_BUNDLE}');
\$result = \$query->execute();
@markisatacomputer
markisatacomputer / add_terms.sh
Last active June 27, 2018 18:01
add terms to drupal 7 taxonomy
#!/bin/bash
PANTHEON_ENV="$1"
echo $'$phenomena = array(
"afterimage",
"albedo",
"amplification",
"atoms and particles",
"attention",
"bernouli effect ",
"centripical force",
@markisatacomputer
markisatacomputer / order-emails.php
Last active March 3, 2018 00:06
php shell script for ordering email addresses
#!/usr/local/bin/php
<?php
/**
*
* @param [type] $address1 [description]
* @param [type] $address2 [description]
* @return [type] [description]
*/
function byemail($address1, $address2) {
return strcasecmp(
@markisatacomputer
markisatacomputer / reference-report.sh
Last active May 7, 2018 21:13
Bash script to return a report on referenced nodes
#!/bin/bash
#
# takes an argument of pantheon environment and
# returns output of all entites targeted in entityreference fields
#
#
#
PANTHEON_ENV="$1"
ALL=()