Chalk Mine - shorthand for embedded SQL in Java

This is the first part of a series I call: Look ma, I invented the wheel again. In a long developer life I have implemented things that have been done by many others, better, before. This is one of them.

Technically Chalk Mine is an ORM (Object Relational Mapper) for Java 5 and later. It provides a simple and concise way of mapping back and forth between Java types and relational data in an SQL-database. In addition to that it provides a way of doing configuration and has built-in connection pool.

This is an example of its typical use:

try {
    int userCount = queryScalar(Int.class, "select count(*) from users where name = ?", "Smith");
    System.out.println("There are " + userCount + " users named 'Smith'.");
} finally {

The methods openConnection, queryScalar and closeConnection are all static methods in chalkmine.ChalkMine and are here imported using a static import.

The methods openConnection and closeConnection open and close a connection. The connection is bound to the current thread which is why it is not given as an explicit parameter to queryScalar.

The method queryScalar does a query expecting exactly one row otherwise chalkmine.NonScalarException is thrown.

The row is mapped to the type supplied as the first parameter.

Since the type is a simple type (int, double, string etc.) the first column of row is used.

The last parameter ("Smith") as one a variable number of parameters that will be substituted into the ?'s in the query. (This happens using Java's PreparedStatement mechanism taking care of proper escaping of strings etc.)

See more at

Sierpinski in EMU

Using recursive functions and turtle graphics to draw the Sierpinski fractal in EMU.

Turning EMU Turing Complete

This article deals with EMU. To try it out follow this link and click “skip” at the login screen.

With EMU I wanted to merge what you can do in spreadsheet with what you can do in an ordinary text editor.

The embedded language in EMU is designed to have a familiar syntax (JavaScript/C-like) and be immediately useful when comes to basic calculations and calling external functions for task such as creating a graph.

Read more ...

New iOS Game: Fidus Fidus

My new iOS Game “Fidus Fidus” has been released on Apple’s App Store. It is made using Apple Swift and Apple SpriteKit.

The game is spin on the classic falling block action puzzles like Puyo Puyo and Tetris.

Like Puyo Puyo you control two beans falling from the top of the screen. The object is to match the beans up in groups of 4 or more while preventing the beans to grow to the top. Unlike Puyo Puyo you don’t play against an opponent and your reward for clearing beans in a cascade is that you get a speciale “happy fiduser” that will clear up even more beans.

Anyways. This description probably does not make much sense. So here is a video of the game action.

As you can see from the white strokes in the video the game is gesture controlled. With gestures for left, right and down plus circular gesture for rotating clockwise or counter-clockwise.

Try the game in the App Store. Free.

How to get the SQL schema generated by Hibernate/JPA in a Spring Boot Application

Spring Boot is set up with automatic schema creaation when you create a database-based application. This is very nice for prototyping but as your project develops you will want to take full control on how the database schema is setup and migrated. Unfornately it is not obvious how get a Spring Boot application to spit out the schema it is creating; here is what I ended up doing:

Read more ...

Basic hosting of a Java 8 / MySQL application on Digital Ocean

Here is how I set up Java 8 hosting on Digital Ocean. Digital Ocean is an American hosting company that offers solid virtual servers starting at the rock bottom price of 5 USD pr. month.

This setup is somewhat lacking security; in particular in that it is a single user setup (only root), does not use SSH keys and let’s Tomcat listen directly to port 80. Also it is running http rather than https so deployments with the manager application sends your password in cleartext.

So use this setup at your own peril.

Read more ...

My Java Applet Games

Since 1996 I have made a series of Java applet that I put online on my old websites ( and my university website). The games used to be very popular peeking at tens of thousands of daily users.

However Oracle has changed the applet security policies and lately announced a complete deprecation of the technology, so the games are no longer working and not available online.

Here is a video showing what the games looked like:

I have put the full source code of the 8 games up on GitHub:

Work in Progress – EMU

EMU – which is short for “extended markup” – is project I have been working on for a while. At its core is a what-you-see-is-what-you-get markup editor with a small functional language embedded that allows the user to do calculations that you normally would use a spreadsheet to do.

It built from “scratch” in the sense it does not use “content editable” or similar to do its editing. It runs as a web application with a Java 8 / Spring Boot server but most of the work is on the JavaScript client using React and a parser/lexer-library called Nearley.

This animation shows the WYSIWYG editing in effect:

The embedded language snippets can be used to call an external library containing various functions. I.e. a function for rendering a pie chart:

You can try the beta here:

This version will store your documents in your web browser and thus without the backend server.

Apple has Thru-the-Roof Customer Service

I have a Macbook Pro retina as my main work machine.

It has been working fine until about 6 months ago when it started to become unstable. The problem seemed to be related to overheating and the discrete GPU. In the beginning it would just reset once in a while or refuse to turn on the screen after sleep.

This is about when the 2 year Danish consumer warranty expires and I was travelling SE Asia. So I tried various things such as software utilities for increasing fan speeds or for turning the discrete GPU off.

Read more ...

My First iOS Work: Tilt Out

Writing a computer game is often a good way to learn a new programming platform. Simply put having something fun to make compensates for the frustration of learning a new platform.

There is large number of classical games out there that can be twisted and adapted to work on the iPhone. One of them is Breakout. Breakout was made by Atari in the 70es. You control a paddle playing a ball against a wall of bricks. Each time the ball hit a brick, the brick would disappear and when all bricks where cleared you would proceed onto the next level. Loose the ball and the game would be finished.

Breakout was also the product of two fellas who later became rather big names inside the computer industry: Steve Jobs and Steve Wozniak.

Read more ...