This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'ffi-rzmq' | |
#IPC_SOCKET = "ipc:///tmp/assert-demo.zmq" | |
IPC_SOCKET = 'tcp://localhost:5555' | |
@sender_context = ZMQ::Context.new(2) | |
send_socket = @sender_context.socket(ZMQ::REQ) | |
second_send_socket = nil | |
send_socket.connect(IPC_SOCKET) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sparql/client' | |
require 'rest_client' | |
sparql = SPARQL::Client.new("http://dbpedia.org/sparql") | |
# existing functionality: | |
p sparql.query("select distinct ?Concept where {[] a ?Concept}").inspect | |
# now equivalent to: | |
response = RestClient.post 'http://dbpedia.org/sparql', { :query => "select distinct ?Concept where {[] a ?Concept}" }, :content_type => 'application/x-www-form-urlencoded', :accept => 'application/sparql-results+json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rubygems' | |
require 'ruby-debug' | |
require 'spira' | |
require 'rdf/rdfxml' | |
require 'sparql/client' | |
class Actor | |
include Spira::Resource |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# curl http://tmp.datagraph.org.s3.amazonaws.com/import/33f361f0-d1b2-012d-f3cf-0023df827da6 > curl | |
% Total % Received % Xferd Average Speed Time Time Time Current | |
Dload Upload Total Spent Left Speed | |
113 795 113 795 0 0 47522 0 --:--:-- --:--:-- --:--:-- 56785 | |
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# diff curl normalization-01.ttl | |
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# ls -al curl normalization-01.ttl | |
-rw-r--r-- 1 root root 795 2010-11-14 00:21 curl | |
-rw-r--r-- 1 lavender lavender 795 2010-10-29 05:46 normalization-01.ttl | |
root@ip-10-251-122-82:/home/lavender/spocq/src/test/rspec/tests/data-r2/i18n# irb1.9 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby1.9 | |
# local spira bug fix for bnode objects with Types::Any | |
$:.unshift '~/repos/spira/lib' | |
require 'spira' | |
require 'rdf/n3' | |
require 'rdf/isomorphic' | |
DAWG = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-dawg#') | |
MF = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#') | |
QT = RDF::Vocabulary.new('http://www.w3.org/2001/sw/DataAccess/tests/test-query#') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ben:promising-future ben$ rake bench; rake1.9 bench; jrake bench | |
(in /Users/ben/Repos/promising-future) | |
Rehearsal ---------------------------------------------------------- | |
Nothing 0.000000 0.000000 0.000000 ( 0.004472) | |
Nothing(Promise) 0.010000 0.000000 0.010000 ( 0.009008) | |
Nothing(Future) 0.120000 0.050000 0.170000 ( 0.168207) | |
A method 0.000000 0.000000 0.000000 ( 0.005997) | |
A method(Promise) 0.010000 0.000000 0.010000 ( 0.012526) | |
A method(Future) 0.130000 0.040000 0.170000 ( 0.171445) | |
#== 0.000000 0.000000 0.000000 ( 0.004996) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I hacked up methodmissing's promise to rename it to ExtPromise. Then I edited the benchmark program like so: | |
require "benchmark" | |
require "ext/promise/promise" | |
require "promise" | |
TESTS = 1000 | |
Benchmark.bmbm do |results| | |
# Picked inspect instead of undefined, as the pure-ruby promise will raise an | |
# exception on undefined instead of return the promise value |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ThreadTest | |
def initialize | |
# kicks off the thread, and only afterwards assigns thread to @t | |
@t = Thread.new { joiner } | |
end | |
def joiner | |
# without this sleep, will sometimes crash, | |
# as @t is not yet the thread, so will try to call @t.join on nil |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby1.9 | |
require 'rdf' | |
require 'rdf/rdfxml' | |
require 'rdf/ntriples' | |
require 'rdf/isomorphic' | |
s1 = %(<?xml version="1.0"?> | |
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'promise' | |
four = promise { 2 + 2 } | |
puts "respond_to? :odd? #{four.respond_to?(:odd?)}" | |
# => true | |
puts "respond_to? :asdfsa? #{four.respond_to?(:asdfasdf?)}" | |
# => false |