java

How to use the Lightbend Config library in a Scala or Java application alvin December 10, 2019 - 11:47am

Table of Contents

  1. Solution
  2. Discussion
Table of Contents1 - Solution2 - Discussion

Scala problem: You want to be able to read configuration files that are written in the Lightbend “Config” file format.

Back to top

Solution

Lightbend — initially named Typesafe — created a configuration file format named HOCON, which stands for, “Human-Optimized Config Object Notation.” As an example, a small HOCON configuration file looks like this:

Scala: How to search a directory tree with SimpleFileVisitor and Files.walkFileTree alvin December 7, 2019 - 2:01pm

As a brief note to self, if you ever want to write some code using Scala that recursively descends through a directory tree, here’s a solution that uses the Java SimpleFileVisitor and Files.walkFileTree method. First, here’s a skeleton class for the SimpleFileVisitor part of the solution:

A `printf` format reference page (cheat sheet)

Summary: This page is a printf formatting cheat sheet. I originally created this cheat sheet for my own purposes, and then thought I would share it here.

A great thing about the printf formatting syntax is that the format specifiers you can use are very similar — if not identical — between different languages, including C, C++, Java, Perl, PHP, Ruby, Scala, and others. This means that your printf knowledge is reusable, which is a good thing.

Five good ways (and two bad ways) to read large text files with Scala

I’m working on a small project to parse large Apache access log files, with the file this week weighing in at 9.2 GB and 33,444,922 lines. So I gave myself 90 minutes to try a few different ways to write a simple “line count” program in Scala. (Not my final goal, but something I could use to measure file-reading speed without applying my algorithm.)

GraalVM native executables can run faster than Scala/Java/JVM applications, with much less memory consumption

In two small tests where GraalVM was able to create a native executable, the native executable ran significantly faster than the equivalent Scala/Java code running with the Java 8 JVM, and also reduced RAM consumption by a whopping 98% in a long-running example. On the negative side, GraalVM currently doesn’t seem to work with Swing applications.

Notes on looking at MacOS application/process memory usage

Very briefly, I spent a little time today trying to understand how much memory/RAM a Java/Swing application was really using, and these are my notes from that excursion. Note that the app is bundled as a MacOS/Java app I named AlPad, but from some system perspectives it is only seen by the name JavaAppLauncher. Here are my notes, which will hopefully be useful to me in the future:

How to fire MacOS notifications with AppleScript and Scala

Table of Contents1 - A “Hello, world” MacOS AppleScript notification2 - AppleScript: Mac notification with a sound3 - How to add a title and subtitle to your notification4 - Running from Scala (or Java)5 - See also6 - Summary

Summary: This tutorial demonstrates how to fire MacOS system notifications with AppleScript and Scala (or Java).

In this article it helps if you already know a little bit about AppleScript, though that’s not completely necessary. Near the end of the tutorial I show how to invoke the AppleScript code using Scala, so feel free to skip down to there if you just want to see that — you can always read the stuff at the top for reference later.