• Using A Core.Async Routine As A State Machine

    Clojure has a library called Core.Async that it allows you to model your system as a set of independent processes that pass messages to each other through channels. Each process is responsible for running itself, managing its own state, etc. But how do you manage state in a language where...

    May 18, 2014 - 5 minute read
  • High Performance and Parallelism With the Feel of a Scripting Language

    Sometimes you need a quick-and-dirty tool to get something done. You're not looking for a long-term solution, but rather just have a simple job to do. As a programmer when you have those thoughts you naturally migrate toward scripting languages. But sometimes that throw away tool also needs to do...

    October 21, 2013 - 10 minute read
  • 3.5x Increase In Performance with a One-Line Change

    Gather around my friends, I'd like to tell you about a cure for what ails you, be it sniffles, scurvy, stomach ailments, eye sight, nervousness, gout, pneumonia, cancer, heart ailments, tiredness or plum just sick of life... Yes, sir, a bottle of my elixir will fix whatever ails you! You...

    October 7, 2013 - 4 minute read
  • Mapping SQL Joins using Anorm

    Anorm is a Scala framework that is a fairly thin veneer over JDBC that allows you to write SQL queries and map results into Scala objects. The examples easily found on the web have a tendency to be fairly simple. One of the first problems I ran into was mapping...

    June 28, 2013 - 8 minute read
  • Java 7 Code Coverage with Gradle and Jacoco

    Thanks Steven Dicks' post on Jacoco and Gradle is a great start to integrating Jacoco and Gradle, this is a small iteration on top of that work. Java 7 Code Coverage The state of Code Coverage took a serious turn for the worst when Java 7 came out. The byte-code...

    September 13, 2012 - 3 minute read
  • Groovy Mocking a Method That Exists on Object

    In Groovy, the find method exists on Object. The find method is also an instance method on EntityManager which is commonly used in JPA to get an instance based on a database id. I was trying to create a Mock of EntityManager like: def emMock = new MockFor(EntityManager) emMock.demand.find {...

    March 22, 2012 - 1 minute read
  • Testing and Internal Implementation in .NET

    Switching back and forth between Java and .NET lets you see some of the differences between the two platforms more easily. This happened to me the other day when I switched from Java to .NET and was writing Unit Tests. In Java, the access modifiers include public, private, protected and...

    February 6, 2012 - 2 minute read
  • Using Groovy AST to Add Common Properties to Grails Domain Classes

    Groovy offers a lot of runtime meta-programming capabilities that allow you to add reusable functionality in a shared fashion. Grails plugins make use of this ability to enhance your project. One of the things that you can't do with runtime meta-programming in Grails is to add persistent Hibernate properties to...

    November 9, 2011 - 4 minute read
  • Check Multiple Mercurial Repositories for Incoming Changes

    Currently I have a whole bunch of Mercurial repositories in a directory. All of these are cloned from a central repository that the team pushes their changes to. I like to generally keep my local repositories up-to-date so that I can review changes. Manually running hg incoming -R some_directory on...

    August 26, 2011 - 2 minute read
  • Java Return from Finally

    try...catch...finally is the common idiom in Java for exception handling and cleanup. The thing that people may not know is that returning from within a finally block has the unintended consequence of stoping an exception from propagating up the call stack. It "overrides" the throwing of an exception so that...

    March 18, 2011 - 2 minute read
  • USB to Serial Adapters in VMWare

    I needed to do some work using a pin pad (a device that allows you to enter a numeric code at a point-of-sale or other system) and needed to test it in a 32bit Windows environment. The pin pad uses a serial port to communicate to a computer. Of course...

    March 2, 2011 - 2 minute read
  • What is the Cost of Not Doing Things?

    We're really good at measuring the cost of some things. We're good at measuring the cost of a new computers for everyone on the team, we're good at measuring the cost per hour of a resource on a project and we're good at measuring the time it will take to...

    January 27, 2011 - 1 minute read
  • NoSQL with MongoDB and Ruby Presentation

    I presented at the Milwaukee Ruby User's Group tonight on NoSQL using MongoDB and Ruby. Code Snippets for the Presentation Basic Operations // insert data db.factories.insert( { name: "Miller", metro: { city: "Milwaukee", state: "WI" } } ); db.factories.insert( { name: "Lakefront", metro: { city: "Milwaukee", state: "WI" } }...

    November 15, 2010 - 5 minute read
  • MongoDB: MapReduce Functions for Grouping

    SQL GROUP BY allows you to perform aggregate functions on data sets; To count all of the stores in each state, to average a series of related numbers, etc. MongoDB has some aggregate functions but they are fairly limited in scope. The MongoDB group function also suffers from the fact...

    October 4, 2010 - 5 minute read
  • MongoDB Replication is Easy

    Database replication with MongoDB is easy to setup. Replication duplicates all of the data from a master to one or more slave instances and allows for safety and quick recovery in case of a problem with your master database. Here is an example of how quick and easy it is...

    August 8, 2010 - 2 minute read
  • MongoDB and Java: Find an item by Id

    MongoDB is one of a number of new databases that have cropped up lately eschewing SQL. These NoSQL databases provide non-relational models that are suitable for solving different kinds of problems. This camp includes document oriented, tabular and key/value oriented models among others. These non-relational databases are supposed to excel...

    June 17, 2010 - 3 minute read
  • Random but Evenly Distributed Sets of Numbers

    Let's say one is a computer programmer and let's say one's wife (or roommate; or significant other) does social science research (a totally hypothetical scenario of course). When doing social science research one needs to create randomized groups of participants. So in a group you might be testing a variable...

    April 17, 2010 - 7 minute read
  • Announcing Grails Constraints Custom Domain Constraint Plugin

    I've released my first public Grails Plugin today. The Grails Constraint plugin gives you the ability to create custom Constraints that you can apply to your Domain classes to validate them. These are applied and act just like the built in Domain class constraints. Why would you want this? Grails...

    October 26, 2009 - 2 minute read
  • DRYing Grails Criteria Queries

    When you're writing code, Don't Repeat Yourself. Now say that 5 times. *rimshot* One of the things that I find myself repeating a lot of in many business apps is queries. It's common to have a rule or filter that applies to many different cases. I came across such a...

    September 2, 2009 - 5 minute read
  • Struts2 Map Form to Collection of Objects

    The Struts2 documentation contains examples that are often basic at best which can make it challenging to figure out how to do things sometimes. I was working on creating a form that would allow me to select values from a list to connect 2 objects in a One-to-Many relationship. This...

    July 2, 2009 - 4 minute read
  • Password Strength Validation with Regular Expressions

    Regular Expressions are both complex and elegant at the same time. They can be made to look like someone was just randomly hammering on their keyboard. They are also an incredibly efficient and elegant solution to describing the structure of text and matching those structures. They are very handy for...

    May 8, 2009 - 4 minute read
  • Scala and Adding New Syntax

    One interesting thing about some languages is their support for adding new syntax. While all languages have the ability to add new functions or types some have specific properties that make it easy to add what looks like new built-in syntax. Scala is an Object Oriented language. You can declare...

    April 26, 2009 - 3 minute read
  • Grails Embedded Classes ClassCastException

    Using ORM tools allow you to map the data to a database independently of how your object model looks. Grails supports one-to-many and one-to-one relationships if you want to have the data in different table. But what about when you want to map a single table to multiple objects? In...

    April 21, 2009 - 2 minute read
  • Update Table Data in Grails using Ajax Calls

    Using Ajax for simple forms can offer users a very clean, simple and fast way to input data. I came across a situation recently where I was looking into replacing a document based workflow with an application. The documents themselves contained a series of different kinds of transactions that could...

    March 27, 2009 - 5 minute read
  • Using Quartz.NET, Spring.NET and NHibernate to run Scheduled Tasks in ASP.NET

    Running scheduled tasks in web applications is not normally a straightforward thing to do. Web applications are built to respond to requests from users and respond to that request. This request/response lifecycle doesn't always match well to a long running thread that wakes up to run a task every 10...

    March 7, 2009 - 7 minute read
  • Older posts