Getting ShowOff source code high-lighting for Clojure

ShowOff is a presentation software where you create your slides by writing simple text files containing markdown formatting. Styling is done using CSS. The slides are served by a web server and can be displayed in a web browser. With a simple command, a presentation can be deployed on Heroku for everyone to see. ShowOff [...]

Tags:

Clojure third language officially supported on Heroku

According to this blog entry on Heroku, Clojure becomes the third language officially supported on the Cedar stack, after Ruby and Node.js. They write: – “Clojure combines the expressiveness of Lisp, the agility of a dynamic language, the performance of a compiled language, and the wide applicability of the JVM in a robust, production-ready package. [...]

Tags: , , ,

Deploying a Clojure web app on Heroku

Heroku is a cloud application platform for Ruby/Rails and Node.js. However, the Cedar stack on Heroku makes it possible to deploy other types of applications. In this blog entry, I will first describe how to write a simple Clojure web app using the Ring library and the build tool Leiningen. Then I will show how to deploy this Clojure web app on Heroku, using nothing but Git. I will make a change and see how to deploy that. I will also show how to easily roll back to a previous release.

Tags: , , , , ,

Numerical Integration (With Precision)

In a previous blog entry, I explained the higher-order function sum and how to use the Substitution Model to follow the execution of a function. In this entry, I will use the sum function to perform numerical integration, and in the process run into some pitfalls of Java’s BigDecimal. I will show how the language Clojure provides an elegant solution to the “exact quotient cannot be represented” problem of BigDecimal.

Tags: , , , , ,

The Substitution Model: A Tool For Understanding Recursion

Section 1.3 in Structure and Interpretation of Computer Programs is about Formulating Abstractions with Higher-Order Procedures. As an example, the authors use three simple sums: a sum of an integer range a sum of the cubes of an integer range a sum of a series that converges to π/8 The purpose is to highlight what [...]

dbg: A Cool Little Clojure Macro

Here’s the development of a tiny little macro that is actually pretty useful. The post is quite verbose, because I explain a lot. I want a debug function that first prints the “quoted” (unevaluated) code and then what it evaluates to, so I can write something like this: user> (dbg (+ 1 2)) dbg: (+ [...]

Tags: , ,

The country that nearly drove me crazy

I just upgraded my OpenLDAP to 2.4.21 and suddenly I couldn’t load an LDIF that we in Spring LDAP have used successfully for years. % ldapadd -Dcn=Manager,dc=jayway,dc=se -wsomepwd -f /tmp/t.ldif adding new entry “ou=groups,dc=jayway,dc=se” adding new entry “c=Sweden,dc=jayway,dc=se” ldap_add: Invalid DN syntax (34) After some time of swearing and random changes, I managed to find [...]

Tags:

The Golden Ratio

Also known as the “Divine Quotient”, the Golden Ratio was given an almost magical meaning during the renaissance, but it’s actually much older than that. Leonardo DaVinci used it. Euclid used it. It was supposedly discovered by Pythagoras. So, what is it? It’s very simple. Take a length and divide it into two parts: a [...]

Tags: , , , ,

The Power of Unit Testing

The purpose of Unit Testing is to verify for the developer that a software unit does what it is supposed to and is fit for use. The confidence that the developer gets, gives the developer courage to do other useful practices like Refactoring. Unit testing is often used to test complex units with one or [...]

Tags: ,

Upgrading Groovy to 1.6.2 Fails on Mac

When I tried to upgrade Groovy from 1.6.1 to 1.6.2 using MacPorts, it failed with an OutOfMemoryError. I managed to get it to build using some manual fixing in the build file. I’ll explain what I did in this blog. This was the result that I got: $ sudo port upgrade groovy —> Building groovy [...]

Tags: , , , , ,

Always Use Parenthesis in Groovy Builders

I recently ran into an interesting Groovy feature when demonstrating the strengths of the MarkupBuilder. As you probably know, parenthesis in a Groovy method call are optional, unless it’s a no-args call. In that case the parenthesis are needed in order to distinguish the call from a property. However, leaving out parenthesis in a Builder is asking for trouble. I’ll show you why.

Tags: , , , , ,

Getting Coverage For Integration Tests

Unit testing in my world is basically defined by being able to run the tests wherever and whenever; on the train, on the plane, at work, or at home. If you also have integration tests, chances are that they require some external data source or something that simply makes it impossible to run them everywhere. [...]

Tags:

Encrypting Properties With Jasypt

Properties are used in many Java applications as a simple way of separating parts that are likely to change, from the parts that are not that likely to change. Consider for example this typical bean definition in a Spring configuration file:   <bean id="traditionalPersonDao" class="org.springframework.ldap.samples.article.dao.TraditionalPersonDaoImpl"> <property name="url" value="ldap://localhost:3901" /> <property name="base" value="dc=jayway,dc=se" /> <property name="userDn" [...]

Tags: , , ,

Squid, the caching proxy

I just checked out the old Squid again, the worlds most famous caching proxy. If you direct all your web access through the Squid proxy server, it will cache stuff after the first access. This would simplify for example for labs where fifty people simultaneously begin retrieving stuff from a Maven repo somewhere or downloading [...]

Tags: , , , , ,

Using Amazon S3 for backup

Amazon Simple Storage Service (S3) is cheap on-line storage with a Web Service interface. You just log in with your Amazon id, sign up for S3, designate a credit card, and that’s it. You now have access to pretty much unlimited storage space, managed by Amazon. The price is $0.15 per GB-Month of storage used [...]

Tags: , , , , , , ,