Skip to content

Instantly share code, notes, and snippets.

Warning: The file properties have changed:
File: /usr/bin/dpkg
Current hash: 8e820f6ffa1ba84be7c5256a8bd344a49fec7182
Stored hash : 7c5ab2420dfddf22f3794a1f2aa4b61243e44a08
Current inode: 52015 Stored inode: 1969
Current file modification time: 1268271700
Stored file modification time : 1253435089
Warning: The file properties have changed:
File: /usr/bin/dpkg-query
Current hash: b5a6de09d70cd24592cb59dbdd2d58e9280a7cc0
(defn connect [server]
(let [socket (Socket. (:name server) (:port server))
in (BufferedReader. (InputStreamReader. (.getInputStream socket)))
out (PrintWriter. (.getOutputStream socket))
conn (ref {:in in :out out})]
(doto (Thread. #(conn-handler conn)) (.start))
conn))
(defn write [conn msg]
(doto (:out @conn)
;; load paths
(setq dotfiles-dir (file-name-directory
(or (buffer-file-name) load-file-name)))
(add-to-list 'load-path dotfiles-dir)
(if (fboundp 'normal-top-level-add-subdirs-to-load-path)
(let* ((my-lisp-dir "~/.emacs.d/elpa-to-submit")
(default-directory my-lisp-dir))
(setq load-path (cons my-lisp-dir load-path))
(ns walton.core
(:use clojure.contrib.duck-streams
clojure.contrib.str-utils
clojure.contrib.seq-utils
clj-html.core
net.licenser.sandbox
walton.integration
walton.web
ring.util.response)
(:gen-class))
@devn
devn / core.clj
Created April 1, 2010 16:16 — forked from Licenser/core.clj
(defn truncate [t coll]
(map (fn [ct]
(if (>= (count ct) t)
(apply str (take t ct) "...")
ct)) coll))
(defn walton*
[#^String s t m?]
(let [result (walton-doc s)]
(defn truncate
"A one off truncation function which takes a coll in the form of \"[:a, :b]\". Provided a [t]runcation length (in characters), it will truncate :a or :b and supply a new \"[\":a...\", \":b...\"]\"."
[coll t]
(let [c coll
ct (first c)
rt (second c)]
[(if (>= (count ct) t)
(apply str (take t ct) "...")
ct)
(if (>= (count rt) t)
(defn truncate [coll t]
(let [c coll
ct (first c)
rt (second c)]
[(if (>= (count ct) t)
(apply str (take t ct) "...")
ct)
(if (>= (count rt) t)
(apply str (take t rt) "...")
rt)]))
@devn
devn / web.clj
Created April 1, 2010 14:47 — forked from swannodette/web.clj
(ns defn-test
(:use clj-html.core
[net.cgrand.moustache :only [app]]
[ring.adapter.jetty :only [run-jetty]]
[ring.util.response :only [response]]))
(defhtml application [text body]
[:html
[:head
[:title text]]
(def walton-web
(app
["examples" text]
{:get [(fn [req] (walton-doc* text))]}
[#".*"] {:get ["all routes!"]}))
(defhtml application [text body]
[:html
[:head
[:title text]]
[:body
[:h3 text]
body]])
(defhtml code-list [body]
[:ul body])