Skip to content

Instantly share code, notes, and snippets.

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|
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"
#!/usr/bin/ruby
require 'zlib'
NETWORK_FLOAT = 'g*'
NETWORK_DOUBLE = 'G*'
LITTLE_ENDIAN_FLOAT = 'e*'
LITTLE_ENDIAN_DOUBLE = 'E*'
BASE_64 = 'm*'
@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
@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 / execute_on_modify.rb
Created June 19, 2012 21:13
Uses rb-notify to execute a command when a file has been modified and can sub in the filename into the command
#!/usr/bin/env ruby
# requires rb-inotify (will only work on linux)
require 'rb-inotify'
substitute = '{{}}'
div = '--'
if ARGV.size < 2
prog = File.basename(__FILE__)
@jtprince
jtprince / savgol.rb
Created July 9, 2012 16:13
Savitsky-Golay filter for ruby arrays
# do what the heck you want to public license (see doc end)
# gem install ruby-svg # provides SVDMatrix
require 'ruby-svd'
class SVDMatrix < Matrix
def self.[](*rows)
mat = self.new(rows.size,rows.first.size)
rows.each_with_index {|row,i| mat.set_row(i, row) }
mat
# http://rosettacode.org/wiki/Twelve_statements
#1. This is a numbered list of twelve statements.
#2. Exactly 3 of the last 6 statements are true.
#3. Exactly 2 of the even-numbered statements are true.
#4. If statement 5 is true, then statements 6 and 7 are both true.
#5. The 3 preceding statements are all false.
#6. Exactly 4 of the odd-numbered statements are true.
#7. Either statement 2 or 3 is true, but not both.
#8. If statement 7 is true, then 5 and 6 are both true.
@jtprince
jtprince / unique_peptides.rb
Created May 30, 2013 16:12
A simple script that displays unique tryptic peptides for proteins retrieved by uniprot accession number.
#!/usr/bin/env ruby
require 'open-uri'
require 'mspire/digester' # gem install mspire
require 'bio'
require 'set'
accessions = ARGV[0,2]
missed_cleavages = ARGV[2].to_i
@jtprince
jtprince / sc
Last active May 23, 2021 17:55
screenshot application
#!/usr/bin/env ruby
# sc - screenshot utility using imagemagick 'import'
require 'optparse'
require 'ostruct'
require 'shellwords'
require 'fileutils'
viewers = {
'g' => 'geeqie',