Skip to content

Instantly share code, notes, and snippets.

View hortongn's full-sized avatar
🧘‍♂️

Glen Horton hortongn

🧘‍♂️
View GitHub Profile
@hortongn
hortongn / delws.sh
Last active August 29, 2015 14:20 — forked from dchandekstark/delws.sh
#!/bin/sh
TYPES="*.rb *.css *.js *.rake"
git ls-files ${TYPES} | xargs sed -E -i "" "s/[[:space:]]+$//g"
@hortongn
hortongn / gist:d81d0e000984c18c771149972f5bf21c
Created November 2, 2018 17:01
Find all works by a user and transfer ownership to another user
work_ids = ActiveFedora::SolrService.query('depositor_ssim:user@example.com', fl: "id", rows: 1000)
new_owner_email = 'user@example.com'
def change_ownership(work_ids, new_owner_email)
work_ids.each do |hash|
pid = hash['id']
work = ActiveFedora::Base.find(pid)
work.depositor = new_owner_email
work.edit_users = [new_owner_email]
@hortongn
hortongn / gist:b842074c8a3cfb0a0c09c6bce4e5e80a
Created November 2, 2018 17:32
Find all works in a collection and update the editors for each work
c = Collection.find('d504rk335')
work_ids = []
c.member_objects.each do |member|
work_ids << member.id
end
new_edit_users = ["user1@example.com", "user2@example.com"]
def change_edit_users(work_ids, new_edit_users)
work_ids.each do |pid|