Skip to content

Instantly share code, notes, and snippets.

View cjcolvar's full-sized avatar

Chris Colvard cjcolvar

  • Bloomington, IN
View GitHub Profile
@cjcolvar
cjcolvar / gist:b56aa87848d6cc519a3f7c36cd24db56
Created June 23, 2016 15:22
Options for determining what migrations need to be run
[cjcolvar@localhost avalon]$ bundle exec rake db:version
Current version: 20160511155417
[cjcolvar@localhost avalon]$ bundle exec rake db:migrate:status
database: /home/cjcolvar/Code/avalon/avalon/db/development.sqlite3
Status Migration ID Migration Name
--------------------------------------------------
up 20120202180525 Devise create users
up 20120202180540 Create searches
@cjcolvar
cjcolvar / example.vtt
Created March 9, 2016 15:41
Example vtt file for testing
WEBVTT
1
00:00:01.000 --> 00:00:10.000
This is the first line of text, displaying from 1-10 seconds
2
00:00:15.000 --> 00:00:20.000
And the second line of text
separated over two lines
@cjcolvar
cjcolvar / gist:7479811
Created November 15, 2013 05:58
Commands I used to zero out space on a virtual disk from the host without running the guest vm
#Magic to zero out space on host without running guest
modprobe nbd max_part=16
qemu-nbd -c /dev/nbd0 /home/cjcolvar/VirtualBox\ VMs/avalon-installer_default_1383930303/box-disk1.vdi
partprobe
vgchange -a y VolGroup
zerofree /dev/mapper/VolGroup-lv_swap
zerofree /dev/mapper/VolGroup-lv_root
vgchange -a n VolGroup
qemu-nbd -d /dev/nbd0
#End magic
@cjcolvar
cjcolvar / buildOVA.sh
Last active December 28, 2015 08:19
Bash script to build an OVA after vagrant up
#!/bin/bash
vagrant destroy
vagrant up
VM_UUID=`VBoxManage list runningvms | grep -o '[0-9a-fA-F]\{8\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{12\}'`
HD_UUID=`VBoxManage list -l runningvms | grep "SATA.*UUID" | grep -o '[0-9a-fA-F]\{8\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{12\}'`
VM_DATE=`date +%y%m%d`
VBoxManage snapshot "${VM_UUID}" take "avalon-vm-${VM_DATE}-bootstrapped"
#Do OVA prep
vagrant ssh -c 'sudo yum install -y NetworkManager-gnome firstboot perl-XML-Twig perl-YAML-LibYAML'
vagrant ssh -c 'sudo rpm -i "http://www.avalonmediasystem.org/downloads/avalon-vm-2.0-1.noarch.rpm"'
@cjcolvar
cjcolvar / gist:7415481
Last active December 28, 2015 00:39
Bash script for creating avalon OVA
#!/bin/bash
vagrant up
VM_UUID=`VBoxManage list runningvms | grep -o '[0-9a-fA-F]\{8\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{12\}'`
HD_UUID=`VBoxManage list -l runningvms | grep "SATA.*UUID" | grep -o '[0-9a-fA-F]\{8\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{12\}'`
vagrant halt
VM_DATE=`date +%y%m%d`
VBoxManage modifyhd ${HD_UUID} --compact
VBoxManage export ${VM_UUID} --output avalon-vm-${VM_DATE}.ova --product "Avalon Media System" --producturl http://www.avalonmediasystem.org --version R2
@cjcolvar
cjcolvar / cleanupExportedAvalonObject.rb
Created October 31, 2013 14:23
A script which will clean up an exported avalon fedora object to prepare it to become a fixture
require 'nokogiri'
require 'open-uri'
require 'base64'
filename = ARGV[0]
f = File.new filename
doc = Nokogiri::XML::Document.parse f
f.close
#Get rid of Audit trail
doc.xpath("//foxml:datastream[@ID='AUDIT']").each {|n| n.remove()}
@cjcolvar
cjcolvar / stripChaptersCronJob.sh
Last active December 26, 2015 22:59
Cronjob script for finding mp4 files in a directory then exporting and stripping chapters for compatibility with Adobe Media Server
#!/bin/bash
lockdir=~/
searchdir=$1
if [ -e ${lockdir}/.stripChaptersCronJob.lock ]
then
exit
fi
touch ${lockdir}/.stripChaptersCronJob.lock
@cjcolvar
cjcolvar / gist:6813926
Created October 3, 2013 17:45
hydra-role-management routes change to allow mounting at custom path
Hydra::RoleManagement::Engine.routes.draw do
#role_users POST /roles/:role_id/users(.:format) user_roles#create
# role_user DELETE /roles/:role_id/users/:id(.:format) user_roles#destroy
# roles GET /roles(.:format) roles#index
# POST /roles(.:format) roles#create
# new_role GET /roles/new(.:format) roles#new
# edit_role GET /roles/:id/edit(.:format) roles#edit
# role GET /roles/:id(.:format) roles#show
# PUT /roles/:id(.:format) roles#update
cap deploy matterhorn HOSTS=pawpaw.dlib.indiana.edu production SCM_BRANCH=release/2.0.0
@cjcolvar
cjcolvar / fedora_solr_sync_issues_spec.rb
Last active December 23, 2015 01:19
Avalon test that should work, but leads to infinite loop resulting in tons of requests to solr and fedora and eventually times out.
require 'spec_helper'
describe 'fedora_solr_sync_issues' do
describe 'master files no longer in fedora but still in solr' do
let!(:master_file) {FactoryGirl.create(:master_file)}
after do
ActiveFedora::SolrService.instance.conn.delete_by_id(master_file.pid)
ActiveFedora::SolrService.instance.conn.commit
end