Blog

Sending Mail via GMail with JavaMail

If you use JavaMail and/or the Spring MailSender bean to send mail through a GMail account with JavaMail these days, you get an authentication error saying GMail blocks less secure apps. At that point there are two options: Configure your GMail account to accept low-security connections (e.g. https://www.google.com/settings/security/lesssecureapps) Configure your JavaMail sender to use OAuth for authentication This article will describe the second approach in detail. OAuth Basics Instead of usernames and passwords, OAuth deals with tokens. First, you set…

SBT: Group annotated tests to run in forked JVMs

SbtTestGrouping Running tests that use a HiveContext On our current project, we utilize Spark SQL and have several ScalaTest based suites which require a SparkContext and HiveContext. These are started before a suite runs and shut down after it completes via the BeforeAfterAll mixin trait. Unfortunately due to this bug (also see this related pull request), if a HiveContext is recreated in the same JVM, this exception is thrown: "java.sql.SQLException: Another instance of Derby may have already booted the database”….

Slick 3.1.0, Oracle 11g, and UUID columns

SlickUUIDs UUIDs to the rescue I recently decided to change our primary key strategy from an auto-incrementing Long to UUID (aka globally unique IDs). Early on in a project, this should be a relatively simple refactoring (neither the software nor any data has been released yet). First of all and most importantly, UUIDs provide uniqueness (with a high probability) across multiple databases. Second, if you are sending numeric identifiers back in JSON and not serializing / deserializing them as strings,…

Binding custom types in plain SQL queries in Slick

Hierarchical Queries Hierarchical Queries and Oracle Not everything is as fun as the first time you discover the power of monads and for-comprehensions, or realize the state machine you wrote with pattern matching is super easy to read and follow! Some days its business as usual, which as a software developer means you’re usually trying to bend a framework to your will (or cursing the estimate you were forced to give). Today it would happen to be Slick and native…

Testing Angular 2 Components with Unit Tests and the TestComponentBuilder (RC1+)

Note – I’ve updated this article and created a new github project using angular-cli to test it. Run all tests with ng test after following instructions at https://github.com/krimple/angular2-unittest-samples-rc Testing Components In my last post, I discussed how to write tests in Angular 2 based on the new angular-testing API. We learned how to stand up a test and use the test injector, and how to mock the network requests to the Http service using the MockBackend. In this post, we'll…

Sensu: Finally the Nagios Replacement I Have Been Looking For!

Nagios, the popular open source system and networking monitoring service, is awesome. It gives you so much flexibility that expensive commercial software like Solarwinds and Spiceworks just doesn’t have. However after I moved my infrastructure to Chef, Nagios was constantly giving me issues. The configuration scheme just doesn’t fit well in an autonomous environment. In this blog article I review how I found a replacement for Nagios,

Making a Java SafeString that works with all unicode characters

In Java, there is an issue with String when using characters that take up more than 2 bytes in UTF-16. substring() and similar methods can split the character in the middle. I was thinking switching Strings to UTF-8 might be good, and there are currently two JEPs for Java 9 somewhat related to this. 226: UTF-8 Property Files and 254: Compact Strings. But thinking about this a little more, I don’t necessarily want a UTF-8 String class, but a String class that works with all unicode characters. Here’s how I did it.

How can we help your company with your development needs?

Contact Us