This file contains 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
# Also see http://norvig.com/sudoku.html | |
from math import sqrt | |
def is_solved(raw_puzzle): | |
# Puzzle as a flat list. | |
puzzle = [int(v) for v in raw_puzzle.split()] | |
# Set up dimensions: for example N=81, n=9, and m=3. | |
N = len(puzzle) |
This file contains 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
def primes(): | |
''' | |
Yields a sequence of prime numbers via the Sieve of Eratosthenes. | |
This is a modified version of an approach I have seen in several | |
online discussions. | |
''' | |
# The sieve is stored in a dict S, where: | |
# | |
# values = all of the primes we have found so far (except 2) | |
# keys = the composites currently being sieved out. |
This file contains 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
# Create index. | |
curl -X DELETE localhost:9200/xx | |
curl -X PUT localhost:9200/xx | |
# Set up the mapping to handle very large integer fields. | |
curl -X PUT localhost:9200/xx/yy/_mapping -d '{"yy": {"properties": {"a": {"type": "string"}, "b": {"type": "string"}}}}' | |
# Index two documents, the second having very large integers. | |
curl -X PUT localhost:9200/xx/yy/1 -d '{"a": 123, "b": 456}' | |
curl -X PUT localhost:9200/xx/yy/2 -d '{"a": 933655199414565157, "b": 9917602859033623819}' |
This file contains 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 'spec_helper' | |
describe "recreating missing elements in a hierarchy" do | |
before(:all) do | |
class FooDoc | |
include OM::XML::Document | |
set_terminology do |t| | |
t.root :path => 'doc', :xmlns => 'foo' |
This file contains 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
1) Pre-assembly integration can run pre_assembly and produce expected files in staging dir | |
Failure/Error: @b.run_pre_assembly | |
NoMethodError: | |
undefined method `label' for #<ActiveFedora::SolrDigitalObject:0x111bcbf80> | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/active-fedora-3.3.2/lib/active_fedora/base.rb:197:in `label' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/dor-services-3.1.0/lib/dor/models/identifiable.rb:58:in `to_solr' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/active-fedora-3.3.2/lib/active_fedora/predicates.rb:47:in `each' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/active-fedora-3.3.2/lib/active_fedora/predicates.rb:47:in `each' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/rdf-0.3.5/lib/rdf/repository.rb:287:in `call' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/rdf-0.3.5/lib/rdf/repository.rb:287:in `each' |
This file contains 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
1) Pre-assembly integration can run pre_assembly and produce expected files in staging dir | |
Failure/Error: @b.run_pre_assembly | |
Rubydora::FedoraInvalidRequest: | |
Error getting dissemination for datastream workflows for object druid:wr622bz6218. See logger for details | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/rubydora-0.5.4/lib/rubydora/rest_api_client.rb:281:in `datastream_dissemination' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/rubydora-0.5.4/lib/rubydora/datastream.rb:117:in `content' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/dor-services-3.1.0/lib/dor/datastreams/workflow_ds.rb:32:in `content' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/active-fedora-3.3.2/lib/active_fedora/metadata_datastream_helper.rb:29:in `ensure_xml_loaded' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p357@pre-assembly/gems/active-fedora-3.3.2/lib/active_fedora/base.rb:258:in `to_solr' | |
# /Users/hindman/.rvm/gems/ruby-1.8.7-p |