Skip to content

Instantly share code, notes, and snippets.

View nrktkt's full-sized avatar

Nathan Fischer nrktkt

View GitHub Profile
@nrktkt
nrktkt / beefy5L.md
Last active February 17, 2021 08:18
Beefy 5 Layer Architecture

Much like the gross, tasty burrito of the same name, this backend architecture has five layers.

  1. Surface
  2. Authentication
  3. Authorization
  4. Service
  5. Client

Layers

@nrktkt
nrktkt / analytics-cheat-sheet.sql
Last active October 21, 2020 02:17
cheat sheet with postgres queries for common analytics metrics
-- based off the metrics on the dashboard of the mixpanel music finder demo
create table events (
id bigserial primary key,
user_id varchar,
created_at timestamptz not null default now(),
name varchar not null,
properties jsonb not null default '{}'
);
@nrktkt
nrktkt / README.md
Last active September 25, 2020 20:26
Create a map of ELB traffic in GPX format.

Requires ammonite

Written to use the ipstack.com API, but can be easily modifed to work with any geolocation api by editing the geolocate function.

Usage

cat your-elb-log-file.log | ./elb-geo.sc --ipstackKey $YOUR_API_KEY > elb-map.gpx
@nrktkt
nrktkt / websocket-auth.md
Last active August 21, 2020 23:48
Securing websocket connections from browsers

Securing a websocket connection is a mess.

A good solution needs to

  1. work from the browser
  2. be hardened against CSRF
  3. be stateless
  4. work on IE 11 :(

To that end, the following should work:

@nrktkt
nrktkt / OrderedIterable.scala
Created April 11, 2020 23:19
A straightforward BST based Iterable immutable persistent data structure. Useful if the need for duplicates prevents use of scala.collection.immutable.SortedSet
import cats.Show
import scala.collection.immutable._
import scala.collection.AbstractIterator
import OrderedIterable.{Nill, Node}
sealed abstract class OrderedIterable[+A] extends Iterable[A] {
def apply(i: Int): A
@nrktkt
nrktkt / ExampleSpec.scala
Last active February 27, 2020 07:34
AWS unit tests with localstack and scalatest
import cloud.localstack.docker.annotation.LocalstackDockerProperties
import cloud.localstack.TestUtils
import org.scalatest.{BeforeAndAfterEach, FlatSpec}
import ...LocalstackSpec
@LocalstackDockerProperties(services = Array("s3"))
class ExampleSpec
extends FlatSpec
with BeforeAndAfterEach
with LocalStackSpec {
@nrktkt
nrktkt / tillerless.md
Last active February 17, 2021 01:12
Using Helm without Tiller

Intro

Assume we have some Helm chart we want to deploy, but we don't want to install Tiller on our Kubernetes cluster. This doc will cover how to deploy a helm chart without installing Tiller on the cluster, but will not go into the motivations or tradeoffs of doing so.

Prereqs

  1. Helm installed locally
  2. Helm initialized (helm init --client-only)
  3. kubectl working for your cluster
@nrktkt
nrktkt / README.MD
Created August 12, 2019 18:42
Key based scala rate limiter

Scala key based rate limiter with automatic key eviction.

Depends on Guava and Akka Actors.

@nrktkt
nrktkt / gear.md
Last active January 5, 2019 23:16
Six pieces of outdoor clothing everyone should own

These staples should last you many years and be usable in almost all your outdoor persuits, from summer hiking to fall backpacking, to snowsports, and even a bit of light summer mountaineering.
Without further ado we'll start from the bottom to the top.

The gear

  1. Wool socks
    Wool stays warm and wicks moisture when wet. As long as you've got breathable shoes wool socks can be comfortable even in the summer. As an added perk they're nice and cheap.
  2. Softshell pants Tough, breathable, and windproof are the trademark characteristics of softshell pants. They're typically not insulated and so are suitable for warm weather, but their wind resistance makes them plenty warm when the mercury drops (especially when worn over a long baselayer).