Super Bowl and Anti-Super Bowl

More than 100,000,000 people tuned in to watch Super Bowl XLVII. In this blog post we will look at how web traffic to a Vast powered automotive marketplace was affected by the Super Bowl and by a power outage that disrupted the Super Bowl for roughly 30 minutes.

Read on →

An Unexpected Recommendation

One of the most famous examples of big data analytics in e-commerce is Amazon’s personalized recommendations. During a recent amazon session, I was surprised to see a set of recommendations that were entirely uninteresting to me. In this blog post I speculate about why the poor recommendations surfaced, and I propose additional features that could have steered the recommender towards products I would be more likely to purchase.

Read on →

Visualizing Model Search

Model search is a general name for a set of techniques that address the problem of selecting a subset of variables for regression. See (1) for an in depth discussion of various model search methods, and (2) for guidance on using implementations in R of some of these techniques. Here we are interested in visualizing the variable selection order determined using lasso regression as implemented by the “lars” package in R. The goal is to get a sense of the impact of selecting a variable subset of a particular size, and the impact of decreasing or increasing the number of variables in order as determined by the lasso technique.

Read on →

Creating Named Guice Bindings for Typesafe Config Properties

Guice provides an @Named annotation so that you can distinguish multiple bindings which have the same type. A canonical example is string or numeric configuration values. For example, to inject a string value into a constructor you could use.

1
2
@Inject
public MyDB(@Named("jdbc.url") String jdbcUrl) {

This requires a binding to provide a value linked to the name. You can create this with the bindConstant() method from within a module, for example

1
2
3
protected void configure() {
    bindConstant().annotatedWith(Names.named("jdbc.url")).to("http://localhost:431");
}

In general though you’d like to read constants like this from a configuration of some sort. The guice Names class provides a convenience method that will create Named bindings for all of the properties in a Properties object. We’re not using Properties for configuration values though, we’re using typesafe Config.

I wanted the same feature for typesafe Config so I wrote a class to create bindings for all the properties in a typesafe Config object so that they could be accessed with @Named annotations.

Read on →

Generating Unique JUnit Test Names With TestNG Data Providers

We use TestNG with the Maven Failsafe Plugin to implement integration tests for our Java platform services.

For this specific platform service we’ve defined a set of functional test suites each containing between a few and a few hundred test payloads and expected results, with each test payload and expected result pair constituting one logical unit test. Each TestNG test would run a single functional test suite, iterating over all test pairs — so while we may have hundreds of unit tests the TestNG reports would only show one test per functional test suite and would fail the entire functional test suite if a single unit test within failed.

This really wasn’t ideal for a couple of reasons:

  • Since each unit test is independent from each other it makes little sense for a single unit test to fail all the unit tests within the functional test suite
  • Test reports wouldn’t adequately show the number of unit tests which succeeded, failed or were skipped
Read on →

ParseError - Premature EOF - Java WebServices Client

Quick post to document the solution, without the underlying root cause, to an exception. The setup is a client implemented with the JAX-WS reference implementation in Java 6 (JAX-WS RI 2.1.6 in JDK 6) calling a server also using JAX-WS hosted by Jetty using the jetty-jaxws2spi package. Setup as normal I get an exception in the client when it tries to parse the response from the server.

1
2
com.sun.xml.internal.ws.streaming.XMLStreamReaderException: XML reader error: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,507]
Message: Premature EOF
Read on →

Using SyslogAppender on OS X

I’m using ch.qos.logback.classic.net.SyslogAppender to send messages to syslog and I need to be able to test the configuration on OS X. There are various sources of information on how to do this but no comprehensive explanation of what to do for OS X 10.7 so here’s my four step process.

Read on →

Ranking Apache Pig Tuples With a Python UDF

The ORDER … BY statement in Pig Latin sorts the tuples in a bag. Sometimes it is useful to know the rank of each tuple – its position in the bag for a given sort order. This post demonstrates a user defined function (UDF) written in Python that injects rank into each tuple in a bag. The code below has been tested on Pig 0.9.2.

Read on →

UIViewController Life Cycle

There are many resources describing the life cycle of a view controller in iOS. This one differs in looking at the order of the the life cycles events of two UIViewControllers embedded in a UINavigationController. The way in which the events on the two controllers are interleaved is interesting.

The main events are

  • (void)viewWillAppear:(BOOL)animated
  • (void)viewDidAppear:(BOOL)animated
  • (void)viewWillDisappear:(BOOL)animated
  • (void)viewDidDisappear:(BOOL)animated

but I’ve also thrown in the UINavigationControllerDelegate methods and some of the UITextFieldDelegate methods.

Read on →
ios

Using the Noscript Element to Hide HTML Elements on Page Load

Sometimes a simple use case leads to a neat technical trick, and this is exactly what this short post is about.

This specific use case was quite simple, based on the following requirements:

  • Show a simple search experience page that allows the end user to pick a value from a long list of options using a select element (e.g. the make of a car) to perform a search.
  • Make the page search engine friendly by providing link elements for the top option values instead of a select element when JavaScript is not available.
  • Serve the same HTML content to all clients regardless of user agent ids or capabilities (no cloaking or semi-cloaking).

The requirements are straightforward and can be implemented using the noscript element as follows:

Read on →