Skip to content

Instantly share code, notes, and snippets.

@jtprince
jtprince / nil_enumerator.rb
Created June 8, 2012 18:47
NilEnumerator: an enumerator that returns nil instead of a StopIteration exception when it is at the end of the collection
# https://gist.github.com/gists/2897543
# NilEnumerator
#
# an enumerator that yields nil when it is finished. Only implements #next and
# #peak. Would only want to use this if your collection does NOT already include
# nils.
#
# Compare:
#
# # normal iteration requires catching StopIteration
@jtprince
jtprince / digestor_spec.rb
Created May 16, 2011 21:46
Digestor Specification
require 'spec/more'
require 'digestor'
describe "Digestor" do
before do
@seq = "MTMDKSELVQKAKLAEQAERYDDMAAAMKAVTEQGHELSNEERNLLSVAYKNVVGARRSSWRVISSIEQKTERNEKKQQMGKEYREKIEAELQDICNDVLELLDKYLIPNATQPESKVFYLKMKGDYFRYLSEVASGDNKQTTVSNSQQAYQEAFEISKKEMQPTHPIRLGLALNFSVFYYEILNSPEKACSLAKTAFDEAIAELDTLNEESYKDSTLIMQLLRDNLTLWTSENQGDEGDAGEGEN"
end
it 'digests a protein' do
#!/usr/bin/ruby
require 'zlib'
NETWORK_FLOAT = 'g*'
NETWORK_DOUBLE = 'G*'
LITTLE_ENDIAN_FLOAT = 'e*'
LITTLE_ENDIAN_DOUBLE = 'E*'
BASE_64 = 'm*'
require 'mechanize'
class LDSGeneralConferenceURLFinder
MONTH_TO_NUM = {
'April' => 4,
'October' => 10,
}
LDS_ORG = "http://www.lds.org"
TOC_URL = "http://www.lds.org/conference/display/0,5234,23-1,00.html"
require 'builder'
if ARGV.size == 0
puts "usage: #{File.basename(__FILE__)} <input>.xml ..."
puts "output: <input>.result.xml ..."
exit
end
ARGV.each do |file|
File.open(file.sub(/\.xml/,'.result.xml'), 'w') do |out|