Skip to content

Instantly share code, notes, and snippets.

View no-reply's full-sized avatar

tamsin woo no-reply

  • UC Santa Barbara Library
  • United States
View GitHub Profile
(require 'ruby-mode)
(add-to-list 'auto-mode-alist
'("\\.\\(?:cap\\|gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" . ruby-mode))
;; Ruby mode
(add-hook 'ruby-mode-hook 'robe-mode)
(add-hook 'ruby-mode-hook 'company-mode)
(add-hook 'ruby-mode-hook 'electric-pair-mode)
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 "."
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 February 10, 2017 19:42
#neverActiveSupport
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 December 29, 2016 21:00
CurationConcerns CI failure with FileSet error
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 December 29, 2016 20:56
CurationConcers CI failure with SOLR error
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)>'
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 June 10, 2016 05:22
Baby's First Rust Server
[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 June 4, 2016 22:06
HAMT RDF::Repository Thread Safety

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
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)) }