Skip to content

Instantly share code, notes, and snippets.

View kardeiz's full-sized avatar

Jacob Brown kardeiz

View GitHub Profile
@kardeiz
kardeiz / gist:3645223
Created September 5, 2012 21:33
some really bad google apps js code just for reference
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"));
}
@kardeiz
kardeiz / gist:3553858
Created August 31, 2012 14:43
Replace curly quotes and other ugly MS Word conversions
# 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/, "...").
@kardeiz
kardeiz / gist:3542022
Created August 30, 2012 21:46
Ugly code to get rough CSV into wrapped EAD XML chunks
#!/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|
@kardeiz
kardeiz / gist:3419688
Created August 21, 2012 21:42
Convert some Dublin Core XML from DigiTool to CSV with Ruby
#!/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,
@kardeiz
kardeiz / gist:3406777
Created August 20, 2012 19:06
Super simple date parser
# Toggle the comments below to switch between American/rational date parsing
require 'american_date'
require 'active_support/core_ext'
# require 'date'
class SimpleDates
def self.parse(mystring)
mystring = mystring.to_s.downcase.strip
# Date._parse likes '/' better than '-', I guess?
@kardeiz
kardeiz / gist:3373244
Created August 16, 2012 20:13
CRUD objects in a DigiTool repository
#!/usr/bin/env ruby
# encoding: utf-8
# please install these gems
require 'nokogiri'
require 'savon'
# define wsdl connection
client = Savon::Client.new do
wsdl.document = ""
@kardeiz
kardeiz / gist:3363686
Created August 15, 2012 21:06
UMI ETD XML to MARCXML with Ruby
#!/usr/bin/env ruby
require 'nokogiri'
# where the files at
my_files = Dir.chdir(ARGV[0]) { Dir.glob("./*").map{|x| File.expand_path(x) } }
builder = Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
xml.collection(:xmlns => 'http://www.loc.gov/MARC21/slim') {
my_files.each do |my_file|
@kardeiz
kardeiz / gist:3177463
Created July 25, 2012 17:41
Generate simple sitemap for DigiTool archive
#!/bin/bash
for i in {1..50}
do
# ea=$(wget -O - --user-agent="botbotbot" "http://specoll.lib.tcu.edu/dtl_publish/$i/index.html" | grep -oh 'href="[0-9]*.html"' | grep -oh [0-9]*)
ea=$(cat "/exlibris/dtl/u3_1/dtle/apache/htdocs/dtl_publish/$i/index.html" | grep -oh 'href="[0-9]*.html"' | grep -oh [0-9]*)
for jj in $ea
do
ace="http://specoll.lib.tcu.edu/dtl_publish/$i/$jj.html"
if ! grep $ace "/exlibris/dtl/u3_1/dtle/apache/htdocs/sitemap.txt"
@kardeiz
kardeiz / gist:3043781
Created July 3, 2012 22:19
Excel VBA: t-test for summary results
Function ttest_from_sum(x As Range, y As Range, values As Range)
' Set up for dragging over names with lookup
' Change this to fit your needs
Set temp = values.Find(x.Value, LookIn:=xlValues)
avga = CDec(temp.Offset(1, 0).Value)
stda = CDec(temp.Offset(2, 0).Value)
numa = CDec(temp.Offset(3, 0).Value)
@kardeiz
kardeiz / gist:3006106
Created June 27, 2012 19:09
Generic user story collection tool using Twitter Bootstrap, Select2, and Google Forms
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>User story collection tool</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Le styles -->