Skip to content

Instantly share code, notes, and snippets.

View nbrandaleone's full-sized avatar

Nick Brandaleone nbrandaleone

View GitHub Profile
@nbrandaleone
nbrandaleone / container-insights-installation.md
Last active January 6, 2020 18:37
[Installing Container Insights on EKS] #kubernetes

Docs

curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/master/k8s-yaml-templates/quickstart/cwagent-fluentd-quickstart.yaml | sed "s/{{cluster_name}}/cluster-name/;s/{{region_name}}/cluster-region/" | kubectl apply -f -

Replace the "cluster-name", and "cluster-region" with proper info.

Delete Container Insights: curl https://raw.githubusercontent.com/aws-samples/amazon-cloudwatch-container-insights/master/k8s-yaml-templates/quickstart/cwagent-fluentd-quickstart.yaml | sed "s/{{cluster_name}}/cluster-name/;s/{{region_name}}/cluster-region/" | kubectl delete -f -

@nbrandaleone
nbrandaleone / readme.md
Created September 20, 2019 13:39 — forked from thomasdarimont/readme.md
Example for decoding a JWT Payload with your Shell (bash, zsh...)

Setup

Add this to your .profile, .bashrc, .zshrc...

decode_base64_url() {
  local len=$((${#1} % 4))
  local result="$1"
  if [ $len -eq 2 ]; then result="$1"'=='
  elif [ $len -eq 3 ]; then result="$1"'=' 
  fi
 echo "$result" | tr '_-' '/+' | openssl enc -d -base64
@nbrandaleone
nbrandaleone / firelens-setup.md
Created September 10, 2019 20:56
[Setup ECS firelens logging] #ecs #fargate #logging

This gist shows how to setup the new preview feature called Firelens, which runs on Amazon ECS. Detailed instructions on the product is located here.

Firelens is a fluentbit log shipper, which is extremely light-weight in terms of memory footprint. It has been altered to support AWS CloudWatch and AWS Firehose, along with its traditional destinations. Firelens operates as a "side-car" container, enriches the logs, and then ships them off to its destination. The side-car can operate on 25 MB of RAM.

Firelens can work with ECS / Fargate. I have not tested it with Kubernetes, so YMMV.

Here is an example of an enriched log:

{
@nbrandaleone
nbrandaleone / ecs iam roles
Created September 10, 2019 20:28
[ECS IAM permissions explanations] #ecs #iam
The only necessary role is the Container Instance IAM role. This role allows the ECS agent (running on your EC2 instance) to communicate with Amazon ECS.
There are five other roles that you may also find useful, for different purposes:
ECS Service-Linked role (SLR) - This role enables Amazon ECS to manage a variety of AWS resources associated with your application on your behalf. When using a Service, this role allows Amazon ECS to manage the load balancer (Classic Load Balancers, Application Load Balancers, and Network Load Balancers) and service discovery (with Route 53) associated with your service. When using task networking, this role allows Amazon ECS to attach and detach Elastic Network Interfaces (ENIs) to your tasks. This role is required when using AWS Fargate.
Service Scheduler IAM role - Prior to the introduction of the ECS Service-Linked role (SLR), this role was used in conjunction with a Service to enable Amazon ECS to manage the load balancer associated with your service. If you want
I think I can provide an inaccurate but short version of the relationships among them.
At first Clojure used Maven for building.
Maven is boring, people made Leiningen, configuring with maps, and the plugin lein-cljsbuild can build ClojureScript.
Leiningen contains only configurations, no logics. People want to compose tasks, so they made Boot, and provided boot-cljs and boot-reload for ClojureScript.
Webpack is cool with hot module replacement, we got lein-figwheel for that.
All tools above relies on JVM heavily, in order to run ClojureScript on devices without JVM, like iOS, Planck was created based on self-hosted ClojureScript and JavaScriptCode, which is a ClojureScript runtime.
Planck does not support modules from npm, then Lumo was created to make full use of V8 engine.
We still feel the toolchain is too heavy for developers from JavaScript ecosystem, shadow-cljs was refactored to be more friendly, supporting npm modules, relies on JVM but in the background, also with some f
@nbrandaleone
nbrandaleone / gist:d4c8ccc23ad89f6cd963506215458461
Created September 19, 2018 18:34
kubernetes kubectl configuration switcher (kcs)
#!/usr/bin/env bash
# Nick Brandaleone - September 2018
#
# Based upon a script by: https://github.com/scottslowe/scripts/blob/master/kcs
# I found that the copying of config files to be unreliable, so I simply
# echo the proper command that needs to be executed by the user.
# Set some variables that will be used later
KUBEDIR="$HOME/.kube"
@nbrandaleone
nbrandaleone / ttt-mcts.clj
Created July 6, 2015 23:21
Monte Carlo Tree Search for Tic-Tac-Toe
(ns ttt-mcts.core
(:gen-class))
(comment
This program implements a monte carlo search algorithm to play tic-tac-toe.
)
;The "MCTS" algorithm has four steps
;1) Randomly pick a branch of the tree (in practice, the more
; successful branches are usually weighted to be chosen more).
;2) Expand the branch (create a node).
@nbrandaleone
nbrandaleone / ttt-minmax.clj
Created June 23, 2015 12:16
tic-tac-toe, written in Clojure. Computer moves are decided by min-max algorithm.
(ns ttt-minmax.core
(:gen-class))
(comment
This program implements a min-max algorithm to play tic-tac-toe.
The program generates all possible moves by examining the empty slots in the playing board.
It creates a tree, growing out from the current board position. It assigns a number to each leaf node
based upon the outcome of the game. It propogates this back up to the current board position, and
makes the move which maximizes its 'utility' function, and minimizes that of its oponent.
@nbrandaleone
nbrandaleone / SwiftLife.swift
Created June 18, 2015 19:02
Conway Game of Life, written in Swift (in a functional manner).
//
// ViewController.swift
// SwiftLife
//
// Created by Nick Brandaleone on 6/1/15.
// Copyright (c) 2015 Nick Brandaleone. All rights reserved.
//
import UIKit
@nbrandaleone
nbrandaleone / clojureLife.clj
Last active August 29, 2015 14:23
Conway Game of Life. Written in Clojure.
;;
;; Source code originally from "Clojure Programming" (2012) by Chas Emerick, Brian Carper and Christophe Grand
;;
(ns gol.core
(:gen-class))
(defn neighbors
"find our cell neighbors"
[[x y]]
(for [dx [-1 0 1] dy [-1 0 1] :when (not= 0 dx dy)]