Building Apache Mesos on Mac OS X Mavericks

Below are step-by-step instructions for building Apache Mesos on Mac OS X Mavericks. I’ve tried this with Mesos 0.18.1 but it may also work with newer/older versions of Mac OS X/Mesos.

  • Download Apache Mesos 0.18.1 from http://archive.apache.org/dist/mesos/0.18.1/mesos-0.18.1.tar.gz
  • Extract the downloaded archive
  • Open a terminal
  • Go to the directory where you extracted Mesos
  • Accept the Xcode license: xcodebuild -license
  • Install Brew: ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
  • Install GCC: brew install gcc48 (this can take for ever i.e. > 30 minutes)
  • Install Maven: brew install maven
  • Create the build directory: mkdir build
  • Go to the build directory: cd build
  • Run the configure script: ../configure
  • Build: make (this can also take a long time)
  • Run test suite: make check (go make another cup of coffee)
  • Start Mesos server: ./bin/mesos-master.sh --ip=127.0.0.1
  • Start Mesos slave: ./bin/mesos-slave.sh --master=127.0.0.1:5050
  • Open the Mesos web page: http://127.0.0.1:5050

Publishing Wink screencasts on YouTube

Wink is a great freeware for capturing and editing screencasts on Windows/Linux. Unfortunately, it only supports exporting screencasts as Flash (.swf) videos, which cannot be directly uploaded on YouTube. Here is a quick way to convert Wink screencasts into videos you can upload on YouTube using Windows Movie Maker (free).

  • Open your screencast file (.wnk) with Wink
  • Export the captured images as HTML (File -> Export as HTML)
  • Open Windows Movie Maker
  • Drag and drop all the images in the exported HTML’s image directory into Movie Maker
  • Select all images, go to the Edit tab and set the duration to 0.3 seconds
  • Export as a video in the format of your choice (.wmv works fine with YouTube)

Single-file Database Management Systems

Below is a list of DBMSs (both relational and NoSQL) that support storing each database as a single, self-contained file.

Below is a list of DBMSs that looked promising but after closer inspection seem to be needing more than one file per database.

  • MapDB (Key-value – Apache License)

If you are aware of any other single-file DBMS please leave a comment below.

Escaping XML special characters in Java

If you do not wish to bring in an additional dependency, you can use the following function, which makes use of the built-in W3C XML API, to escape XML special characters in your Java program.

public String escapeXml(String target) throws Exception {
	Document document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
	Text text = document.createTextNode(target);
	Transformer transformer = TransformerFactory.newInstance().newTransformer();
	DOMSource source = new DOMSource(text);
	StringWriter writer = new StringWriter();
	StreamResult result = new StreamResult(writer);
	transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
	transformer.transform(source, result);
	return writer.toString();
}

Basic username/password authentication for ksoap2 on Android

The built-in HttpTransportBasicAuth class provided by ksoap2 doesn’t seem to be part of the ksoap2 Android assembly. The following class (adapted from here) works fine for me.

import java.io.IOException;

import org.kobjects.base64.Base64;
import org.ksoap2.transport.HttpTransportSE;
import org.ksoap2.transport.ServiceConnection;

public class HttpTransportBasicAuth extends HttpTransportSE {

  private String username;
  private String password;

  public HttpTransportBasicAuth(String url, String username, String password) {
    super(url);
    this.username = username;
    this.password = password;
  }

  @Override
  public ServiceConnection getServiceConnection() throws IOException {
    ServiceConnection serviceConnection = super.getServiceConnection();
    addBasicAuthentication(serviceConnection);
    return serviceConnection;
  }

  protected void addBasicAuthentication(ServiceConnection serviceConnection) 
      throws IOException {
    
    if (username != null && password != null) {
      StringBuffer buffer = new StringBuffer(username);
      buffer.append(':').append(password);
      byte[] bytes = buffer.toString().getBytes();
      buffer.setLength(0);
      buffer.append("Basic ");
      Base64.encode(bytes, 0, bytes.length, buffer);
      serviceConnection.setRequestProperty
        ("Authorization", buffer.toString());
    }
  }
}

Sharing GWT projects to SVN with Subclipse

If you try to add your GWT project to an SVN repository with Subclipse, by default Subclipse will also put all GWT-generated files (which can be several MBs in size) under version control. To avoid this, before sharing your project you should mark the following folders of your project as derived in Eclipse, so that Subclipse ignores them when it tries to share the project.

  • war/WEB-INF/deploy
  • war/<module_name>
  • gwt-unitCache

To mark a folder as derived in Eclipse you need to right-click it in the Package Explorer view, click Properties, check the Derived option in the Resource panel and click OK.

Model Transformation Papers

Below is a short list of papers and other resources in the area of model(-to-model) transformation aimed at newcomers to the field.

Reviewing PDF Documents using Skim

When reviewing PDF documents (papers, reports etc.) I often need to produce a list of comments in a separate text file. For quite some time I’ve been doing this by switching back and forth between the PDF viewer and a text editor but I’ve recently found a more efficient way of doing this so I thought I’d share it.

To avoid switching between applications, I started marking my comments using highlights in Skim and exporting them using File->Export->Notes as Text which creates a file with the following format.

* Highlight, page 2
some bold claim -> needs reference

* Highlight, page 3
confusing sentence -> Not entirely clear what this means

* Highlight, page 4
tyop -> typo

This was not quite the format I wanted, so to fix this I’ve created a new Skim template (Compact Notes.txt) which produces notes in the following format:

Page 2: some bold claim -> needs reference
Page 3: confusing sentence -> Not entirely clear what this means
Page 4: tyop -> typo

To use Compact Notes.txt, you need to download and place it under /Library/Application Support/Skim/Templates/ (you’ll need to create any missing folders in this hierarchy). Once the template is in place, you can choose it in the File Format drop down menu as displayed below: