Skip to content

Instantly share code, notes, and snippets.

View kristenmills's full-sized avatar

Kristen Mills kristenmills

View GitHub Profile
@kristenmills
kristenmills / instructions.md
Last active August 29, 2015 13:57
Setting Up Rails for ThoughtShare
@kristenmills
kristenmills / keybase.md
Last active April 14, 2020 18:27
keybase.md

Keybase proof

I hereby claim:

  • I am kristenmills on github.
  • I am kristen (https://keybase.io/kristen) on keybase.
  • I have a public key whose fingerprint is 7E43 7607 A407 BD2E CC49 B4D6 B3C0 6C61 1C18 B1E4

To claim this, I am signing this object:

curl -o yaz-4.2.67.tar.gz http://ftp.indexdata.dk/pub/yaz/yaz-4.2.67.tar.gz
tar zxvf yaz-4.2.67.tar.gz
cd yaz-4.2.67
./configure
make install
@kristenmills
kristenmills / isbn2lcc.rb
Last active December 22, 2015 20:09 — forked from kurtraschke/parsecallno.py
Some scripts to work with library of congress call numbers. Eventually to be used in some fashion in Alexandria.
#Connects to the library of congress database.
#Given a ISBN, it fetches the LCC.
require 'zoom'
require 'marc'
require 'stringio'
ZOOM::Connection.open('z3950.loc.gov', 7090) do |conn|
conn.database_name = 'VOYAGER'
conn.preferred_record_syntax = 'USMARC'
@kristenmills
kristenmills / isbn.rb
Created September 8, 2013 01:19
Ruby script for making the barcode labels
while true
print '>> '
STDOUT.flush
isbn = gets.chomp
`lpr barcodes/#{isbn}.png`
end
LOG1 = Math.log(GOLDEN_RATIO, 10)
LOG2 = Math.log(Math.sqrt(5), 10)
def problem104
n = 2
fn1 =1
fn2 = 1
while true
n += 1
fn = (fn1 + fn2) % 10**9
@kristenmills
kristenmills / split.rb
Created November 28, 2012 17:10
Splits a string into lines so that the number characters in a line is less than or equal to a specified length. Individual words will only be split if the word itself has more characters than can fit on a line.
def split string, length
split = Array.new
if string.length > length #if the string needs to be split
string_words = string.split(" ")
line = ""
string_words.each do |x|
if x.length > length #if the word needs to be split
#add the start of the word onto the first line (even if it has already started)
while line.length < length
line += x[0]
@kristenmills
kristenmills / problem102.rb
Created September 3, 2012 00:42
Project Euler 102
def same_side p1, p2, p3, p4
cp1 = cross_product p4-p3, p1-p3
cp2 = cross_product p4-p3, p2-p3
dot_product(cp1, cp2) >=0
end
# is the point p in the triangle
def point_in_triangle p=Vector[0,0,0], a, b, c
same_side(p, a, b, c) && same_side(p, b, a, c) && same_side(p, c, a, b)
end
@kristenmills
kristenmills / problem31.rb
Created June 8, 2012 00:20
Project Euler 31
def solve
coins = [1, 2, 5, 10, 20, 50, 100, 200]
goal = 200
ways = Array.new
ways << 1
200.times do
ways << 0
end
coins.each do |coin|
coin.upto(goal) do |x|
@kristenmills
kristenmills / problem70.rb
Created May 30, 2012 00:39
Project Euler 70
def phi p1, p2
(p1-1)*(p2-1)
end
def find
min = [0,2]
lst = prime_sieve 5000
lst.keep_if{|x| x > 2000}
lst.reverse_each do |p1|
lst.reverse_each do |p2|