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
| // Javascript can be so much more pleasant when it's functional -- re-implement | |
| // a bunch of utility methods from Prototype and Steele's Functional... | |
| window._ = { | |
| // The centerpiece, an each implementation. | |
| // Handles objects implementing forEach, _each, arrays, and raw objects. | |
| each : function(obj, iterator, context) { | |
| var index = 0; | |
| try { | |
| if (obj.forEach) { |
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
| def levenshtein(a, b) | |
| case | |
| when a.empty?: b.length | |
| when b.empty?: a.length | |
| else [(a[0] == b[0] ? 0 : 1) + levenshtein(a[1..-1], b[1..-1]), | |
| 1 + levenshtein(a[1..-1], b), | |
| 1 + levenshtein(a, b[1..-1])].min | |
| end | |
| end |
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
| full_text = Nokogiri::XML::Node.new('full_text', xml) | |
| full_text.content = File.read(path).gsub(/[^[:print:]]/, '') | |
| existence = Nokogiri::XML::Node.new('exists', xml) | |
| existence.content = '1' | |
| # Alternate approaches that don't work... | |
| # to_xs is way, way too slow for production -- especially if | |
| # we're rebuilding the index all the time. At least parallelize it | |
| # in CloudCrowd. | |
| # full_text.content = File.read(path).to_xs |
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
| <?xml version="1.0" encoding="UTF-8"?> | |
| <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
| <plist version="1.0"> | |
| <dict> | |
| <key>KeepAlive</key> | |
| <false/> | |
| <key>Label</key> | |
| <string>org.documentcloud.cloudcrowd</string> | |
| <key>Program</key> | |
| <string>crowd</string> |
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
| #! /bin/sh | |
| ### BEGIN INIT INFO | |
| # Provides: cloud-crowd | |
| # Required-Start: $all | |
| # Required-Stop: $all | |
| # Default-Start: 2 3 4 5 | |
| # Default-Stop: S 0 1 6 | |
| # Short-Description: starts a cloud-crowd node | |
| # Description: starts a cloud-crowd node using start-stop-daemon |
NewerOlder