Created
July 30, 2013 20:35
-
-
Save jennifersmith/6116661 to your computer and use it in GitHub Desktop.
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 horse-ebooks.core | |
(:require [clojure.java.io :refer :all] | |
[clojure.string :as s])) | |
(defn foo | |
"I don't do a whole lot." | |
[x] | |
(println x "Hello, World!")) | |
(defn line-is-not-valid [a-line] | |
(< | |
(count a-line) | |
200)) | |
(defn tweetify [a-line] | |
(-> | |
a-line | |
(s/replace #"[^A-Za-z0-9 ]" " ") | |
(s/replace #"\s(lt|small|gt|lt|br|gt|lang|en|quot)\s" " ") | |
(s/replace #" +" " ") | |
(s/trim))) | |
(defn cut-at-word [line] | |
(apply str (take 140 line))) | |
(defn read-tweet [] | |
(with-open [our-file (reader "/tmp/foo")] | |
(->> | |
(line-seq our-file) | |
(drop (rand-int 100000)) | |
(drop-while line-is-not-valid) | |
(first) | |
(tweetify) | |
(cut-at-word)))) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment