Skip to content

Instantly share code, notes, and snippets.

View jcoyne's full-sized avatar

Justin Coyne jcoyne

  • Stanford University Libraries
  • Minneapolis, MN
View GitHub Profile
App.Router = Ember.Router.extend({
location: 'hash',
root: Ember.Route.extend({
index: Ember.Route.extend({
route: '/',
}),
nodes: Ember.Route.extend({
route: '/nodes/new/:fileBinding',
deserialize: function(router, params) {
@jcoyne
jcoyne / gist:3350207
Created August 14, 2012 15:15
Indexing record
class Document < ActiveRecord::Base
after_save :index_record
before_destroy :remove_from_index
private
def to_solr
#TODO - implement a hash serialization of this record
end
def index_record
SolrService.add(self.to_solr)
@jcoyne
jcoyne / gist:4045742
Created November 9, 2012 13:51
Setting default internal_encoding causes Encoding::UndefinedConversionError when writing to popen2
require 'open3'
Encoding.default_internal = Encoding::UTF_8 # works fine if this line is removed
file = File.open('sample.mp3', 'rb')
stdin, stdout, wait_thr = Open3.popen2('mpg321 - -w -|oggenc -')
stdin.write file.read
stdin.close
[{"actual_result":null,"created_at":"2012-11-19T21:17:50Z","dsid":"DC","expected_result":null,"id":9,"pass":1,"pid":"sufia:wp988j80x","updated_at":"2012-11-19T21:17:50Z","version":"DC1.0"},
{"actual_result":null,"created_at":"2012-11-19T21:17:50Z","dsid":"RELS-EXT","expected_result":null,"id":10,"pass":1,"pid":"sufia:wp988j80x","updated_at":"2012-11-19T21:17:50Z","version":"RELS-EXT.0"},
{"actual_result":null,"created_at":"2012-11-19T21:17:50Z","dsid":"rightsMetadata","expected_result":null,"id":11,"pass":1,"pid":"sufia:wp988j80x","updated_at":"2012-11-19T21:17:50Z","version":"rightsMetadata.0"},
{"actual_result":null,"created_at":"2012-11-19T21:17:50Z","dsid":"properties","expected_result":null,"id":12,"pass":1,"pid":"sufia:wp988j80x","updated_at":"2012-11-19T21:17:50Z","version":"properties.0"},
{"actual_result":null,"created_at":"2012-11-19T21:17:50Z","dsid":"content","expected_result":null,"id":13,"pass":1,"pid":"sufia:wp988j80x","updated_at":"2012-11-19T21:17:50Z","version":"content.0"},
{"actual_result"
[|{ : nameI"active-fedora:ET: numberI"5.0.0.rc3;T: platformI" ruby;T:dependencies[[I"deprecation;TI" >= 0;T[I"rdf-rdfxml;TI" ~> 0.3.8;T[I"rdf;TI" >= 0;T[I" rubydora;TI"~> 0.5.13;T[I"mediashelf-loggable;TI" >= 0;T[I" builder;TI" ~> 3.0.0;T[I"activesupport;TI" >= 3.0.0;T[I"activeresource;TI" >= 3.0.0;T[I" solrizer;TI"~> 2.0.0.rc6;T[I"om;TI"~> 1.8.0.rc1;T[I" rsolr;TI" >= 0;T{ ;I"active-fedora;T;I"5.0.0.rc2;T;I" ruby;T; [[I"deprecation;TI" >= 0;T[I"rdf-rdfxml;TI" ~> 0.3.8;T[I"rdf;TI" >= 0;T[I" rubydora;TI"~> 0.5.13;T[I"equivalent-xml;TI" >= 0;T[I"mediashelf-loggable;TI" >= 0;T[I" builder;TI" ~> 3.0.0;T[I"activesupport;TI" >= 3.0.0;T[I"activeresource;TI" >= 3.0.0;T[I" solrizer;TI"~> 2.0.0.rc6;T[I"om;TI"~> 1.8.0.rc1;T[I" rsolr;TI" >= 0;T{ ;I"active-fedora;T;I"5.0.0.rc1;T;I" ruby;T; [[I"deprecation;TI" >= 0;T[I"rdf-rdfxml;TI" ~> 0.3.8;T
Rubydora::FedoraInvalidRequest:
See logger for details
# /Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/rubydora-1.0.0/lib/rubydora/rest_api_client.rb:24:in `block (2 levels) in <module:RestApiClient>'
# /Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/rescuable.rb:80:in `call'
# /Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/rescuable.rb:80:in `rescue_with_handler'
# /Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/rubydora-1.0.0/lib/rubydora/rest_api_client.rb:284:in `rescue in add_datastream'
# /Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/rubydora-1.0.0/lib/rubydora/rest_api_client.rb:276:in `add_datastream'
# /Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/rubydora-1.0.0/lib/rubydora/datastream.rb:247:in `block in create'
# /Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/activesupport-3.2.9/lib/active_support/callbacks.rb:403:in `_run__2331759158968185283__create__1948477632319260046__callbacks'
/Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/cucumber-1.2.1/lib/cucumber/js_support/js_dsl.js:3: syntax error, unexpected '{', expecting keyword_then or ';' or '\n'
/Users/justin/.rvm/gems/ruby-1.9.3-p286/gems/cucumber-1.2.1/lib/cucumber/js_support/js_dsl.js:6: syntax error, unexpected keyword_else, expecting '}'
else{
mjgiarlo: I noticed you aren't using mod_deflate on scholarsphere's web server.
Compressing the following resources with gzip could reduce their transfer size by 431.2KiB (71% reduction).
• Compressing https://scholarsphere.psu.edu/assets/application-5dede70da34d4edfb933650cd332af32.js could save 225.6KiB (71% reduction).
• Compressing https://scholarsphere.psu.edu/assets/application-e16714cb31d1271c456c85a3e9e7ddcd.css could save 119.8KiB (82% reduction).
• Compressing https://scholarsphere.psu.edu/assets/Lato-Light.ttf could save 66.6KiB (55% reduction).
• Compressing https://scholarsphere.psu.edu/ could save 19.3KiB (79% reduction).
mjgiarlo: also cache headers for assets:
<LocationMatch "^/assets/.*$">
Header unset ETag
FileETag None
@jcoyne
jcoyne / gist:4774986
Created February 13, 2013 00:17
Fedora4Lib hack in jruby
require 'java'
java_import 'org.fcrepo.services.DatastreamService'
java_import 'org.springframework.context.ApplicationContext'
java_import 'org.springframework.context.support.ClassPathXmlApplicationContext'
ctx = org.springframework.context.support.ClassPathXmlApplicationContext.new("spring-test/repo.xml");
@jcoyne
jcoyne / gist:5158691
Created March 14, 2013 03:53
I'm trying to write Ruby's inject method in Elixir.
defmodule Foo do
def bar(acc, [H | T]) do
acc + H + bar(T)
end
def bar(acc, []) do
acc
end
end