Bash script to:
- Iterate all commits made within a Git repository.
- List every object at each commit.
#!/bin/sh | |
timezone="Europe/Zurich" | |
# List of valid timezones: wikipedia.org/wiki/List_of_tz_database_time_zones | |
script="${0##*/}" | |
rootdir=$(cd `dirname "${BASH_SOURCE[0]}"` && pwd) | |
logfile="$script.log" | |
log="$rootdir/$logfile" | |
now=$(TZ=":$timezone" date) | |
# Uncomment 'mailto=' (remove #) to enable emailing the log upon completion | |
#mailto="your@email.com" |
<?php | |
// Here is a sample of the URLs this regex matches: (there can be more content after the given URL that will be ignored) | |
// http://youtu.be/dQw4w9WgXcQ | |
// http://www.youtube.com/embed/dQw4w9WgXcQ | |
// http://www.youtube.com/watch?v=dQw4w9WgXcQ | |
// http://www.youtube.com/?v=dQw4w9WgXcQ | |
// http://www.youtube.com/v/dQw4w9WgXcQ | |
// http://www.youtube.com/e/dQw4w9WgXcQ | |
// http://www.youtube.com/user/username#p/u/11/dQw4w9WgXcQ |
// Enable Devel module and go to /devel/php | |
$nodes = \Drupal::entityQuery("node") | |
->condition('created', strtotime('-30 days'), '<=') | |
->execute(); | |
$storage_handler = \Drupal::entityTypeManager()->getStorage("node"); | |
// $entities = $storage_handler->loadMultiple(); // Delete ALL nodes. | |
$entities = $storage_handler->loadMultiple($nodes); | |
$storage_handler->delete($entities); |
<?php | |
// original source: http://kuwamoto.org/2007/12/17/improved-pluralizing-in-php-actionscript-and-ror/ | |
/* | |
The MIT License (MIT) | |
Copyright (c) 2015 | |
/** | |
* @file | |
* Example code from http://agaric.com/blogs/conditional-fields-paragraphs-using-javascript-states-api-drupal-8. | |
*/ | |
/** | |
* Implements hook_field_widget_WIDGET_TYPE_form_alter(). | |
* | |
* Example of conditional fields in paragraphs for Drupal 8. | |
*/ |
/** | |
* ALL CREDIT GOES TO ORIGINAL CREATOR | |
* @Ronald Speelman | |
* http://moinne.com/blog/ronald/mysql/mysql-lorum-ipsum-generator | |
* | |
* renamed function for simplicity | |
*/ | |
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='STRICT_TRANS_TABLES'; |
function getNodesByTaxonomyTermIds($termIds){ | |
$termIds = (array) $termIds; | |
if(empty($termIds)){ | |
return NULL; | |
} | |
$query = \Drupal::database()->select('taxonomy_index', 'ti'); | |
$query->fields('ti', array('nid')); | |
$query->condition('ti.tid', $termIds, 'IN'); | |
$query->distinct(TRUE); |