Archive for Technology

Making Emacs even more like TextMate

Much as I love TextMate, I’m still trying to get back to one editor. Here are a two more things to make Aquamacs even more TextMate like.

TextMate Minor Mode

Go to defunkt’s github page and follow the instructions.

This gives you access to some of the magical TextMate features. The ones I missed the most are:

  • ⌘T - Go to File
  • ⌘/ - Comment Line (or Selection/Region)
  • ⌘L - Go to Line

By adding in these few shortcuts, I find it much easier to jump between the editors.

Cucumber Support

A simple set of scripts to enable cucumber support into emacs. See the installation page for how to set it up. And don’t forget the pre-req.

Once installed, you get syntax highlighting for feature files, and snippet support.

You can also setup run targets, however that requires a few more dependencies.

Other Rails Files

Try the following in your .emacs to include additional syntax highlighting:

;; Rake files are ruby, too, as are gemspecs, rackup files, etc.
(add-to-list 'auto-mode-alist '("\.rake$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\.gemspec$" . ruby-mode))
(add-to-list 'auto-mode-alist '("\.ru$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Rakefile$" . ruby-mode))(add-to-list 'auto-mode-alist '("Gemfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Capfile$" . ruby-mode))
(add-to-list 'auto-mode-alist '("Vagrantfile$" . ruby-mode))

MapReduce Examples

In investigating MongoDB I decided to explore MapReduce to analyse the posts from a heap of RSS feeds. However, the MongoDB documentation is fairly basic. This post has a bit more detail on more complex map/reduce functions.

Looking outside of MongoDB, there are a few other groups working with MapReduce. Google started the whole thing off, and has some good resources:

Some examples of using MapReduce include:

  • Distributed Grep - emit(matched line), reduce(identity)
  • Count of URL Access Frequency - emit(url, 1), reduce(url, sum)
  • Reverse Web-Link Graph - emit(target, source), reduce(target, cons) => {target, [sources]}
  • Term-Vector per Host - {hostname, [term vector]}
  • Inverted Index
  • Distributed Sort

The reverse web-link graph sounds interesting:

The map function outputs pairs for each link to a target URL found in a page named “source”. The reduce function concatenates the list of all source URLs associated with a given target URL and emits the pair: .

There is also some work on using MapReduce to allow for machine classification to run in parallel. I also found a presentation on Large Scale Data Analysis that was helpful.

The main thing to get my head around is that the map function can return more complicated results than just a simple count. The reduce function then just glues the results together in some way.

And then there is the idea of multi-pass MapReduce. That could get interesting.

For now, I’m doing a lot of reading. The next step will be start to put into practice some of these ideas for analysing data. Actually, the next step is collecting the data, but that’s on a different thread.

Owning an Agile Product

One of the challenges in running a successful agile project is having a strong product owner.

In learning about agile processes, this is an area I haven’t read much about. This recent article on the Scrum Alliance site is a valuable addition and thinking about how to build a better product owner.

Some quotes:

Creating any product can be challenge. With a product being developed at the speed of agility, these challenges increase.

What teams need most is a product owner who is able to prioritize the product backlog.

It’s the product owner’s responsibility to know and communicate a product vision for the team. Knowing where you want to go enables you to reach your destination; the details of getting there we all discover along the way.

Product owners must be able to earn the respect of the team, resolve conflicts through conversations, and adjust priorities accordingly. There are whole books dedicated to managing conflicts. Learning when to take a stand and when to give is important. It is more important, though, that everyone has a voice.

Be concerned about creating a stable environment for the team members to learn and contribute. It’s imperative that you keep the team from being distracted.

The product owner is not a dictated hierarchy, but a service role. The customer, the team, and the company are all tuned around the product by the product owner.

It is worth reading in full.

Learning Clojure with Google App Engine and Emacs

This is an overview to my attempts at getting Clojure with Emacs. Inspired by this post, I set out to learn three things simultaneously: emacs, clojure and Google App Engine.

For comparison, my current web prototyping combination is TextMate, Rails, and Heroku. Prior to that it was a mix of python, php or perl, with vim.

There are already number of articles on getting GAE and Clojure to work. Consider this me making notes for myself because I keep forgetting the Emacs shortcuts!

Emacs

I settled on Aquamacs to start out with emacs on the Mac. It seems to be more forgiving if I use normal Mac keyboard shortcuts while I learn emacs keys. Also makes it easy to switch between it and TextMate.

The other feature I love is full screen mode: ⌘-Shift-Return

