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

Neo4J File Storage

Below are two excellent articles explaining Neo4J’s binary file storage format.


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();
}

Composite and nested filesets in ANT

I haven’t found a sensible way to combine/nest filesets in ANT so I’ve implemented a ResourceCollectionGroup DataType/ResourceCollection, which allows for deep nesting of filesets/groups. An example of using ResourceCollectionGroup is available here.


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());
    }
  }
}

Follow

Get every new post delivered to your Inbox.