Advent of Code programming puzzles

Every day in December I am doing a programming puzzle. The series is called Advent of Code and it follows the advent calendar approach. Every day from the 1st until the 25th of December one puzzle is unlocked. The puzzles get gradually harder and each puzzle has two parts, where the first part is easier than the second. It is not about winning Well, for some people it is. Only the first 100 answers are rewarded with points on the global leader board. I’m simply not fast enough to compete for a top 100 position. So for me it is not about winning. For most people it is not, as 95 thousand people have made the first puzzle and there is only place for 100 entries on the global leader board. The yearly unofficial survey asks people why they play and the reasons given are: for the fun (1st), the challenge (2nd) or to improve their skills (3rd). ...

December 23, 2019 · Maurits van der Schee

How mature is your REST API?

In my career I have seen many REST APIs. They all implement Create Read Update and Delete (CRUD) on single entities with verbs as described by the REST standard. All of them do the same 4 (additional) things: column filtering, row filtering, authorization and document nesting. In this post we will look at a few implementations and explore a system for maturity qualification of a REST API implementation. Column filtering (sparse field-sets) Row filtering (with filter language) Authorization (on tables, columns, rows) Document nesting (based on relations) As a software architect I’m interested in standards and standard implementations. We will evaluate a few implementations and score the 4 additional tasks on the following scale: ...

November 13, 2019 · Maurits van der Schee

TreeQL and PathQL compared

TreeQL (see: TreeQL.org) and PathQL (see: PathQL.org) are two API query languages that I have designed and implemented. These implementations can save you time implementing your queries and CRUD operations on database models as REST API’s in (administrative) business applications. TreeQL design philosophy In one sentence: TreeQL is a feature-rich REST protocol for exposing database tables as resources over the web using nested JSON. It does: .. follow the REST protocol closely .. have a limited (spatial) filtering language .. nesting based on foreign key relations .. hide the underlying SQL dialect .. no real joins, only sub-selects .. support application authorization Example query to get the content of post 1 with the messages in the comments: ...

November 2, 2019 · Maurits van der Schee

Sorting JSON for unit testing

When you are creating unit tests for things that produce JSON, you will quickly find that you need to compare two JSON strings for equality. The order of key/value pairs within a JSON object is not defined, while the order within JSON arrays is. The spec (RFC 7159) says: An object is an unordered collection of zero or more name/value pairs… An array is an ordered sequence of zero or more values. ...

October 26, 2019 · Maurits van der Schee

Automatic REST API for SlimPHP 4 (minimal)

Last month we showed how to use PHP-CRUD-API (2k stars) as a library executed on an endpoint in the SlimPHP 4 framework (10k stars). In the previous post we used the recommended way to set up a SlimPHP 4 project and in this post we take a minimal approach (using as little code as possible). Install SlimPHP4 We download composer and use it to install the two projects: wget https://getcomposer.org/composer.phar php composer.phar require slim/slim:^4 php composer.phar require mevdschee/php-crud-api This is all that is needed. ...

September 26, 2019 · Maurits van der Schee

GopherCon 2019: videos online

GopherCon is the original Go conference. It debuted in 2014 and was celebrating it’s five-year anniversary last year. Like every year it was held in the Colorado Convention Center in Denver and it had about 1800 attendees. The videos are posted on the Gopher Academy Youtube channel and are also linked here: Thursday July 25 9:00 Welcome Gophers! Russ Cox - On the Path to Go 2 [34:57] Elena Morozova - How Uber Goes [23:31] 10:15 Morning Break ...

August 28, 2019 · Maurits van der Schee

Automatic REST API for SlimPHP 4

Today, about 4 years after the initial commit, the promise of “upload a single PHP file to add a REST API to your database” is still very much alive. It is now possible to use PHP-CRUD-API (2k stars) as a library executed on an endpoint in the SlimPHP 4 framework (10k stars). This is possible as they both adhere to the PHP-FIG’s (PHP Framework Interop Group) HTTP standard PSR-7. Install SlimPHP 4 You need to run the following commands on your Linux system: ...

August 16, 2019 · Maurits van der Schee

Script to undelete all files in Git

I have written a Bash script to quickly undelete all files that are deleted in a Git repository (on any previous commit). The script only recovers the last known state of files of which the filename is not currently in use. It is optimized so that it executes quickly when large numbers of files are deleted. Usage Copy the script into the repository that you want to undelete files in and run: ...

August 13, 2019 · Maurits van der Schee

API authorization strategy: use the DB

When building an API you may find the need to implement authorization in a generic way. Using the authorization implementation of your (relational) database is a well-documented, simple and proven strategy. The user that is used for the database connection should in this scenario depend on the authenticated user of the API (and it’s authorization). This post will explain how to apply this strategy. But before we start let’s take a step back and think about what it is that you may be authorizing. ...

July 29, 2019 · Maurits van der Schee

Database multi-tenancy strategies

When you are building a SaaS software product you need to chose a way to store the data of your customers. You can store everything in one database or you can create multiple databases. There are roughly four main approaches. This article discusses the up- and downsides of these approaches. Multi-tenancy: 4 approaches First let’s try to summarize the four identified approaches: All customers in one database (fully normalized) Every table has a CustomerID field (de-normalized) A database for every customer and one shared database Every customer has it’s own database Now let’s try to find some up- and downsides for each of them. ...

July 28, 2019 · Maurits van der Schee