Skip to content

Instantly share code, notes, and snippets.

@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
@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 / 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.

What is a swarm?

Consists of:

  • multiple Docker hosts running in swarm mode
  • act as managers and workers

A given host can be a:

  • manager
  • worker
  • or perform both roles
@kchien
kchien / Warmup.md
Created April 14, 2018 02:51
Our warm-up is...a warm-up

Choose reasonable jumps all the way up so that you are not squatting something really close to your work weight. For example, if you are going to squat 275x5x3 for your work set today, 260x5 for your last warm-up is not a good choice as it could rob some of the energy you need to complete 275x5x3.

When you are pulling above 225 for your work set, start with 135x5.

@kchien
kchien / How to connect a PS3 controller.md
Created October 10, 2015 18:41 — forked from hlung/How to connect a PS3 controller.md
How to connect PS3 controller on Mac OSX, PC

How to connect PS3 controller on Mac OSX, PC, etc.

This is how you connect PS3 controller to Mac OSX, PC, etc. when previously connected to a PS3. You will need a Mini USB cable. Overcome your laziness, get up of your chair, and go get one!

A big misconception is that keep holding PS button will reset the controller's pairing. It DOES NOT! From my testings, the controller keeps paring with the last machine it was CONNECTED VIA A USB CABLE.

Here are the steps:

package demo;
public abstract class Homer implements EatsDonuts{
public Homer() { }
public void eat() {
Donut d = getDonut(); //We want a new donut every time
//eat donut
}
//here is where Spring will do its magic and return a prototype
ld: in /usr/local/lib/libiconv.2.dylib, missing required architecture x86_64 in file
collect2: ld returned 1 exit status
make[1]: *** [../../.ext/x86_64-darwin10.5.0/tcltklib.bundle] Error 1
make: *** [mkmain.sh] Error 1
/Users/kchien/.rvm/rubies/ruby-1.9.2-p0, this may take a while depending on your cpu(s)...
ruby-1.9.2-p0 - #fetching
ruby-1.9.2-p0 - #extracted to /Users/kchien/.rvm/src/ruby-1.9.2-p0 (already extracted)
ruby-1.9.2-p0 - #configuring
ruby-1.9.2-p0 - #compiling
ruby-1.9.2-p0 - #installing
ruby-1.9.2-p0 - updating #rubygems for /Users/kchien/.rvm/gems/ruby-1.9.2-p0@global
ruby-1.9.2-p0 - updating #rubygems for /Users/kchien/.rvm/gems/ruby-1.9.2-p0
ruby-1.9.2-p0 - adjusting #shebangs for (gem).
ruby-1.9.2-p0 - #importing default gemsets (/Users/kchien/.rvm/gemsets/)
@kchien
kchien / 0001-Changed-expectation-to-use-regex.patch
Created December 10, 2010 00:28
rspec-expectations : include.feature change
From 2d348a3d4a69c167572b42ac65961b1c66d086f7 Mon Sep 17 00:00:00 2001
From: Kenrick Chien <ken.chien@gmail.com>
Date: Thu, 9 Dec 2010 19:22:26 -0500
Subject: [PATCH] Changed expectation to use regex.
---
features/matchers/include.feature | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/features/matchers/include.feature b/features/matchers/include.feature