My Tedious Blog

Thursday, July 23, 2015

Today is my last day at IBM and I'm sad to be leaving. I applied to IBM in 2000, partly because I was impressed by the company's early support for the open source movement and partly because an IBMer visiting Warwick University had told us that, were IBM Hursley to be an independent software company at that time, it would have been the sixth largest software company in the world. Mostly, though, it was because IBM promised each student a beer in exchange for a CV. It should be noted that IBM never followed through on that particular promise, giving us instead a glass of wine each. A bit of a bait-and-switch, I'm sure you'll agree, but a classy one.

I only intended to stay at IBM for three years but ended up staying for nearly 14. There are many reasons for this and many things that I am still reluctant to leave behind. Hursley is still a great place to work with a wonderfully creative atmosphere. To work in a campus environment in the beautiful Hampshire countryside is something that I'll miss as I brave the sharp elbows of stressed London commuters over the coming months. Hursley itself is lovely, even if the locals describe IBM as "the funny farm". The greatest of the perks of working in IBM Hursley is the people. I've made some of my best friends here and I've had the privilege of working with some truly brilliant people.

I'm now off to Masabi to work in a much more startup-ey environment, which is both exciting and also rather scary. I'll miss IBM and my friends and former colleagues, though. You guys rule.

Thursday, November 27, 2014

Today, I had extract a PAX archive file on a mainframe. Having never done this before, I stumbled for a while until I figured out how to do it. For future reference, here's what I needed to do in order to unzip archive.pax:

pax -r < archive.pax

The Wikipedia page for the pax command is a useful source of example usage:

Wednesday, September 24, 2014

In a previous blog post, I talked about running a Clojure web app on IBM Bluemix using the Heroku buildpack for Clojure. This isn't the only way that you can run Clojure code on Bluemix, though. In this post, I'll talk about running the same Hello World application using the WebSphere Liberty Buildpack. This buildpack is built in to Bluemix and has the ability to run a web application, in this case packaged as a WAR file.

I've added an uberwar-name key to the :ring section. This is the name of the generated WAR file that we'll generate. Also note that the version of lein-ring must be at least 0.8.11 in order to generate a conformant WAR in order to work with the Liberty buildpack.

Finally, it's a relatively simple matter to push our WAR to Bluemix. Note that this time, we don't use -b to specify a buildpack (since the WebSphere Liberty buildpack is built in to Bluemix). In addition, we use -p to specify the path of the artefact that we want to push, in this case the WAR file.

OK so once again, this isn't especially exciting but this process is equally applicable to larger and more complex applications as it is to the simple one that we deployed here. Using the WebSphere Liberty buildpack allows us to run our application on top of code that was specially designed for Bluemix and it allows us to build our application once, on the client, and then deploy the built application as one WAR file. Contrast this with the Heroku buildpack for Clojure which uploads Clojure source code to the server and then compiles it there.
There is a third way to run Clojure on Bluemix, which is to build your app into a runnable jar file (together with an embedded web server such as Jetty). I might cover that briefly in a future blog post.

This is a test to see if I can write a blog post in org-mode, output
the whole thing to HTML and then have it look half decent in my
Blogger blog.

Here is some Clojure source:

(defnmy-function [message]
(println"The message is: " message))

I turn the org-mode source into HTML by hitting C-c C-e (to execute
org-export) and then I hit H to put the resulting export into a new
buffer. It's then easy to copy the contents into Blogger's raw HTML
view.

The result doesn't look completely terrible to my eyes. If you don't like the light blue background for the source code then I'm afraid that I must take credit for having chosen that but the good bits were output by htmlize. To be honest, though, I'm not sure what this setup currently buys me, over and above editing the text in Blogger's editor and then using htmlize to output each snippet of source code separately and then copying it into its own <pre> block.

All of this raises the question of why I am still using Blogger in
this day and age. To be honest, it's more a matter of inertia than
anything else. I'd really like to get round to trying to use something like Jekyll
(which seems very cool) or Wordpress (which everyone else
seems to have been using since the year dot) but Blogger is what I have been using, on and off, since
2006 and it seems to work relatively well, despite being rather
annoying and despite being closed source and a wee bit dumbed
down. Thankfully, Blogger does let me customise pretty much all of the
HTML and CSS that it spews out and it will have to do until I find the
time to properly learn (and migrate to) something else.

If you see this then you can work around it by moving the dependency on javax.servlet/servlet-api "2.5" out of :dev :dependencies and into :dependencies (or just clone the latest code from https://github.com/cdpjenkins/hello-clojure). I'll update this once I get to the bottom of why this started failing for some people.
</EDIT>

Today, I signed up for a free trial account on the public beta of Bluemix, IBM's Platform as a Service (disclosure: I work for IBM, though not on Bluemix). Bluemix performs a similar function to Heroku and Azure, allowing you to run applications in a variety of languages and has the advantage that it built upon the open Cloud Foundry platform.

Having played played around deploying Clojure apps on IBM's internal Bluemix beta, I thought I'd write a guide to getting started with Clojure on Bluemix now that it is open to the world.

To sign up, go to http://www.bluemix.net/. In order to do this, you need to create an IBM id if you don't already have one.

This gives you access to the Bluemix dashboard from which you can create new apps and services.

This post won't talk about using the Dashboard because I'm more comfortable using the command line. In order to use the command line, you first need to download the tools. You can find the installation package for your favourite OS here:

Once the Cloud Foundry CLI tools is installed, you can run the cf command to interact with Bluemix. First, let's point it at the Bluemix API (note to any IBMers who are using the IBM internal Bluemix: your API endpoint will be different to this):

Check that the version of lein-ring is at least 0.8.11 because this will make our life easier if we want to run an uberwar of our webapp on Bluemix at a later date.

The compojure template gives us a simple Hello World app which is good enough for our purposes here. We want to push it up to Bluemix using the command line tool but there is one problem: Bluemix does not natively support Clojure web apps and neither does Cloud Foundry. However, that's not a problem because Cloud Foundry and Bluemix have native support for Heroku buildpacks.

In this example, we're going to use the Heroku buildpack for Clojure unchanged. You might be thinking that this is a little dangerous; Heroku might make a change to their buildpack tomorrow that breaks Bluemix. That is true and a safer bet would be to maintain a fork of the Heroku buildpack and test that fork against Bluemix (or even write a new buildpack completely from scratch that is specifically aimed at Bluemix). For now, though, we're going to live on the edge and use the Heroku buildpack directly.

The buildpack already knows how to compile our Clojure webapp but we need to tell it how to run it or it will default to lein trampoline run, which isn't what we want. We do so by adding a file called Procfile to our project with the following contents:

web: lein trampoline ring server-headless ${PORT}

We also need to specify :min-lein-version "2.0.0" in order to require the use of Leiningen 2. Edit project.clj to look like this:

My first impressions of Bluemix are good so far. It appears to work and I was able to get my app running without too much bother, which is great. And Bluemix supports a fair few applications and services, some open source and some from IBM. I'll try to write about deploying a slightly more complex Clojure app in a future post.

Before switching back to the Compose view, I have to ensure that Blogger is not going to quote my HTML so I hit Options on the right and make sure that Show HTML literally is selected.

Previewing the post, I can now see my Clojure code wonderfully highlighted as above.

This whole process is slightly faffy. What I really want is to remove the step where I have to find the right bit of HTML to copy into Blogger's raw HTML editor. One solution would be to figure out how to get htmlize to output HTML snippets (rather than whole documents). Another alternative would be to use org-mode - which works well with htmlize - to output the whole blog post. I'll write more if I get round to trying that.