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:

// WTF's added by me, class cut down for brevity.
public class ModelAndView {
// WTF?!
/** View instance or view name String */
private Object view;
public ModelAndView(String viewName) {
this.view = viewName;

FreeBSD on a MacBook Pro

Since 2008 or 2009 I work on Apple hardware and OS: back then I grew tired of Linux desktop (which is going to be MASSIVE NEXT YEAR, at least since 2001), and switched to something that Just Works. Six years later, it less and less Just Works, started turning into spyware and nagware, and doesn't need much less maintenance than Linux desktop — at least for my work, which is system administration and software development, probably it is better for the mythical End User person. Work needed to get software I need running is not less obscure than work I'd need to do on Linux or othe Unix-like system. I am finding myself turning away from GUI programs that I used to appreciate, and most of the time I use OSX to just run a terminal, Firefox, and Emacs. GUI that used to be nice and unintrusive, got annoying. Either I came full circle in the last 15 years of my computer usage, or the OSX experience degraded in last 5 years. Again, this is from a sysadmin/developer ki

// ==UserScript==
// @name Kanji.koohii Stroke Order
// @namespace koohiistroke
// @description Adds kanji stroke order to the study and review sections on kanji.koohii.com
// @include http://kanji.koohii.com/study/kanji/*
// @include https://kanji.koohii.com/study/kanji/*
// @include http://kanji.koohii.com/review*
// @include https://kanji.koohii.com/review*
// @grant GM_xmlhttpRequest
// @version 1.1
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