Skip to content

Instantly share code, notes, and snippets.

@kchien
kchien / friendly_helpful_code.md
Last active August 18, 2022 15:25
Personal thoughts on writing readable, friendly code so those that come after you can maintain it

Description

This is a work in progress and is not to be interpreted as hard and fast rules or laws, but rather just guidelines and observations from the code I've been working on.

Unexplained numbers, constants, etc. in tests

Example: a test that I was reading made an assertion that expected an audit count to increase by seven (7). It wasn't obvious at all why the SUT would generate seven audit records. I suppose this exposed another code smell, since a lot of the auditing occurred magically (implicitly via ActiveRecord callbacks), so I would recommend: "don't test implicit, hidden behavior" by testing other things.

@kchien
kchien / description.md
Created August 26, 2022 17:01 — forked from juanje/description.md
Connect services with docker-compose at multirepo project

Connect services with docker-compose at multirepo project

Sometimes you have a project with different services (or microservices) and each one of them has its own repository. At those cases, tests the whole project (and its interactions) can be challenging.

With Docker and Docker Compose you can run easily each service from its repo, but for making them to see each other you (usually) need to manually create a network with Docker, assume so facts (as directories names) or do some crazy network configurations.

TL;DR

You have the final configuration here.

@kchien
kchien / puma_client_cert_auth.md
Last active August 30, 2022 19:39
Enforcing client cert authentication with Puma

Purpose

This is for a private, internal microservice. I want to enforce client authentication with X.509 certs and I don't care -- at the moment -- whether or not the client wants to verify the server (the called microservice).

Stack for the internal microservice

  • puma
  • sinatra
  • ruby 2.7 base image
  • docker-compose