Created
February 12, 2014 17:24
-
-
Save wjdix/8960250 to your computer and use it in GitHub Desktop.
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- consumer-queue [dequeue] | |
(lazy-seq | |
(let [head (.take dequeue)] | |
(cons head (consumer-queue dequeue))))) | |
(defn- send-in-batches [tweet-list] | |
(loop [tweets tweet-list] | |
(send-tweet-emails (take 2 tweets) (System/getenv "GMAIL_PASS")) | |
(recur (drop 2 tweets)))) |
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- add-tweet [queue tweet] | |
(if (not (= tweet ""))(.offer queue tweet))) | |
(defn- parse-tweet [response] | |
(:text (try (json/read-json (str response)) | |
(catch Exception e | |
(println (str e " Parsing Exception")) | |
{:text ""})))) | |
(defn- success_handler [queue] | |
(fn [a response] | |
(add-tweet queue (parse-tweet response)))) | |
(defn- | |
print-callback [queue] | |
(AsyncStreamingCallback. (success_handler queue) | |
(comp println response-return-everything) | |
exception-print)) | |
(defn fetch-tweets [queue oauth-credentials] | |
(statuses-filter :params {:follow braintreeTwitterID} | |
:oauth-creds oauth-credentials | |
:callbacks (print-callback queue))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment