Skip to content

Instantly share code, notes, and snippets.

(defn devin [walters]
(println "yep, it works..."))
@devn
devn / gist:243191
Created November 26, 2009 02:26
This is some rudimentary code to create an http connection to the twitter firehose.
(ns twitjure
(:use clojure.core)
(:use clojure.contrib.http.connection)
(:use clojure.contrib.base64)
(:use clojure.contrib.duck-streams))
(defn get-stream []
(let [conn #^java.net.HttpURLConnection
(http-connection "http://stream.twitter.com/1/statuses/sample.json")]
(.setDoInput conn true)
(defn take-tweets [n]
(take n (map read-json
(line-seq (reader
(get-stream))))))
(defn tweet-text [n]
(map #(get % "text")
(take-tweets n)))
(defn search-text [s coll]
@devn
devn / 11*
Created November 30, 2009 05:19
va.lang.NullPointerException
[Thrown class java.lang.RuntimeException]
Restarts:
0: [ABORT] Return to SLIME's top level.
1: [CAUSE] Throw cause of this exception
Backtrace:
0: clojure.lang.LazySeq.sval(LazySeq.java:47)
1: clojure.lang.LazySeq.seq(LazySeq.java:63)
(ns doc-ns
(:gen-class)
[:use clojure.contrib.duck-streams
compojure])
(defn sort-ns
"Sorts the keys from the map returned by ns-publics for a given nspace into alphabetical order."
[nspace]
(sort (keys (ns-publics nspace))))
(ns doc-ns.core
(:gen-class)
[:use clojure.contrib.duck-streams
compojure])
(defn sort-ns
"Sorts the keys from the map returned by ns-publics for a given nspace into alphabetical order."
[nspace]
(sort (keys (ns-publics nspace))))
(defproject doc-ns "1.0.0-SNAPSHOT"
:description "Writes documentation for a namespace to a text file.
Usage: java -jar doc-ns.jar \"compojure\" \"~/\" \"myfile.txt\""
:dependencies [[org.clojure/clojure
"1.1.0-alpha-SNAPSHOT"]
[org.clojure/clojure-contrib
"1.0-SNAPSHOT"]
[org.clojars.ato/compojure
"0.3.1"]]
:dev-dependencies [[org.clojure/swank-clojure
(ns cljex.view
[:use compojure])
(defn api-entry
[doc-path]
(html-tree
[:h2 [:a {:href doc-path}]]))
;; (defn example-entry
;; [example-entry])
(ns cljex.core
(:gen-class)
[:use compojure,
clojure.contrib.duck-streams,
clojure.contrib.shell-out,
clojure.contrib.str-utils,
cljex.view]
[:import java.io.File])
(defn get-markdown-paths
<p><html>
<head>
<link rel="stylesheet" href="pygmentize.css" type="text/css" media="screen" charset="utf-8">
</head>
<body></p>
<h1>Foreword</h1>
<p>This is a very rough draft of the tutorial I'm going to put on
compojure.org. It's not complete, but it covers most of the basics. There's a possibility some of the terminology (such as handlers and routes) might change, but I'll let you know if it does. The technical content, however, should be accurate and up to date. Criticism is very welcome; I'd like to know if anything is unclear or could be better worded, or if I'm missing out anything. </p>
<h1>Compojure from the bottom up</h1>
<h2>Handlers</h2>