Posts
Docker X11 Client Via SSH
tldr Running a GUI program in Docker takes a little work. So does running a GUI program using SSH X11 forwarding. Putting the two together is the most fun of all. /tldr
Docker is an interesting technology to work with, because sometimes it feels like just regular coding, and sometimes it feels like typing with oven mitts on. Today was an oven mitt day.
The goal was to get a GUI program to run, in Docker, with the X server on the other side of an SSH tunnel.
Posts
Posting at DZone
Since this blog was new, the content has been syndicated at DZone through their Most Valuable Blogger (MVB) program. Most of the people who have read what I’ve written have read it there, so it’s been advantageous to me, especially when I was starting as a new blogger.
Recently I was invited to join their Zone Leader program. As a result, I am joining a number of others posting original content at DZone and helping to syndicate the work of MVBs.
Posts
Agile Tools?
tldrThe agile manifesto says to emphasize individuals and interactions over processes and tools. So why do we spend so much time on tools?/tldr
The very first of the four values in the agile manifesto is, “[i]ndividuals and interactions over processes and tools”. The agile mentors I have worked with emphasize this value when teaching agile; for example, they use only flipcharts and sticky notes to teach new teams how to write user stories and do sprint planning and daily standups.
Posts
Environment Variables with Ansible and Vagrant
One of the joys of working in a big corporate environment is the use of a Web proxy server for connection to the Internet. When provisioning a virtual machine with Vagrant and Ansible, this means that sometimes the VM has to go through the proxy and sometimes it doesn’t. I’d rather this was as seamless a transition as possible. The solution I came up with can be extended to other cases where different Ansible behavior is needed at different times.
Posts
Situational Test Driven Development
I was thinking today about Test Driven Development (TDD) in the context of Code I Have Known. I think I found a couple examples that illustrate what I think is great and not so great about TDD. Both are examples of code I wrote, and of which I am proud, which I think is important for the example.
The first was a message parser I wrote to support a strange packed binary format.
Posts
Minimal Docker Container
Most Docker images start from the Docker Hub, with its set of base OS images and application images built from them. With Docker’s layered architecture for images, the fact that typical images are 50MB to 100MB is not a major issue.
At the same time, there are uses for Docker where building from scratch is desirable, and when building from scratch, the image might as well be as small as possible.
Posts
Java REST Web Service
Introduction I’ve built a small example of running a standalone Java application that both serves static HTML, JavaScript, CSS content, and also publishes a REST web service. The example uses Jersey and Jetty. This example probably deserves a few posts to allow enough time to explain how the pieces fit together, so I’ll start with the primary Java pieces that make a JAX-RS application.
A couple years back, while I was working through some slides to teach a Java class (mostly Java EE and Spring) I created a REST web service using Spring WebMVC.
Posts
Logging Performance
Introduction I had an interesting conversation today about the cost of using string concatenation in log statements. In particular, debug log statements often need to print out parameters or the current value of variables, so they need to build the log message dynamically. So you wind up with something like this:
logger.debug("Parameters: " + param1 + "; " + param2); The issue arises when debug logging is turned off. Inside the logger.
Posts
Generics and Capture Of
I taught an introductory Java session on generics, and of course demonstrated the shorthand introduced in Java SE 7 for instantiating an instance of a generic type:
// Java SE 6 List<Integer> l = new ArrayList<Integer>(); // Java SE 7 List<Integer> l = new ArrayList<>(); This inference is very friendly, especially when we get into more complex collections:
// This Map<String,List<String>> m = new HashMap<String,List<String>>(); // Becomes Map<String,List<String>> m = new HashMap<>(); Not only the key and value type of the map, but the type of object stored in the collection used for the value type can be inferred.
Posts
Concurrent Random in Java SE 7
Introduction Last year I wrote a series of posts (Part 1, Part 2, Part 3) on the use of the new Java fork/join framework for a Monte Carlo simulation.
First, an update. Going back through the code I discovered a bug in the way the triangle distribution was implemented. Fortunately this is a toy example, as it made the results inaccurate. My fault for not unit testing. I would still not suggest using this code for anything other than learning about fork/join.
Posts
Spring Static Application Context
Introduction I had an interesting conversation the other day about custom domain-specific languages and we happened to talk about a feature of Spring that I’ve used before but doesn’t seem to be widely known: the static application context. This post illustrates a basic example I wrote that introduces the static application context and shows how it might be useful. It’s also an interesting topic as it shows some of the well-architected internals of the Spring framework.
Posts
Conversational Git
This post is an excerpt from my new book, Conversational Git. The entire book is available on-line and its source is on GitHub. It’s designed to be a quick, accessible introduction for experienced developers. I’d be delighted to hear what others think.
I recently had some close friends talk about their hesitation in adopting Git as opposed to continuing to work with Subversion. I’ve used Subversion for many years, and advocated for its use.
Posts
Spring Custom XML Namespaces
Introduction One of the nice recent features of Spring (2.x era) is support for custom XML. This is the way that Spring itself has added all kinds of new tags such as <util:list> and <mvc:annotation-driven>. The way this works is pretty elegant, to the point that it makes an interesting alternative for configuring Java using XML, particularly if the application already uses Spring.
I’ve written an example application to try to give an easily-copied example of how it’s done.
Posts
Embedded Jetty Executable JAR
Previous posts such as this one have shown using embedded Jetty to REST-enable a standalone Java program. Those posts were lacking an important feature for real applications: packaging into a JAR so the application will run outside of Eclipse and won’t be dependent on Maven and jetty:run. To make this happen, we will use Maven to build an executable JAR that also includes all of the Jetty and Spring dependencies we need.
Posts
Jetty Proxy Servlet
Introduction I’ve talked before about Jetty as an embedded servlet container. Jetty also includes some useful utility servlet implementations, one of which is ProxyServlet.
ProxyServlet is a way to create an HTTP or HTTP/S proxy in very few lines of code. Even though it’s part of the Jetty project, it’s modularized to be independent of the Jetty server, so you can use it even in cases where the servlet won’t be run in Jetty.