Skip to content

Instantly share code, notes, and snippets.

View r00k's full-sized avatar
💭
Working on Tuple (https://tuple.app)

Ben Orenstein r00k

💭
Working on Tuple (https://tuple.app)
View GitHub Profile
class DownloadTrials
require 'rubygems'
def self.download_trials
agent = WWW::Mechanize.new
file = agent.get("http://clinicaltrials.gov/search?term=%22banana%22&studyxml=true")
file.save_as(File.dirname(__FILE__) + '/../tmp/trials.zip')
end
end
# test/unit/import_trials_test.rb
def test_import
search_string = "search string"
inst_name = "institution name"
Trial.expects(:create_trials_from_xml).with(DownloadTrials::OUTPUT_DIRECTORY, inst_name)
ImportTrials.import(inst_name, search_string)
end
# test/unit/trial_test.rb
580) Error:
test: SporeUnit should require unique value for name. (SporeUnitTest):
ArgumentError: wrong number of arguments (1 for 0)
/var/projects/beno/dfhcc_informatics/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:102:in `sum'
/var/projects/beno/dfhcc_informatics/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:102:in `instance_method_already_implemented?'
/var/projects/beno/dfhcc_informatics/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:72:in `define_attribute_methods'
/var/projects/beno/dfhcc_informatics/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `each'
/var/projects/beno/dfhcc_informatics/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:71:in `define_attribute_methods'
/var/projects/beno/dfhcc_informatics/vendor/rails/activerecord/lib/active_record/attribute_methods.rb:242:in `method_missing'
/var/projects/beno/dfhcc_informatics/vendor/gems/thoughtbot-shoulda-2.0.5/lib/shoulda/ac
class Array
# Split an array into 10 pieces, yield 1/10th and the other 9/10ths. Do this 10 times, returning a distinct
# (no overlaps) 1/10th slice each time.
def iterate_by_tenths(&block)
self.each_slice((self.length / 10).ceil) do |tenth|
yield(tenth, self - tenth)
end
end
end
class ClassifyPublications
# TODO: test corpus should be confirmed AND rejected items; would require a classifyable object
# Results:
#
# (Testing done with 10-fold cross-validation on 31k citations)
#
# Training on title and abstract, classifying on title = 90.8% accuracy
# imports institutions from a filemaker exported xml file
require File.dirname(__FILE__) + '/../../config/environment'
require 'rubygems'
require 'hpricot'
# this establishes a mapping between column names in the
# exported filemaker xml and the variable names we'll be using in rails
COLUMN_MAP = {
"institution_key" => :institution_key,
"institution_name" => :institution_name,
def show
if (@trial.closed? || @trial.nonrelevant?) && !is_admin?
render 'admin_only'
else
respond_to do |format|
format.html
format.xml { render :xml => @trial.to_xml(:include => [:topics, :contacts, :investigators, :institutions]) }
end
end
end
bjo@dhcp-172-24-115-72:~$ ssh -v ben@railsstage
OpenSSH_5.1p1, OpenSSL 0.9.7l 28 Sep 2006
debug1: Reading configuration data /etc/ssh_config
debug1: Connecting to railsstage [172.24.115.131] port 22.
debug1: Connection established.
debug1: identity file /Users/bjo/.ssh/identity type -1
debug1: identity file /Users/bjo/.ssh/id_rsa type -1
debug1: identity file /Users/bjo/.ssh/id_dsa type 2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.2
debug1: match: OpenSSH_5.2 pat OpenSSH*
##
# Delete a (key, value) pair.
#
# ==== Example
# t = Trie.new.insert("a", 1).insert("a", 2)
# t.delete_pair("a", 1) # t now only contains the second value
#
def delete_pair(key, value)
key = key.split('') if key.is_a?(String)
if key.empty?
require 'rbconfig'
require 'find'
require 'ftools'
include Config
# this was adapted from rdoc's install.rb by ways of Log4r
$sitedir = CONFIG["sitelibdir"]
unless $sitedir