Skip to content

Instantly share code, notes, and snippets.

View jkwaldrip's full-sized avatar

Jain Waldrip jkwaldrip

  • Olo
  • Indianapolis, IN
View GitHub Profile

Keybase proof

I hereby claim:

  • I am jkwaldrip on github.
  • I am jkwaldrip82 (https://keybase.io/jkwaldrip82) on keybase.
  • I have a public key ASAYbigLBQFDnMmGji7PL0nCvFI5QyTZGDae-lbPBEFJ1Ao

To claim this, I am signing this object:

@jkwaldrip
jkwaldrip / document-ready.js
Created September 21, 2017 15:03
Useful browser-injection snippets
return document.readyState === 'complete';
@jkwaldrip
jkwaldrip / opacityCheck.js
Created September 8, 2017 13:39
Check whether a CSS selector's first matched element is faded-in to view
var opacityCheck = function(selector) {
return window.getComputedStyle(document.querySelectorAll(selector)[0])["opacity"] === "1";
}
@jkwaldrip
jkwaldrip / broken-images-jQuery.js
Last active September 21, 2017 15:12
JavaScript to check for broken images (jQuery & vanilla flavors!)
jQuery("img").map(
function() {
return this.naturalWidth > 0 && this.naturalWidth !== "undefined" && this.complete;
}).get();
@jkwaldrip
jkwaldrip / benchmark_selector
Created September 3, 2014 20:50
Test expressions for performance with Benchmark
require 'benchmark'
# Average the values in an array.
def avg vals = []
vals.inject(:+)/vals.count
end
# Test a Watir-Webdriver expression to ensure it's the fastest way to address an element.
#
# Example:
@jkwaldrip
jkwaldrip / sru_barebones.rb
Created August 12, 2013 15:12
Ruby Bare-Bones SRU Test
#!/usr/bin/env ruby
require 'open-uri'
require 'nokogiri'
base_url = 'http://tst.docstore.ole.kuali.org/sru?version=1.2&operation=searchRetrieve&query='
query_str = 'title%3Dtest'
full_url = base_url + query_str
puts "Searching on #{query_str}"
@jkwaldrip
jkwaldrip / ruby_sru.rb
Created August 8, 2013 16:13
Bare-bones OLE SRU Test
require 'open-uri'
require 'nokogiri'
base_url = 'http://tst.docstore.ole.kuali.org/sru?version=1.2&operation=searchRetrieve&query='
query_str = 'title%3Dtest'
full_url = base_url + query_str
# Pull search query results into Nokogiri XML document.
noko = Nokogiri::XML(open(full_url))
record_count = noko.xpath("//*[local-name()='record' and namespace-uri()='http://www.loc.gov/MARC21/slim']").count
@jkwaldrip
jkwaldrip / staff_uploader.rb
Created June 24, 2013 15:21
OLE Staff Uploader - A quick-and-easy test to perform X staff uploads end-to-end. Run in multiple instances for easy scale testing of the Staff Upload function for paired Marc/EDI EOCR records. (Requires ./data/ to contain paired .mrc/.edi records; uses ole-qa-framework 1.0.0+ )
#!/usr/bin/env ruby
#
# Upload x paired Marc/EDI order files. Used for scale testing of Staff Upload function.
#
# Copyright 2005-2013 The Kuali Foundation
#
# Licensed under the Educational Community License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
@jkwaldrip
jkwaldrip / Dash Date
Created April 25, 2013 14:54
Generate Current Date - MM-DD-YYYY (Preferred Format for OLE Description Fields)
var d = new Date(); var da = d.getDate(); da = ( da < 10 ? "0" : "" ) + da; var mo = d.getMonth() + 1; mo = ( mo < 10 ? "0" : "" ) + mo; var yr = d.getFullYear(); mo + "-" + da + "-" + yr;
@jkwaldrip
jkwaldrip / Slash Date
Created April 25, 2013 14:53
Generate Current Date - MM/DD/YYYY (Preferred Format for OLE Search Fields)
var d = new Date(); var da = d.getDate(); da = ( da < 10 ? "0" : "" ) + da; var mo = d.getMonth() + 1; mo = ( mo < 10 ? "0" : "" ) + mo; var yr = d.getFullYear(); mo + "/" + da + "/" + yr;