This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class MultipleInput < SimpleForm::Inputs::Base | |
# Create one or more input fields for a multiple valued attribute | |
# including one empty input for adding new values. | |
def input(wrapper_options = {}) | |
result = '' | |
# make sure the name is for a multi-valued parameter | |
input_html_options.merge!(name: "#{object.class.to_s.downcase}[#{attribute_name.to_s}][]") | |
if object.respond_to? attribute_name | |
value = object.send(attribute_name) | |
if value.is_a? Enumerable |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Search Term | Results | Solr | OJS | |
------------|---------|------|----- | |
Kolding | 1514| 372 | 3108 | |
Herning | 1022 | 298 | 2699 | |
gallagher | 16 | 474 | 2605 | |
strik 66 880 4038 | |
grønland 1439 797 2714 | |
samfund 5180 839 2792 | |
rasmussen 3383 190 1914 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Start parse wrapper | |
num=$1 | |
for i in $(seq 1 $num); do | |
echo "getting log for $i days ago"; | |
./log_parser.sh "$i days ago"; | |
done | |
# Start log parser | |
#!/bin/bash | |
#get timestamp for requested date |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AAR: Afar | |
ABK: Abkhaziansk | |
ACE: Akinesisk | |
ACH: Acoli | |
ADA: Adangme | |
AFA: Afro-Asiatisk (Andre) | |
AFH: Afrihili (Kunstsprog) | |
AFR: Afrikaans | |
AJM: Aljamia (udgået) | |
AKA: Akan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scraperwiki | |
import lxml.html | |
# Grab the page and turn it into an lxml object | |
html = scraperwiki.scrape("http://www.loc.gov/marc/relators/relaterm.html") | |
root = lxml.html.fromstring(html) | |
authorizedList = root.find_class("authorized") # get the title (has class authorized) | |
codeList = root.find_class('relator-code') # get the code (has class relator-code) | |
codeDict = dict() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def write_xml(hash) | |
builder = Nokogiri::XML::Builder.new do |xml| | |
hash_to_xml(hash, xml) | |
end | |
render xml: builder | |
end | |
def hash_to_xml(hash, xml) | |
hash.each do |key, value| | |
if value.is_a? String |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Synopsis | |
# This application bundles multiple files into a | |
# single file. It is intended for use with js and css | |
# files to allow developers to work on modular files | |
# which can be bundled together to minimise http requests. | |
# == Examples | |
# This command bundles all css files in the relative | |
# directory styles and its subdirectories into one | |
# file complete.css. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def prompt(*args) | |
print(*args) | |
gets.chomp! | |
end | |
def confirm(*args) | |
answer = prompt(*args, "(Y/N)") | |
if (answer.downcase =~ /^y|^n/) | |
return answer =~ /y/ ? true : false | |
else |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//call relevant function on click of showMore/Less links | |
$("[id^=show]").click(function(){ | |
var functionCall = $(this).attr("id").substring(4,8); | |
var boxName = $(this).attr("id").substring(8); | |
window["show" + functionCall](boxName); | |
}); | |
/** | |
* @param boxName string | |
* @pre boxName = Subjects || Notes |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# this function adds two vectors together to produce a new vector, vector3. | |
# first vector 3 is defined as an array. then, an if sentence tests | |
#which vector is longer. this means that vectors of unequal sizes can be added | |
# together. - except that this doesn't actually work... loop stops | |
# the for loop adds each element of the first vector to that of its counterpart | |
# the output is then appended to vector3, the new output. | |
def vectorAdd(vector1,vector2): | |
vector3 = [] | |
if len(vector1)<= len(vector2): |