tl;dr: When mocking functions that have value classes as arguments, use Mockito matchers on the wrapped value instead of on the value class (i.e. MyId(any[Int]) instead of any[MyId]) or else NullPointerExceptions will be thrown at runtime.
Last weekend I created a GitHub Action and submitted it to the GitHub Hackathon. It was a relatively simple workflow that brings up a WireMock API for tests to run against.
It was pretty cool as I hadn’t had a chance to write a Node application before. (The other way to write an Action is to build a Docker image, in which case any language can be used.)
In this post, I’m going to share my thought process bemoan my follies as I went about writing the Action.
Tl;dr In JavaScript, use async await to deal with intermediate state, much simpler. Also, just having documentation from types make TypeScript awesome, even if you don’t write your application in TypeScript.
Inspired by this post, I built a pipeline to extract facilities from ~700K hotels, combine all repeated facilities and rank by number of occurences, all in Bash.
TL;DR commands:
echo"supplier_id,supplier_value,mapping_type"> header.csv
cat hotel-facility-dump | \ #read from file
rg "facility:" | \ #find relevant logsawk-F'facility: ''{print $2}' | \ #extract content in the form of 'facility name,facility code'sort | \ #sort for the next stepuniq-c | \ #get all unique entries with countsort--numeric-sort--reverse | \ #get entries with count in descending orderhead-n 500 | \ #take top 500 entriesawk-F' "''{print 12345",""\42"$2}'>\ #remove count and put back double quote
hotel-processed #write to output filecat header.txt hotel-processed > hotel-facilites.csv
I was recently upgrading a library at work from using Scala 2.11 to 2.12. Here are some sbt tricks that I picked up while trying to perform the migration.