To get command line access, you need to go to Tools->Install Command Line Tools. This gives you an “aquamacs” shortcut in the shell. I aliased it to “aq”.

For some help on learning emacs, consider:

You may also want to setup Clojure to run with Emacs. This article assumes you are using lein.

Google App Engine (GAE)

The GAE distribution is available here: GAE Download.

I setup my shell to include a $GAE_BASE directory for where I unpacked it, and added $GAE_BASE/bin to my path.

Creating a Clojure Project

The first post I read assumed that you were starting with a manual layout of your project. I’m going to use lein, a build manager for clojure, similar to rake for ruby. Behind the scenes lein uses Java’s maven as a package management system (similar to gems).

To make things a bit more interesting, I plan to write a very basic CMS to explore the various APIs. I’m keeping everything on the githubs.

The steps to getting setup look something like:

% lein new gaecms
% mkdir -p war/WEB-INF

Then make some changes to your project.clj file:

(defproject gae-cms "1.0.0-SNAPSHOT"
  :description "A basic CMS built on Google App Engine (GAE)"
  :dependencies [[org.clojure/clojure "1.2.0"]
		 [org.clojure/clojure-contrib "1.2.0"]
		 [compojure "0.4.1"]
		 [ring/ring-servlet "0.2.1"]
		 [appengine "0.4-SNAPSHOT"]
		 ]
  :dev-dependencies [[leiningen/lein-swank "1.2.0-SNAPSHOT"]]
  :compile-path "war/WEB-INF/classes"
  :library-path "war/WEB-INF/lib"
  )

To save some typing, you can clone: git://github.com/gmwils/gaecms.git

To run the interpreter locally, try the following:

% lein deps
% lein swank

To test out that the interpreted mode is working, open up src/gae_cms/core.clj in AQ.
Then connect to the server:

M-x slime-connect

From within the editor, you can now run either of the following:

C-x C-e    % evaluate current line
C-c C-k    % compile the current file

You also have an interactive clojure shell for typing commands into. Try adding the following into your source code and then pressing C-x C-e to evaluate:

(System/getProperty "java.class.path")

You should see your current CLASSPATH printed out.

Setup for GAE

In $HOME/war/WEB-INF/web.xml map the URLs that you want your custom servlet to handle. In this case, send everything into the servlet:

<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app
   xmlns="http://java.sun.com/xml/ns/javaee"
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
   xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
   version="2.5">
  <display-name>CMS on GAE</display-name>

  <servlet>
    <servlet-name>cms</servlet-name>
    <servlet-class>gae-cms.core</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>cms</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
</web-app>

In $HOME/war/WEB-INF/appengine-web.xml add the following to setup Google App Engine to refer to your servlet above.

<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
  <application>cms-clj</application>  <!-- GAE app id for your app -->
  <version>v0-1</version>  <!-- Arbritrary Version Id -->
</appengine-web-app>

Next, update src/gaecms/core.clj with:

(ns gaecms.core
  (:gen-class :extends javax.servlet.http.HttpServlet)
  (:use
   compojure.core
   [ring.util.servlet :only [defservice]]
   )

  (:require [compojure.route :as route]))

(defroutes cms-public
  (GET "/" [] "<html><title>GAE CMS</title><body><h1>Hello World!</h1></body>")
  )

(defroutes cms
  cms-public
  (route/not-found "Page not found")) ; 404 error page

(defservice cms)

To test this locally, try:

% lein deps
% lein compile
% $GAESDK/bin/dev_appserver.sh war

Deploying to Google

First go to the GAE console and create an application. The following should then work:

% lein deps
% lein compile
% $GAESDK/bin/appcfg.sh update war

I’m still playing with getting it working with Google App Engine. The above is enough to get hello world working.

For more details, I suggest you follow the Compojure on GAE blog. Specifically, the article on Deploying to App Engine is a good overview.

Next steps include getting interactive development working with GAE, and actually handling dynamic content.

Agile Retrospectives

Presentation from the authors of the book “Agile Retrospectives - Making Good Teams Great” at Google. Lots of great tips on how to improve your sprint & project retrospectives.

One tip I picked up on was to ask “how was the energy for this sprint?” rather than the bland “how are you feeling?”.

Their structure for a retrospective is:

  • Set the Stage
  • Gather Data
  • Generate Insights
  • Decide What to Do
  • Close the Retrospective

The way to succeed with a process such as agile is through continuous improvement. The forum for reviewing what needs to be improved and to decide on how to improve things is the sprint retrospectives.

Retrospectives are critical for having a successful project.