Skip to content

Commit

Permalink
updated clojure.clj and README
Browse files Browse the repository at this point in the history
  • Loading branch information
amitrathore committed Aug 4, 2009
1 parent bb70146 commit 095a1c9
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
9 changes: 9 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
This has a bunch of utils I commonly use on other projects. They're grouped into areas, and each corresponds pretty much to one file of source code. The following are the broad ones:

* logger - stuff I've written to help me log messages and exceptions to a file
* mailer - helpful wrapper around the postal clojure library (which in turn wraps the JavaMail library)
* sql - helper functions to work with (shudder) SQL
* rabbitmq - helper functions to work with AMQP in general, and RabbitMQ in particular
* file - utilities to help working with the filesystem
* process - helpers to work with OS processes
* clojure - helper functions to enhance the clojure language
12 changes: 11 additions & 1 deletion src/org/rathore/amit/utils/clojure.clj
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,14 @@
`(let [start-time# (System/currentTimeMillis)
response# ~expr
end-time# (System/currentTimeMillis)]
{:time-taken (- end-time# start-time#) :response response# :start-time start-time# :end-time end-time#}))
{:time-taken (- end-time# start-time#) :response response# :start-time start-time# :end-time end-time#}))

(defn destructured-hash [attribs]
(let [d-pair (fn [attrib]
(list attrib (.replace (name attrib) "-" "_")))]
(apply hash-map (mapcat d-pair attribs))))

(defmacro def-hash-method [method-name params & exprs]
`(defn ~method-name [~(destructured-hash params)]
(do
~@exprs)))

0 comments on commit 095a1c9

Please sign in to comment.