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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'active_support/core_ext' | |
require 'pp' | |
require 'csv' | |
require 'nokogiri' | |
dc_terms = [ :contributor, :coverage, :creator, :date, | |
:description, :format, :identifier, :language, |
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
#!/usr/bin/env ruby | |
# encoding: utf-8 | |
require 'csv' | |
require 'pp' | |
require 'active_support/core_ext' | |
require 'nokogiri' | |
f = nil; File.open('/home/jhbrown/Dropbox/kaye.csv') do |file| |
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
# thanks to http://www.andornot.com/blog/post/Replace-MS-Word-special-characters-in-javascript-and-C.aspx | |
class UglyCharGsubber | |
# To replace characters in a string and return the substitution string | |
def self.replace(text) | |
text. | |
gsub(/[\u2018|\u2019|\u201A]/, "\'"). | |
gsub(/[\u201C|\u201D|\u201E]/, "\""). | |
gsub(/\u2026/, "..."). |
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
function jbtest(a, b) { | |
var ss = SpreadsheetApp.getActiveSheet(); | |
var rangeall = ss.getDataRange(); | |
var rangeb = ss.getRange(ss.getLastRow(),1,1,ss.getLastColumn()); | |
//rangeb.setBackgroundColor("#CC6666"); | |
//var valyus = rangeb.getValues(); | |
//Browser.msgBox(valyus[0][1]); | |
Browser.msgBox(hex_md5("message digest")); | |
} |
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
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'csv' | |
def get_stuff_from_dc(file) | |
ret_values = {} | |
my_xml = Nokogiri::XML(File.read(file)) | |
# I know these rescue nils are bad but I don't know a more efficient way | |
ret_values[:pid] = my_xml.at_xpath('//xb:digital_entity/pid/text()', "xb" => "http://com/exlibris/digitool/repository/api/xmlbeans").content rescue nil |
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
#!/usr/bin/env ruby | |
require 'nokogiri' | |
require 'csv' | |
require 'savon' | |
Savon.configure do |config| | |
config.log = false | |
end | |
HTTPI.log = false |
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
# Fix for ActiveRecord::Relation not including ORDER BY columns in SELECT statement (in PostgreSQL) | |
# e.g., ActionView::TemplateError (PGError: ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list | |
# Note: use at your own risk. This works on my data but your results may vary. | |
def add_order_values_to_select(arel_object) | |
my_order_values = arel_object.order_values.map do |x| | |
x = x.to_sql if x.respond_to? :to_sql | |
x.gsub(/ASC|asc|desc|DESC|"/,"").strip | |
end.reject(&:blank?) |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/ZJONSSON/d3-plugins/master/force_labels/force_labels.js"></script> | |
<style> | |
.anchor { fill:blue} | |
.labelbox { fill:black;opacity:0.8} | |
.labeltext { fill:white;font-weight:bold;text-anchor:middle;font-size:16;font-family: serif} | |
.link { stroke:gray;stroke-width:0.35} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://d3js.org/d3.v2.js"></script> | |
<script type="text/javascript" src="https://raw.github.com/ZJONSSON/d3-plugins/master/force_labels/force_labels.js"></script> | |
<style> | |
.anchor { fill:blue} | |
.labelbox { fill:black;opacity:0.8} | |
.labeltext { fill:white;font-weight:bold;text-anchor:middle;font-size:16;font-family: serif} | |
.link { stroke:gray;stroke-width:0.35} |
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
#!/usr/bin/env ruby | |
my_files = Dir.chdir(ARGV[0]) { Dir.glob("./*").map{|x| File.expand_path(x) } } | |
def my_array_steamer(oldarr, newfile) | |
lines = (File.readlines(newfile)).map(&:strip) | |
oldarr | lines | |
end | |
my_arr = Array.new |