avatar

Joseph Earl

Lead Consultant @thoughtworks

Customizing the logback-access format

If you’re already using Logback and Logback Logstash Encoder with Spring Boot to log to something like ELK or Splunk and want to add HTTP access logs to your application then logback-access is simple to integrate and the output format and destination can be easily configured through XML just like for standard Logback. To begin add the logback-access dependency to your project: implementation 'ch.qos.logback:logback-access' Then configure the embedded server (Tomcat in this case) to integrate with logback-access:

JavaScript and Semicolons

To semicolon or not to semicolon? The comments on this StackOverflow answer should help you figure out whether they are currently in fashion. jack: Nonsense! You DO need to use semicolons! tacone: It’s 2014 now, so we need semicolons again. Mark Knol: It’s 2015 now, so we don’t need semicolons again. Saeid Yazdani: Will we need to use semicolons in 2016? Foo L:

Using ES6 `import` in tests with Jest and Rollup

Today while working on a new version of Preliminaries using ES6 I was trying to get both Rollup working to bundle my code and Jest to run tests when importing my code. Rollup recommends* something like the following .babelrc: { "ignore": [ "node_modules/**" ], "presets": [ ["es2015", { "modules": false }], "stage-0" ], "plugins": [ "external-helpers" ] } which worked great for bundling my code, so I wrote a simple test:

Optimising CSS delivery

In a previous post I covered my efforts to improve the PageSpeed ranking of my site. Today I achieved a perfect 100/100 PageSpeed score on Desktop. To do this I had to optimise my CSS delivery. What does that mean? Well, previously, all of my styles were loaded using a link in the head: <html> <head> <link rel="stylesheet" href="/styles.css"> </head> <body> <p>Content</p> </body> </html> But this is bad and blocks rendering until all of styles.

Preliminaries — a front matter parser for Node.js

Preliminaries is a small Node.js library for parsing front matter in Markdown documents. You can easily parse YAML, JSON and TOML front matter, with custom delimiters if needed: var preliminaries = require('preliminaries')(true); require('preliminaries-parser-yaml')(true); require('preliminaries-parser-toml')(true); // `preliminaries.parse` returns an object `{data: {}, content: ''}` with the front // matter data and content preliminaries.parse('{\n"name":"Joseph"\n}\nContent'); preliminaries.parse('---json\n{\nname: Joseph\n}\n---\nContent'); preliminaries.parse('---\nname: Joseph\n---\nContent'); preliminaries.parse('---yaml\nname: Joseph\n---\nContent'); preliminaries.parse('+++\nname = "Joseph"\n+++\nContent'); preliminaries.parse('~~~\nname: Joseph\n~~~\nContent', {delims: '~~~', lang: 'yaml'}); You can also stringify a JavaScript object and a content string back out:

Scrollable CSS overlay

I recently had the need to create a CSS overlay for the search function on this site. My requirements were that the overlay should be scrollable, whilst the overlay was visible the body should not be scrollable, and any HTML for the overlay should be after the main content. I first tried adding overflow: hidden to the body when the overlay was shown using JavaScript but this has the effect of scrolling the body and main content immediately to the top, giving a jarring user experience when the overlay is dismissed.

Slack is not a free product

Slack’s free tier is an unlimited trial period, not a permanent solution for your business. It might look tempting to use this forever – you can have unlimited users, but the limitation is in the fine print in the bullet points below: up to 10k of your team’s most recent messages 5GB total file storage for the team Would you use an email service that only kept your whole companies' most recent 10,000 messages?

Winding down at the end of the work day

Recently a good colleague at ThoughtWorks and the tech lead on my current project, Sophie Holden, has been taking a group of us through the ThoughtWorks tech lead training materials. This has involved a number of group whiteboard drawing sessions at the end of the day. I’ve found that ending the work day with light-hearted, slightly physical activity such as a group whiteboard sketching activity really helps me leave work in a good mood.

SSH authentication with YubiKey

One great thing I’ve found I can do with my YubiKey is use it for SSH certificate based authentication. Your private key is stored on your YubiKey rather than your computer and requires your PIN to access or alter. This means you can take your SSH logins wherever you go, to any computer that supports a YubiKey! Instead of your computer being authorized, it is your YubiKey. The easiest way to get started on macOS is to use YubiKey PIV Manager (or brew cask install yubikey-piv-manager).

Search your Hugo static site using lunr.js

In this post I’ll show you how you can add easily add search to your Hugo static site using Hugo’s Scratch feature and the lunr.js JavaScript library on the client. First we’ll need to create a JSON index of all our documents as part of our Hugo site generation process. Add a new document with hugo new search-index.md and set the type to search-index and the url the index.json in the frontmatter: