Skip to content

Instantly share code, notes, and snippets.

@banurekha
banurekha / roman.java
Created September 16, 2020 01:38
Convert Roman String to Integer
class Solution {
static Map<String, Integer> values = new HashMap<>();
static{
values.put("I", 1);
values.put("V", 5);
values.put("X", 10);
values.put("L", 50);
values.put("C", 100);
@banurekha
banurekha / run-hyrax.md
Created April 10, 2017 17:07 — forked from jeremyf/run-hyrax.md
Script to run the internal app of Hyrax (and thus ease testing a bit)
  1. Open Terminal 1
  2. cd /path/to/hyrax
  3. rake engine_cart:regenerate -- Rebuild the internal app; May not be necessary
  4. Terminal 1: rake engine_cart:server -- Analogue to cd .internal_test_app; rails s
  5. Open Terminal 2
  6. cd cd /path/to/hyrax
  7. fcrepo_wrapper -v -p 8984 --no-jms
  8. Open Terminal 3
  9. cd cd /path/to/hyrax
  10. solr_wrapper -v -d solr/config/ -n hydra-development -p 8983
@banurekha
banurekha / rspec_solr_helper
Last active August 29, 2015 14:05
Creatint Rspec for curate solr_helper
require 'spec_helper'
describe Hydramata::SolrHelper do
before(:all) do
class EmbargoMockController
include Hydramata::SolrHelper
attr_accessor :params
def current_ability
@banurekha
banurekha / Console Commands
Last active August 29, 2015 14:02
Content Model description and underlying Rels_ext
item=Item.find('changeme:1')
item.page_ids
Return []
page=Page.find('changeme:2')
page.item_ids
=> ["changeme:1"]
But then
item.pages
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
@banurekha
banurekha / gist:6153327
Created August 5, 2013 03:40
My reference for date query I was referring to this site http://mercury-ops2.ornl.gov/clearinghouse/
This how during query will look like for
-----------before query-----------
Has Data started before $date
startdate:[* TO $date]
****************************
Has Data ended before $date
enddate:[* TO $date]
@banurekha
banurekha / gist:6137400
Created August 2, 2013 04:00
Solr Date range reference
Yes, you'll need two fields.
The query will then have to be on both fields.
Example:
dateFrom:[$start TO $end] AND dateTo:[$start TO $end]
This would mean that the timespan of the object would have to fall entirely within the timespan you are searching for (e.g. object is 1950-1960 and you search for 1900-2000).
class EtdSubmitDatastream < ActiveFedora::NokogiriDatastream
set_terminology do |t|
t.root(:path=>"workflow") {
t.object_id(:path=>{:attribute=>"objectId"}, :label=>"Object ID")
}
# t.process would allow you to leave off
# the :path, but because we called it something