Skip to content

Instantly share code, notes, and snippets.

View bhuga's full-sized avatar

Ben Lavender bhuga

View GitHub Profile
require 'quantity/all'
1.meter #=> 1 meter
1.meter.to_feet #=> 3.28083... foot
c = 299792458.meters / 1.second #=> 299792458 meter/second
newton = 1.meter * 1.kilogram / 1.second**2 #=> 1 meter*kilogram/second^2
newton.to_feet #=> 3.28083989501312 foot*kilogram/second^2
newton.convert(:feet) #=> 3.28083989501312 foot*kilogram/second^2
jerk_newton / 1.second #=> 1 meter*kilogram/second^3
jerk_newton * 1.second == newton #=> true
require 'spira'
require 'rdf'
Spira.add_repository(:person, ::RDF::Repository)
class Person
include Spira::Resource
class CDs < RDF::Vocabulary('http://example.org/')
property :artist
property :cds
property :artists
end
class CD
include Spira::Resource
require 'spira'
Spira.add_repository(:person, ::RDF::Repository)
class Person
include Spira::Resource
default_source :person
# sample heroku rackup
http://rdfdo.heroku.com/postgres
http://rdfdo.heroku.com/sqlite3
$:.unshift(Dir.glob("./.bundle/gems/bundler/gems/rdf-spec*gemspec*/lib").first)
require 'spec'
app = proc do |env|
#!/usr/bin/env ruby
require 'rdf'
require 'do_sqlite3'
require 'rdf/do'
$:.unshift '~/repos/RDFObjects/lib'
require 'rdf_objects'
rdfobject = RDFObject::Resource.new('http://example.org/1234')
RSpec:
should support #predicates
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
200 OK | text/plain 1070 bytes
ben:rdf ben$ irb
>> require 'rdf'
=> true
>> s = RDF::NTriples.unserialize '<http://openlibrary.org/b/OL3M> <http://RDVocab.info/Elements/titleProper> "Jhūlā." '
=> #<RDF::Statement:0x90bbb8(<http://openlibrary.org/b/OL3M> <http://RDVocab.info/Elements/titleProper> "Jhūlā." .)>
>> RDF::NTriples.serialize(s)
=> "<http://openlibrary.org/b/OL3M> <http://RDVocab.info/Elements/titleProper> "Jh\305\253l\304\201." .\n"
>> exit
require 'spira'
require 'rdf/ntriples'
class Person
include Spira::Resource
property :name, :predicate => FOAF.name
property :nick, :predicate => FOAF.nick
end
#!/usr/bin/env jruby
libs = %w{jena-2.6.2 arq-2.8.3 icu4j-3.4.4 iri-0.8 log4j-1.2.14 stax-api-1.0.1 wstx-asl-3.2.9 xercesImpl-2.7.1 slf4j-api-1.5.8 slf4j-log4j12-1.5.8}
libdir = "/Users/ben/jena/ARQ-2.8.3/lib"
libs.each do | lib |
require File.join(libdir, "#{lib}.jar")
end
require '/Users/ben/jena/spinrdf-1.1.1/lib/spinrdf-1.1.1.jar'
require 'rdf'