Skip to content

Instantly share code, notes, and snippets.

@jennifersmith
Created July 30, 2013 20:35
Show Gist options
  • Save jennifersmith/6116661 to your computer and use it in GitHub Desktop.
Save jennifersmith/6116661 to your computer and use it in GitHub Desktop.
(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