Skip to content

Instantly share code, notes, and snippets.

View palexander's full-sized avatar

Paul R Alexander palexander

View GitHub Profile
@@ -41,10 +41,23 @@ namespace :docker do
# Require the test files for this particular fork
test_files_sliced[i].each {|f| require_relative f}
+ # redirect stdout
+ require 'stringio'
+ sio = StringIO.new
+ $stdout = sio
+ $stderr = sio
+
@@ -27,6 +27,7 @@ namespace :docker do
pids = []
forks.times do |i|
pids << fork do
+ begin
##
# Configure your environment
# You'll want to do something here to make the environment
@@ -49,7 +50,9 @@ namespace :docker do
namespace :docker do
desc "Run tests in parallel using docker"
task :test do
forks = 4
begin
# Start docker containers (serially, docker seems to have problems with concurrency)
ports = {}
forks.times do |i|
# Start redis and get the mapped port
`docker run -d -p 6379 -name redis#{i} yourdockeruser/redis`
namespace :docker do
desc "Run tasks in parallel using docker"
task :test do
forks = 4
begin
# Start docker containers (serially, docker seems to have problems with concurrency)
ports = {}
forks.times do |i|
# Start redis and get the mapped port
`docker run -d -p 6379 -name redis#{i} yourdockeruser/redis`
@palexander
palexander / Vagrantfile
Last active December 28, 2015 11:19
Setup for running docker
# Base config from Vagrantfile plus additions to support docker
config.vm.provider :virtualbox do |vb|
config.vm.box = BOX_NAME
config.vm.box_url = BOX_URI
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
vb.customize ["modifyvm", :id, "--natdnsproxy1", "on"]
# Added for docker
vb.customize ["modifyvm", :id, "--ioapic", "on"] # needed for multicpu support
vb.customize ["modifyvm", :id, "--cpus", "4"] # multiple cpus
require 'rack'
class TestPull < LinkedData::TestCase
def self.before_suite
# CREATE FILE OBJECT:
file = File.new("../some/file.owl")
@@thread = Thread.new do
Rack::Server.start(
app: lambda do |e|
@palexander
palexander / gist:4773824
Created February 12, 2013 21:59
Ontology submission zip error
org.ncbo.stanford.service.ontology.AbstractOntologyService ERROR - 2013-02-04 03:51:11,509 - Error in OntologyService:uploadOntologyFile()! - remote file (fileItem) /srv/ncbo/bioportal_resources/uploads/1005/1 (Is a directory)
java.io.FileNotFoundException: /srv/ncbo/bioportal_resources/uploads/1005/1 (Is a directory)
at java.io.FileOutputStream.open(Native Method)
at java.io.FileOutputStream.<init>(FileOutputStream.java:194)
at java.io.FileOutputStream.<init>(FileOutputStream.java:84)
at org.ncbo.stanford.util.CompressionUtils.extractFiles(CompressionUtils.java:126)
at org.ncbo.stanford.util.CompressionUtils.unzip(CompressionUtils.java:58)
at org.ncbo.stanford.util.CompressionUtils.uncompress(CompressionUtils.java:41)
at org.ncbo.stanford.util.ontologyfile.compressedfilehandler.AbstractCompressedFileHandler.handle(AbstractCompressedFileHandler.java:35)
at org.ncbo.stanford.util.ontologyfile.compressedfilehandler.impl.RRFCompressedFileHandlerImpl
##
# Get the context for a search term and highlight the term itself
# text: string containing the search term and additional information
# term: string with the term you're looking for
# words: int for how many words to include total
# padding_left: int for characters to the left of the search term
# padding_right: int for characters to the right of the search term
#
# Only handles the first instance of a given term. Can be modified to take
# character positions denoting the start and stop of term(s).
@palexander
palexander / 4s-service-setup.sh
Created December 5, 2012 01:53
4store-service: a script to start, stop and restart 4store
# Setup for usage in Mac OSX (assuming you are using 4store.app from your /Applications folder)
curl -L https://raw.github.com/gist/4211360/81143f15fd6f9a3defcd38b6c24a922f3fc731ac/gistfile1.sh -o 4s-service
chmod +x 4s-service
mv 4s-service /Applications/4store.app/Contents/MacOS/bin
# Add the following to your (zsh|bash)rc path (this makes it so you don't have to run 4store.app):
# export PATH=/Applications/4store.app/Contents/MacOS/bin:$PATH
# You can also do this for custom installs of 4store, just replace the /Applications path with your own
# THE SCRIPT WILL NOT WORK WITHOUT 4s-backend, 4s-httpd, etc IN YOUR PATH
# Defaults:
@palexander
palexander / review.rb
Created November 29, 2012 22:17
blank node error
module LinkedData
module Models
class Review < Goo::Base::Resource
model :review
validates :creator, :presence => true, :cardinality => { :maximum => 1 }
validates :created, :date_time_xsd => true, :presence => true, :cardinality => { :maximum => 1 }
validates :body, :presence => true, :cardinality => { :maximum => 1 }
validates :ontologyReviewed, :presence => true, :cardinality => { :maximum => 1 }
validates :usabilityRating, :cardinality => { :maximum => 1 }
validates :coverageRating, :cardinality => { :maximum => 1 }