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
-- | |
-- Assume that you have a table - `customers`... create a new table called | |
-- `customers_audit` with the following qualities: | |
-- | |
create table if not exists customer ( | |
-- assumming you have a primary key that's a uuid | |
id uuid not null, | |
-- ...make sure to have a version and timestamp | |
version integer not null, | |
as_of timestamp with time zone not null, |
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
(ns ns-toolkit.db.polaris | |
"Namespace for accessing the Polaris database for all the data it has." | |
(:require [ns-toolkit.config :as cfg] | |
[ns-toolkit.db :as db] | |
[ns-toolkit.logging :refer [log-execution-time!]] | |
[cheshire.core :as json] | |
[clj-time.coerce :refer [to-timestamp from-date]] | |
[clojure.java.jdbc :refer [IResultSetReadColumn ISQLValue result-set-read-column] :as sql] | |
[clojure.string :as cs] | |
[clojure.tools.logging :refer [error errorf warnf infof info]] |
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
(defn- get-block | |
"Function to get one block from LenderX based on the URL and start and limit | |
values provided. Typically we should keep the `limit` to 25 or less, but this | |
function will be called for each block - as needed, from LenderX for the | |
provided URL." | |
[url st lim & [sess]] | |
(if (and (string? url) (not (neg? st)) (pos? lim)) | |
(let [ep (str url (if (neg? (.indexOf url "?")) "?" "&") "start=" st "&limit=" lim) | |
] | |
(-> (do-get* cm ep (mk-headers "GET" ep nil sess) lenderx-opts) |
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
(ns ns-toolkit.metrics | |
"This is the code that handles the metrics and events through the Dropwizard | |
Metrics core library, which, in turn, will ship it over UDP to the DataDog | |
Agent running on localhost." | |
(:require [clojure.tools.logging :refer [infof debugf warnf errorf]]) | |
(:import [com.codahale.metrics MetricRegistry] | |
[org.coursera.metrics.datadog DatadogReporter] | |
[org.coursera.metrics.datadog.transport UdpTransportFactory | |
UdpTransport] | |
[java.util.concurrent TimeUnit])) |
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
:dependencies [[base64-clj "0.1.1"]] |
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
(ns cq.logging | |
"Logging utilities." | |
(:require [clojure.tools.logging :refer [log]] | |
[robert.hooke :refer [add-hook]])) | |
(defn now [] (System/currentTimeMillis)) | |
(defn execution-time-logging-hook | |
"Given a config map, returns a hook function that logs execution time." | |
[{:keys [level func-name msg msg-fn ns] :or {level :info}}] |
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
(ns my-prog.database | |
"Namespace for accessing the database for all the persistent data we will | |
be gathering and serving up." | |
(:require [my-prog.config :as cfg] | |
[my-prog.logging :refer [log-execution-time!]] | |
[cheshire.core :as json] | |
[clj-time.coerce :refer [to-timestamp from-date]] | |
[clojure.java.jdbc :refer [IResultSetReadColumn result-set-read-column] :as sql] | |
[clojure.string :as cs] | |
[clojure.tools.logging :refer [error errorf warnf infof info]] |
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
(ns bartender.dcm | |
"The DCM-specific functions for loading data. The Google OAuth2 data for the | |
application is obtained from the Developer Console." | |
(:require [bartender.util :refer [parse-json update lcase]] | |
[cheshire.core :as json] | |
[clj-http.client :as http] | |
[clj-oauth2.client :as oauth2] | |
[clj-time.coerce :refer [to-long from-long]] | |
[clj-time.core :refer [now]] | |
[clojure.set :refer [rename-keys]] |
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
(defn return-json | |
"Creates a ring response for returning the given object as JSON." | |
([ob] (return-json ob (now) 200)) | |
([ob lastm] (return-json ob lastm 200)) | |
([ob lastm code] | |
{:status code | |
:headers {"Content-Type" "application/json; charset=UTF-8" | |
"Last-Modified" (str (or lastm (now)))} | |
;; TODO: the input-stream tactic is foiled by ring.middleware.jsonp | |
;; which slurps the whole stream before adding the callback. Could |
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
(ns finch-experiments.bucket | |
"Namespace to deal with all the bucketing issues with the experiments and | |
users so that we can respond as the finch client would." | |
(:require [clj-endpoints :as ep] | |
[clj-endpoints.logging :refer [log-execution-time!]] | |
[clj-endpoints.util :refer [md5 to-uuid nil-if-empty compact]] | |
[finch-experiments.routing :as routing] | |
[finch-experiments.web :as web] | |
[finch-experiments.data :refer [experiment-list]])) |
NewerOlder