Skip to content

Instantly share code, notes, and snippets.

View arockwell's full-sized avatar

Alex Rockwell arockwell

View GitHub Profile
select ?org ?label
where
{
?org rdf:type foaf:Organization .
optional { ?org rdfs:label ?label }
filter(!bound(?label))
}
@arockwell
arockwell / gist:864756
Created March 10, 2011 19:37
find all people who have written a paper in VIVO
select ?person ?authship ?publication
where
{
?person rdf:type foaf:Person .
?person core:authorInAuthorship ?authship .
?authship core:linkedInformationResource ?publication
}
limit 10
select ?person ?authship ?publication
where
{
?person rdf:type foaf:Person .
?person core:authorInAuthorship ?authship .
?authip core:linkedInformationResource ?publication .
?publication rdf:type ?pub_type .
optional { ?pub_type rdf:type core:Journal }
filter(!bound(?publication))
@arockwell
arockwell / gist:865295
Created March 11, 2011 01:09
example_construct_wszd
construct {
?pers_vivo_id core:authorInAuthorship ?authship .
?authship core:linkedInformationResource ?pub_vivo_id .
?pub_vivo_id
bibo:pmid ?pub_pmid ;
rdf:type ?pub_type ;
rdfs:label ?pub_lbl ;
core:Title ?pub_title ;
bibo:volume ?pub_vol ;
select ?uri ?actual_label
where
{
?uri rdfs:label ?actual_label
{
select ?uri
where
{
?uri rdfs:label ?label
}
require 'rubygems'
require 'stomp'
queue = "/queue/IdCard.Vivo"
puts "Consumer for queue #{queue}"
client = Stomp::Client.new "lib-vivo", "[redacted]", "bsd-dev-activemq.bsd.ufl.edu", 61618, true
client.subscribe queue, { :ack => :client } do | message |
puts "message=#{message.body}"
end
@arockwell
arockwell / clock.rb
Created June 12, 2011 01:01
Clock for pushing tasks to redis periodicall
redis = Redis.new(:host => redis_host, :port => redis_port)
while(1) do
first_url = redis.rpoplpush src_queue, src_queue
redis.rpush work_queue, first_url
while(1) do
next_url = redis.rpoplpush src_queue, src_queue
if next_url != first_url
redis.rpush work_queue, next_url
else
break
@arockwell
arockwell / worker.rb
Created June 12, 2011 01:03
Worker for pulling tasks off a redis queue
redis = Redis.new(:host => redis_host, :port => redis_port)
while(1) do
url = redis.blpop(work_queue, 0)[1]
is_up = server_check.check(url)[0]
if is_up
puts "#{url} is up."
else
puts "#{url} is down."
end
end
@arockwell
arockwell / Rakefile
Created June 22, 2011 20:57
first iteration of rake task definition
files = [
:a_file => "/path/to/a_file",
:b_file => "/path/to/b_file",
:c_file => "/path/to/c_file"
]
desc "Process files"
task :process_files do
files.each |file_name, file_location|
process_file(file_name, file_location)
@arockwell
arockwell / Rakefile
Created June 22, 2011 20:59
second iteration of rakefile
files = [
:a_file => "/path/to/a_file",
:b_file => "/path/to/b_file",
:c_file => "/path/to/c_file"
]
process_tasks = []
files.each |file_name, file_location|
process_task = "process_#{file_name}".intern
process_tasks << process_task
desc "Process #{file_location}"