Kevin Locke's Homepage

Eureka!

A blog of minor discoveries and useful tips from Kevin Locke.

Issues with Slow Cryptsetup

by

I recently configured an additional encrypted partition mounted at boot using cryptsetup with LUKS. Doing so increased my boot time by about 5 seconds. In tracking down this minor annoyance, I learned two things about cryptsetup which may be helpful to others in a similar situation:

Read more...

Firefox Fails in Odd Ways Without /proc

by

Recent versions of Firefox crash on startup when /proc is not mounted. Although this is not a problem, per se, the fact that it crashes without giving any indication of the reason can significantly complicate testing alpha/beta/nightly releases. This post simply lists the errors that I have seen in hopes that it will save others some debugging time.

Read more...

Scala Default Constructor Parameters Causing Circular Static Initialization

by

I just finished tracking down a rather esoteric bug in a Scala application that I am writing. Understanding this bug requires some understanding of how Scala is translated to Java and how Java handles static initialization, neither of which will be explained (much) in this post. So, if you are interested in how default parameters on a constructor can cause circular static initialization resulting in a NullPointerError, read on.

Read more...

PostgreSQL Cascading Delete Trigger Visibility

by

If a delete trigger is fired on a table due to an ON DELETE CASCADE action, will the trigger see the rows in the parent table which triggered the cascade? Will a trigger on the originating table see rows in the child tables? Does it matter if the trigger is a “before” or an “after” trigger? The answer to these questions was not immediately obvious to me, and my half-minute of searching didn’t find a clear answer, so I have written this post to remind myself and others what happens in PostgreSQL 9.1.

Read more...

A Warning About Auto-Commit with Flyway and BoneCP

by

This post is just a quick warning that Flyway (before commit 55985b, which includes version 2.0.3, the current version) disables auto-commit on its JDBC Connection. Also, BoneCP (before commit 99d50d, resulting from bug 790585, which includes version 0.7.1.RELEASE, the current version) did not apply the default auto-commit or read-only setting to recycled connections. When these behaviors are combined, connections will be returned from the connection pool which have differing auto-commit. Plan accordingly.

Another quick note, version 0.8.0-rc1 has auto-commit set to false by default, which differs from the JDBC behavior. I consider this a bug.

Configuring Logging in Tests with Lift

by

The Lift web framework integrates the SLF4J logging framework through a set of interfaces for performing logging and a configuration mechanism. The configuration mechanism attempts to configure the logging in a manner similar to the configuration for other parts of Lift. Unfortunately, this mechanism performs differently (or not at all) when running tests than it does when running normally. This post is a quick explanation of the configuration mechanism and how to configure logging during tests.

Read more...

No Output From non-UTF-8 XMLStreamWriter

by

Just a quick reminder to always flush your buffers (when appropriate) and that the behavior of the JDK default XMLStreamWriter (com.sun.xml.internal.stream.writers.XMLStreamWriterImpl) differs between UTF-8 output, which is unbuffered, and non-UTF-8 output, which is buffered through com.sun.xml.internal.stream.writers.XMLWriter. I just spent way too much time figuring this out (particularly because finding the actual location of the source file is non-trivial - Hint: It’s not in the OpenJDK source tree). Hopefully this post will save others that time/effort.

Using Debian-packaged Ruby Gems

by

Ruby software is commonly distributed as “gems”, packages containing Ruby applications and/or libraries, which can be installed using the RubyGems package manager, typically run as a command named gem. On Debian systems, some gems are also available as Debian packages through the Debian package repositories. For Ruby developers on Debian, it is almost inevitable that some gems will be installed through RubyGems and some will be installed through the Debian package managers (and possibly some installed through both). This post discusses some tips for minimizing the pain of this situation.

Read more...

Downloader for Google Web Fonts

by

Just a quick note: I wanted to work with fonts from Google Web Fonts offline. Unfortunately, the source code only contains TTF files and I was unable to find either a trusted converter utility for all formats or a way to download non-TTF formats. So, I wrote a simple utility to download the fonts. Perhaps you will find it useful.

Removing Attributes with Lift CSS Selector Transforms

by

