Skip to content

Instantly share code, notes, and snippets.

View mjgiarlo's full-sized avatar
:shipit:
always be shipping

Michael J. Giarlo mjgiarlo

:shipit:
always be shipping
View GitHub Profile
require: rubocop-rspec
AllCops:
RunRailsCops: true
DisplayCopNames: true
Include:
- '**/Rakefile'
- '**/config.ru'
Exclude:
- 'bin/**/*'
@mjgiarlo
mjgiarlo / dump.nt
Last active August 29, 2015 14:28
content/fcr:metadata triples from a simple GF
2.2.2 :017 > puts gf.content.metadata.ldp_source.graph.dump(:ttl)
<http://127.0.0.1:8983/fedora/rest/dev/xk/81/jk/37/xk81jk370/content> a <http://www.jcp.org/jcr/nt/1.0resource>,
<http://www.jcp.org/jcr/nt/1.0base>,
<http://www.jcp.org/jcr/mix/1.0mimeType>,
<http://www.jcp.org/jcr/mix/1.0lastModified>,
<http://fedora.info/definitions/v4/repository#Binary>,
<http://fedora.info/definitions/v4/repository#Resource>,
<http://www.jcp.org/jcr/mix/1.0created>,
<http://www.jcp.org/jcr/mix/1.0referenceable>;
mjg@beacon:~/workspace/scholarsphere/jetty/fcrepo4-data/fcrepo.binary-store-path (@scholarsphere) [arkivo_testing L|✚ 3…3]$ tree
.
├─ 0e
│   └── f2
│   └── 43
│   └── 0ef2436e5a17a9785f9ab0dc4f8eeb0dd5b6ad51
...
37 directories, 6 files
mjg@beacon:~/workspace/scholarsphere/jetty/fcrepo4-data/fcrepo.binary-store-path (@scholarsphere) [arkivo_testing L|✚ 3…3]$ file 0e/f2/43/0ef2436e5a17a9785f9ab0dc4f8eeb0dd5b6ad51
1) ActiveFedora::Noid::SynchronizedMinter#mint does not mint the same ID twice in a row
Failure/Error: expect(subject).not_to eq ActiveFedora::Noid::Service.new.mint
expected: value != "cr56n096b"
got: "cr56n096b"
(compared using ==)
# ./spec/unit/synchronized_minter_spec.rb:40:in `block (3 levels) in <top (required)>'
def migrate_statefile!
EngineCart.load_application!
EngineCart.within_test_app do
puts `rake sufia:noid:migrate_statefile`
Rake::Task['sufia:noid:migrate_statefile'].invoke
end
end
1st 0.000000 0.000000 0.000000 ( 0.001382)
10th 0.010000 0.000000 0.010000 ( 0.002431)
100th 0.000000 0.000000 0.000000 ( 0.001564)
1,000th 0.000000 0.000000 0.000000 ( 0.002074)
10,000th 0.010000 0.000000 0.010000 ( 0.006800)
2.2.1 :003 > ActiveFedora::Noid::Service.new.mint
seed is 271030524290525531404955989783767342781
counters size is 293
@rand.rand(counters.size) is 261
counters[261] is {:value=>6300353125, :max=>6324492408}
counters[261][:value] is 6300353125
counters[261][:value] is now 6300353126
=> "vt150j25g"
2.2.1 :004 > ActiveFedora::Noid::Service.new.mint
seed is 271030524290525531404955989783767342781
@mjgiarlo
mjgiarlo / curation_concern_events.rb
Created July 15, 2015 18:32
A pattern for handling CurationConcerns events in Sufia::Core
# These events are triggered by actions within CurationConcerns Actors
CurationConcerns.config.after_create_content = lambda { |generic_file, user|
Sufia::CreateContentService.new(generic_file, user).call
# which will call CurationConcerns.queue.push(ContentDepositEventJob.new(generic_file.id, user.user_key))
}
CurationConcerns.config.after_revert_content = lambda { |generic_file, user, revision|
Sufia::RevertContentService.new(generic_file, user, revision).call
# which will call CurationConcerns.queue.push(ContentRestoredVersionEventJob.new(generic_file.id, user.user_key, revision))
}
@mjgiarlo
mjgiarlo / console.rb
Created July 8, 2015 17:37
automatic nilification
[1] pry(main)> var1 = 'value1' if false
=> nil
[2] pry(main)> var1
=> nil
[3] pry(main)> if false
[3] pry(main)* var2 = 'value2'
[3] pry(main)* end
=> nil
[4] pry(main)> var2
=> nil
mjg@beacon:~ (master[2.2.0])$ cd workspace/druw/
mjg@beacon:~/workspace/druw (creators[2.2.0@druw])$ which rails
/home/mjg/.rvm/gems/ruby-2.2.0@druw/bin/rails
mjg@beacon:~/workspace/druw (creators[2.2.0@druw])$ cd ../scholarsphere
mjg@beacon:~/workspace/scholarsphere (develop[2.1.5@scholarsphere])$ which rails
/home/mjg/.rvm/gems/ruby-2.1.5@scholarsphere/bin/rails