<commit_before>(ns notes.paas
  (:require
   [clojure.java.io :as io]
   [clojure.data.json :as json]))

(defn db-name "/notes")

(defn localhost-uri [uid pwd]
  (str "mongodb://" uid ":" pwd "@localhost:27017" db-name))

;-- dotCloud

(defn is-dotcloud? []
  (-> (io/file "/home/dotcloud/environment.json") .exists))

(defn dotcloud-uri [uid pwd]
  "Get dotCloud MongoDB URI. User 'uid' with password '<PASSWORD>' must exist
  for database 'notes'"
  (let [env-file "/home/dotcloud/environment.json"
        env (with-open [f (io/reader env-file)] (json/read f))
        mongo-host (get env "DOTCLOUD_MONGO_MONGODB_HOST")
        mongo-port (get env "DOTCLOUD_MONGO_MONGODB_PORT")]
    (str "mongodb://" uid ":" pwd "@" mongo-host ":" mongo-port db-name)))

;-- OpenShift
<commit_msg>Tweaked and tested on OpenShift.<commit_after>(ns notes.paas
  (:require
   [clojure.java.io :as io]
   [clojure.data.json :as json]))

(def db-name "notes")

(defn localhost-uri [uid pwd]
  (str "mongodb://" uid ":" pwd "@localhost:27017/" db-name))

;-- dotCloud

(defn is-dotcloud? []
  (-> (io/file "/home/dotcloud/environment.json") .exists))

(defn dotcloud-uri [uid pwd]
  "Get dotCloud MongoDB URI. User 'uid' with password '<PASSWORD>' must exist
  for database 'notes'"
  (let [env-file "/home/dotcloud/environment.json"
        env (with-open [f (io/reader env-file)] (json/read f))
        mongo-host (get env "DOTCLOUD_MONGO_MONGODB_HOST")
        mongo-port (get env "DOTCLOUD_MONGO_MONGODB_PORT")]
    (str "mongodb://" uid ":" pwd "@" mongo-host ":" mongo-port db-name)))

;-- OpenShift

{'fraction_non_alphanumeric': 0.1756926952141058, 'fraction_numerical': 0.006297229219143577, 'mean_word_length': 3.5142045454545454, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '465705', 'n_tokens_mistral': 627, 'n_tokens_neox': 614, 'n_words': 148}