Skip to content

Instantly share code, notes, and snippets.

View grzegorznowak's full-sized avatar
🙊
improving, as always, what else can a man do

Grzegorz Nowak grzegorznowak

🙊
improving, as always, what else can a man do
View GitHub Profile
@grzegorznowak
grzegorznowak / cleanup_syncoid_builds.sh
Created February 12, 2020 08:45
Remove all the syncoid created snapshots. Uses specific syncoid's pattern, so make sure you it doesn't clash with anything else you use
#!/bin/bash
ARR=($(zfs list -t snapshot -o name -s name | grep -i -o ".*@syncoid_build.*"))
for i in "${ARR[@]}"
do
echo "Getting rid of snapshot $i..."
echo "zfs destroy -R $i"
zfs destroy -R "$i"
done
@grzegorznowak
grzegorznowak / gist:6781538
Created October 1, 2013 16:48
How to manipulate Drupal 7's fields, based on entity reference example. Minus validation, duplicates check, etc. Only the core logic. Please comment if you think it's substantially wrong.
$node = node_load($nid);
$node_wrapped = entity_metadata_wrapper('node', $node);
$references = $collection_node->[name_of_reference_field]->value();
// append new reference (note no sanity checks are included with this Gist)
$references[] = node_load($referenced_nid);
$collection_node->field_cards_reference->set($references);
$collection_node->save();