Skip to content

Instantly share code, notes, and snippets.

✔️

Tom Johnson no-reply

✔️
Block or report user

Report or block no-reply

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:d07c751074510ba4643484f1d19ddabc
tjohnson@hopper:~/src/hyrax$ bundle exec rake engine_cart:regenerate
Removing sample rails app
create
/home/tjohnson/.rbenv/versions/2.5.3/lib/ruby/2.5.0/fileutils.rb:122: warning: conflicting chdir during another chdir block
create README.md
create Rakefile
create config.ru
create .gitignore
create Gemfile
run git init from "."
View custom_actor.rb
class MyActor < Hyrax::Actors::AbstractActor
def create(env)
titlilze(env, attribute: :title) && next_actor.create(env)
end
private
def titlize(env, attribute:)
env.attributes[:attribute] = env.attributes[:attribute].map(&:titlize)
end
@no-reply
no-reply / as.rb
Created Feb 10, 2017
#neverActiveSupport
View as.rb
class Circle
def intialize
@circle = self
end
end
require 'active_support/core_ext/object/json'
Circle.new.as_json
# SystemStackError: stack level too deep
@no-reply
no-reply / curation_concerns_engine_cart.txt
Created Dec 29, 2016
CurationConcerns CI failure with FileSet error
View curation_concerns_engine_cart.txt
Running RuboCop...
Inspecting 531 files
...................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
531 files inspected, no offenses detected
create
create README.md
create Rakefile
create config.ru
create .gitignore
@no-reply
no-reply / curation_concerns_solr.txt
Created Dec 29, 2016
CurationConcers CI failure with SOLR error
View curation_concerns_solr.txt
Done generating test app
rake aborted!
Failed to execute solr create:
ERROR:
Core 'hydra-test' already exists!
Checked core existence using Core API command:
http://localhost:53179/solr/admin/cores?action=STATUS&core=hydra-test
. Further information may be available in /tmp/solr-6.3.0/logs
/home/tjohnson/src/hydra/curation_concerns/Rakefile:24:in `block (2 levels) in <top (required)>'
View pattern.rb
require 'rdf'
require 'rdf/spec'
statements = RDF::Spec.quads
statements.extend(RDF::Enumerable, RDF::Queryable)
statements.count # => 95
pattern = RDF::Query::Pattern.new(nil, nil, nil, graph_name: false)
@no-reply
no-reply / Cargo.toml
Last active Jun 10, 2016
Baby's First Rust Server
View Cargo.toml
[package]
name = "hello_server"
version = "0.1.0"
authors = ["Tom Johnson <n0reply@uw.edu>"]
[dependencies]
hyper = "~0.9.7"
log = "*"
env_logger = "*"
@no-reply
no-reply / hamt_repo_threading.markdown
Last active Jun 4, 2016
HAMT RDF::Repository Thread Safety
View hamt_repo_threading.markdown

Threading

While our new RDF::Repository implementation theoretically improves the concurrency story for RDF.rb, it isn't, in itself, thread safe. The underlying data representation may be purely functional, but the Repository itself is swimming in shared mutable state. Specifically, we have the potential for a data race during execution of code like @data = data; and, more generally, for race conditions wherever our changes depend on previous reads. Notably, this affects #transaction, as demonstrated in the following snippet:

require 'rdf'
repo = RDF::Repository.new

threads = []
err_count = 0
View gen_dataset.rb
require 'rdf/turtle'
require 'json/ld'
g = RDF::Graph.load('http://json-ld.org/test-suite/reports/ruby-earl.ttl')
File.open('ruby-earl.json', 'w') { |file| file.write(g.dump(:jsonld, standard_prefixes: true)) }
File.open('ruby-earl.nt', 'w') { |file| file.write(g.dump(:ntriples)) }
View infinite_enum.rb
my_enum = (1..5).lazy.map { |i| i == 3 ? raise(StandardError) : i }
safe_enum = Enumerator.new do |y|
loop do
begin
y.yield my_enum.next
rescue => e
break if e.kind_of? StopIteration
end
end
You can’t perform that action at this time.