Skip to content

Instantly share code, notes, and snippets.

weaver299

Block or report user

Report or block weaver299

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:a773df126383d472eac398f2a7577a15
function ffclip {
# some links about calculating durations in bash
# https://stackoverflow.com/questions/8903239/how-to-calculate-time-difference-in-bash-script
# http://giantdorks.org/alain/script-to-calculate-clip-duration-from-startstop-times/
# http://giantdorks.org/alain/bash-script-to-calculate-duration-between-two-time-stamps-and-also-report-minutes-hours-days-weeks-months-and-years/
# http://www.daveeddy.com/2014/06/29/human-readable-duration-in-bash/
# https://gist.github.com/bezhermoso/2d61cf44646c2f07c0820d81c644c1de
if [ "$#" -lt 3 ]; then
echo "Usage: ffclip <file> <start> <finish>";
View migrate_plus.migration.media_youtube.yml
id: media_youtube
label: Migrate Youtube Videos
description: Migrate Youtube Videos
migration_group: media
migration_tags:
- Custom
source:
plugin: file_entity
View migrate_plus.migration.users.yml
id: users
label: User Migration
source:
key: source_db
plugin: d7_user
destination:
plugin: entity:user
process:
View FileEntity.php
<?php
namespace Drupal\asc_migrate_standardd7\Plugin\migrate\source;
use Drupal\Core\Database\Query\Condition;
use Drupal\migrate\Row;
use Drupal\migrate_drupal\Plugin\migrate\source\d7\FieldableEntity;
/**
* Drupal 7 file_entity source from database.
*
View migrate_plus.migration.media_images.yml
id: media_images
label: Migrate image file entities
description: Migrate image file entities
migration_group: media
migration_tags:
- Custom
source:
plugin: file_entity
View migrate_plus.migration.media_files.yml
id: media_files
label: Migrate managed files
description: Migrate managed files
migration_group: media
migration_tags:
- Drupal 7
- Content
migration_dependencies:
required:
@weaver299
weaver299 / Dfence.php
Last active Jan 22, 2019
defensive programming
View Dfence.php
<?php
if (empty($json_object->fields) && empty($json_object->field_deltas)) {
echo "Embedded Reference -- fields NO, field_deltas NO.\n";
print_r($json_object);
die();
}
else if (!empty($json_object->fields) && empty($json_object->field_deltas)) {
echo "Embedded Reference -- fields YES, field_deltas NO.\n";
}
View generate-db-config.sh
gen_dev_config() {
if [[ -z "$1" ]]; then
echo "Usage: gen_site_config <site_name>";
echo;
return 1;
fi
password=$(</dev/urandom tr -dc '0-9!@#$%a-zA-Z' | head -c16; echo "");
underscores=$(echo "$1" | sed 's/\./_/g' | sed 's/-//g');
dev_underscores=$(echo "dev_$underscores");
@weaver299
weaver299 / bash_escaping.sh
Last active Sep 5, 2018
Can't output desired string with "..." in bash??
View bash_escaping.sh
#!/usr/bin/env bash
# This outputs "\$conf" as desired
echo $'s/^(\\$conf\\[\'simplesamlphp_auth_installdir\'\\] = .*)/if(whatever){ $1 } else { whatever };/'
# Yes, it can also be done with this craziness
echo 's/^(\$conf\['"'"'simplesamlphp_auth_installdir'"'"'\] = .*)/if(whatever){ $1 } else { whatever };/'
# But it doesn't seem to be possible with "..." ?
echo "s/^(\$conf\['simplesamlphp_auth_installdir'\] = .*)/if(whatever){ \$1 } else { whatever };/"
View gist:e44185e548196db038afcfba145c11c2
check_redirect () {
echo -n "$1: ";
curl -is "$1" | grep '^Location:' | perl -pe 's/^Location: //;chop;'
echo;
}
You can’t perform that action at this time.