Skip to content

Instantly share code, notes, and snippets.

@pgwillia
pgwillia / sufia_7.sh
Last active November 27, 2015 23:39
Try out Sufia 7 (with PCDM)
#! /bin/sh -x
yum remove -y java
yum install -y sqlite-devel java-1.8.0-openjdk
# install ruby 2.2
yum install gcc-c++ patch readline readline-devel zlib zlib-devel libyaml-devel libffi-devel openssl-devel make bzip2 autoconf automake libtool bison iconv-devel
curl -sSL https://rvm.io/mpapis.asc | sudo gpg2 --import -
curl -L get.rvm.io | bash -s stable
source /etc/profile.d/rvm.sh
rvm install 2.2
# from https://www.rubyplus.com/articles/2721?utm_source=rubyweekly&utm_medium=email
car = Car.new
method = car.method(:drive)
p method.parameters
# p method.source_location
# p method.super_method.source_location
# Example 1
# output: [[:req, :speed]]
@pgwillia
pgwillia / controller_spec.md
Created November 24, 2015 19:38
What's the deal with xhr in controller spec?

If you're talking about testing it inside your controller specs, where you normally call

get :index

to make an HTTP request to the index action, you would instead call

xhr :get, :index

to make an XmlHttpRequest (AJAX) request to the index action using GET.

@pgwillia
pgwillia / stub_open.rb
Created November 10, 2015 23:04
To mock or stub ‘open’ method
allow(OpenURI).to receive(:open_uri) { raise Timeout::Error }
#Gemfile
group :development do
gem 'byebug' unless ENV['CI'] # debugging tool to place breakpoints and examine stack
gem 'rubocop', require: false # enforce code style
gem 'mutant-rspec' # mutation testing tool -- will change code to find code that isn't covered or doesn't have a speced side effect
end
I, [2015-09-25T13:54:46.517417 #30462] INFO -- : Completed 500 Internal Server Error in 764ms (ActiveRecord: 11.0ms)
F, [2015-09-25T13:54:46.522783 #30462] FATAL -- :
ActionView::Template::Error (Object mk61sr85c not found in solr):
1: <%# container for all documents in index view -%>
2: <div id="search-results">
3: <ol class="catalog" start="<%= document_counter_with_offset(0) %>">
4: <%= render documents, as: :document %>
5: </ol>
6: </div>
vendor/ruby/2.1.0/gems/active-fedora-9.2.1/lib/active_fedora/solr_instance_loader.rb:37:in `solr_doc'
def jobs = Hudson.instance.items
jobs.findAll{it.logRotator}.each {
println("JOB : "+ it.name)
try {
println(it.logRotator.perform(it))
} catch (Exception e) {
println("It didn't work: "+ e)
}
}
<% if can? :edit, @collection && (not @collection.edit_groups.include? "registered") %>
@pgwillia
pgwillia / redis_keys_a_before.out
Last active August 29, 2015 14:19
What does redis store for Sufia ```redis-cli```
127.0.0.1:6379> keys *
1) "sufia:development:stat:processed:plano.library.ualberta.ca:6105:*"
2) "GenericFile:p841b097m:event"
3) "events:10"
4) "GenericFile:p8419k11c:event"
5) "events:6"
6) "GenericFile:p841b098w:event"
7) "sufia:development:stat:failed"
8) "GenericFile:p8419c62m:event"
9) "sufia:development:stat:failed:plano.library.ualberta.ca:6102:*"
@pgwillia
pgwillia / where_is_this_method_defined.rb
Created April 23, 2015 22:25
Where is this method defined?
# where buddy is an instance of a Class
buddy.method(:spit) # ruby doc for spit method
buddy.method(:spit).owner # object hierarchy
buddy.method(:spit).parameters # expected parameters
buddy.method(:spit).source_location # file name and line number