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 connectors {:or " OR " | |
| :and " AND " | |
| :not " NOT "}) | |
| (defn -| [coll] | |
| (paren-wrap | |
| (apply str (interpose (:or connectors) | |
| (map build-querystring coll))))) | |
| (defn -& [coll] |
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
| (defn merge-queries [coll sep] | |
| (paren-wrap (apply str (interpose sep (map build-querystring coll))))) | |
| (defn -| [coll] (merge-queries coll (:or connectors))) | |
| (defn -& [coll] (merge-queries coll (:and connectors))) |
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 take(n, seq): | |
| "Return first n items of the seq as a list" | |
| return list(islice(seq, n)) | |
| def drop(n, seq): | |
| "Return seq with the first n items removed." | |
| return list(islice(seq, n, None, 1)) | |
| def split_by(n, seq): | |
| return [take(n, seq), drop(n, seq)] |
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
| (ns solr-disj.core | |
| (:require [clojure-solr :as csolr] | |
| [clojure.set] | |
| [clojure.string]) | |
| (:use [solr-disj.secret :only [solr-server]] | |
| [solr-disj.db] | |
| [icarus.core :only [-?>]] | |
| [korma.core] | |
| [korma.db] | |
| [clojure.data.xml])) |
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
| import time | |
| from datetime import datetime | |
| from lxml import etree | |
| def time_handler(s): | |
| t = time.strptime(s, "%m/%d/%Y %I:%M:%S %p") | |
| return time.strftime("%Y-%m-%dT%H:%M:%S%Z", t) | |
| def feed_parser(tree): |
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 kmp_match(seq, subseq): | |
| """ | |
| Implementation of the Knuth-Morris-Pratt (KMP) algorithm in Python. | |
| This algorithm finds valid shifts to locate subsequence `subseq` in | |
| sequence `seq`. | |
| """ | |
| n = len(seq) | |
| m = len(subseq) |
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
| from django.conf import settings | |
| from django.test import TestCase | |
| from django.test.simple import DjangoTestSuiteRunner, reorder_suite | |
| from django.utils.importlib import import_module | |
| from django.utils.unittest.loader import defaultTestLoader | |
| class DiscoveryDjangoTestSuiteRunner(DjangoTestSuiteRunner): | |
| """A test suite runner that uses unittest2 test discovery.""" | |
| def build_suite(self, test_labels, extra_tests=None, **kwargs): |
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
| BASE_PATH = os.path.dirname(__file__) | |
| TEST_DISCOVERY_ROOT = os.path.join(BASE_PATH, "tests") | |
| TEST_RUNNER = "tests.runner.DiscoveryDjangoTestSuiteRunner" | |
| SOUTH_TESTS_MIGRATE = False | |
| SKIP_SOUTH_TESTS = True |
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
| #!/home/matt/Envs/dseo/bin/python | |
| from django.core.management import execute_manager | |
| try: | |
| import settings # Assumed to be in the same directory. | |
| except ImportError: | |
| import sys | |
| sys.stderr.write( | |
| """ | |
| Error: Can't find the file 'settings.py' in the directory containing %r. | |
| It appears you've customized things. |
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 take(n, seq): | |
| "Return first n items of the seq as a list" | |
| return list(islice(seq, n)) | |
| def drop(n, seq): | |
| "Return seq with the first n items removed." | |
| return list(islice(seq, n, None, 1)) | |
| def split_by(n, seq): | |
| return [take(n, seq), drop(n, seq)] |