Category Archives: clojure

Graphing Unique Users With Incanter 1

In a previous post, I showed how we could use Clojure and specifically Incanter to process access logs to graph hits on our site. Now, we’re going to adapt our solution to allow us to to show the number of unique users over time. We’re going to change the previous solution to pull out the [...]

Graphing Hits Per Minute Using Clojure & Incanter 3

Continuing in a re-occurring series of posts showing my limited understanding of Clojure, today we’re using Clojure for log processing. This example is culled from some work I’m doing right now in the day job – we needed to extract usage information to better understand how the system is performing. The Problem We have an [...]

Creating Sparse Tabular Data With Clojure 3

In the spirit of making my mistakes in public – something which I have a long history of on this blog – I thought I’d post up a solution I came up with for a relatively simple problem. I’m not unhappy with the solution – it works – but I can’t help thinking I’m missing [...]

Executing A Command Line Program With Clojure 3

Updated to reflect some feedback and one example of using commons-exec as an alternative to the plain old Runtime.exec Second Update to reflect use of shell-out – thanks Scott! Basic Making use of clojure.contrib.duck-streams: (ns utils (:use clojure.contrib.duck-streams)) (defn execute [command] (let [process (.exec (Runtime/getRuntime) command)] (if (= 0 (.waitFor process)) (read-lines (.getInputStream process)) (read-lines [...]

Clojure, Partially Applied Functions And Java Interop 3

I’ve been playing around with partially applied functions in Clojure, and have hit an interesting snag when dealing with Java interop. First, lets examine what partial does in Clojure, by cribbing off an example from Stuart Halloway’s Programming Clojure: user=> (defn add [one two] (+ one two)) #’user/add user=> (add 1 2) 3 user=> (def [...]

In Clojure, Those Parenthesis Really Matter 1

Posted in the “I hope no-one else has to go through this” category in the hope that Google surfaces this for some other poor soul. Picture a rather trivial split function: (defn split [str delimiter] ((seq (.split str delimiter)))) Which helpfully spits out: java.lang.ClassCastException: clojure.lang.ArraySeq cannot be cast to clojure.lang.IFn The issue here is the [...]

Struggling with Test Driven Clojure 10

I’ve recently been working on a Clojure application that I hope to open source soon. It’s been my first experience of using Clojure, and is almost certainly one of the most thought provking things I’ve done in a long while. One of the things that is still causing me issues is how to go about [...]

Clojure on App Engine – my take 1

I’ve been working on a couple of spare time projects, both of which I hope to release more formally in the next few weeks. One of them involves development of a simple web application for deployment on Google App Engine. As part of the development, I had to modify an existing open source Clojure API [...]

Clojure editor/IDE options – IntelliJ v Emacs 6

So all the cool Clojure kids keep wanting me to use Emacs. The problem is that I haven’t used Emacs for the last 10 years – since, in fact, I had to support a C application on about 7 different flavours of UNIX. As you can imagine, I’ve since expunged many of those past memories. [...]

Data Transformation and Language Syntax 5

I’m currently working on a personal project by way of learning Clojure – it’s actually a program to match up my itemised phone bill against my list of contacts to help me expense my calls. I find it best to have a real-world problem I need to solve to learn a new programming language. The [...]