Recent versions of Lift (2.2-M1 and later) provide a concise way of expressing XML transformations using a CSS-like syntax called CSS Selector Transforms. The pleasant conciseness comes with a number of unexpected/undocumented behaviors and corner-cases. One which recently caught me by surprise is the handling of attributes on XML elements. This post is a brief discussion of the behavior and how to work around it to remove attributes from elements.

Read more...

SSL Certificate Verification in Dispatch and AsyncHttpClient

by

I’ve recently started using the Dispatch library for HTTP/HTTPS, which is quite a nice library, as long as you don’t need documentation. Dispatch uses the Ning/Sonatype AsyncHttpClient library, which is also quite nice, and although AsyncHttpClient is a library which I could recommend, it does have an insecure-by-default implementation of SSL. This post is a quick discussion of the AsyncHttpClient defaults and how to implement certificate verification to increase the security provided by SSL.

Read more...

SLICK/ScalaQuery Recipes

by

I recently started using SLICK (formerly ScalaQuery) for database access in a Scala project. In the process of wrapping my head around how SLICK, I’m documenting some “recipes” for common queries. Unfortunately, this post got published before the recipes were ready. (Oops!) But, not to worry, I’ll post them here (or a link from here) once they are ready.

Important Squeryl Limitations

by

I recently had to make the difficult choice to replace Squeryl with SLICK (formerly ScalaQuery) much later in the development cycle than I would have liked. Although I do like some of the design and features of Squeryl, it has some very significant limitations that anyone considering using it should be aware of up-front. Also, in an effort to avoid excessive bias, I’ll include a few of the limitations of SLICK that I have encountered for comparison.

Read more...

How to Subscribe to Google Groups without GMail, Really

by

Although it does not appear to be officially documented, it is possible to subscribe to a Google Group without a Google Account. There are several ways to subscribe but, as I recently found out, Google Groups tries really hard to use a GMail account, if you have one. This post explains how to subscribe to a Google Group via email and how to avoid one pitfall that may result in messages being sent to your GMail address rather than the address with which you subscribed.

Read more...

Squeryl Transactions Not Committing in Lift

by

The latest issue that I’ve encountered while working with Squeryl in a Lift-based web application, is that not all transactions are being committed to the database. This post is a quick discussion of the symptoms that I was seeing and a note on how to avoid the issue.

Read more...

BoneCP 0.8.0-alpha1 unusable with Lift Squeryl-Record

by

In tracking down some persistent errors relating to using Squeryl with Lift, I’ve found that the latest version of BoneCP does not appear to be safe for use in this scenario. This article is a quick discussion of the symptoms that I am seeing and how to avoid them.

Read more...

Letterboxing with FFmpeg/Avconv for Mobile

by

Although the ffmpeg (and avconv) program has a relatively intuitive command-line interface, given the diversity and complexity of the functionality that it exposes, there are still many operations which can be difficult to express. I found letterboxing (and pillarboxing) to be one of those operations, so in order to save others the trouble of working out the details, this post will develop a command for doing boxing with ffmpeg/avconv.

Read more...

NoSuchMethodException for Field Classes in Squeryl-Record

by

I recently spent way too much time tracking down the source of an error in the Squeryl integration to the Record persistence layer in Lift. In the hopes that it may be useful to others encountering the same error, here are the details:

Read more...

Serving XHTML with Apache MultiViews

by

If you are reading this article on the web using a modern web browser, you should be seeing an XHTML version of this page served as application/xhtml+xml. The merits of the XHTML media type, and XHTML in general, have been widely debated and I will not discus them here. Instead, here is a brief discussion of how this server is configured to serve HTML and XHTML content.

Read more...

Changing the Default Browser in Thunderbird on Linux

by

Recently Thunderbird started opening http URLs in the wrong browser. Although you may think that the solution would be a simple configuration change, as I did at the time, it turns out that the process which Thunderbird uses to determine which browser to use is complex, poorly documented, and has changed several times between Thunderbird versions. This post outlines my understanding of the process and, most importantly, how to change the default browser in current versions of Thunderbird.

Read more...

SDL Blit Speed Comparison

by

This post was converted from a page I put together several years ago. It is presented here for posterity and in the hopes that it may still be useful in some way.

The Simple Directmedia Layer (SDL) library provides several methods of displaying images, many of which may be used interchangeably. In order to help developers choose which method to use in a given set of situations, this post presents performance numbers for a variety of these display methods.

Read more...