Skip to content

Instantly share code, notes, and snippets.

@colinjfw
colinjfw / kustomize-deploy.sh
Last active December 23, 2021 18:28
Kubernetes deployment strategy using Kustomize and a few basic tools. Replaces helm charts with simple tooling solutions.
# Kustomize based apply workflow. Requires jq, yq, kubectl, kustomize, mustache.
#
# Expected variables
# - namespace Namespace for all resources.
# - release A unique name to give to this collection of manifests.
# - revision Release revision.
# - images Image replacements.
# - variables Variable replacements.
#
# Example inputs:
@colinjfw
colinjfw / ecs-deploy.sh
Created April 11, 2019 04:06
ECS Deployment Script
#!/bin/bash
set -e
# Set the variables below or add them dynamically.
region="us-west-2"
environment="<environment>"
cluster="<cluster>"
commit=$(git rev-parse --short HEAD)
full_commit=$(git rev-parse HEAD)
const express = require('express');
const app = express();
function start() {
return { color: "#3d00a6" }
}
function move(state) {
console.log(state);
return { move: 'right' }
const express = require('express');
const app = express();
app.listen(3000, () => {
console.log("Listening on port 3000");
});
function move(state) {
const head = state.you.body[0];
const neck = state.you.body[1];
const moves = ['up', 'down', 'left', 'right'];
for (const move of moves) {
const coord = moveAsCoord(move, head);
if (!offBoard(state, coord) && !coordEqual(coord, neck)) {
return {move: move};
}
function coordEqual(a, b) {
return a.x === b.x && a.y === b.y
}
function move(state) {
const head = state.you.body[0];
const moves = ['up', 'down', 'left', 'right'];
for (const move of moves) {
const coord = moveAsCoord(move, head);
if (!offBoard(state, coord)) {
return {move: move};
}
}
function offBoard(state, coord) {
if (coord.x < 0) return true;
if (coord.y < 0) return true;
if (coord.y >= state.board.height) return true;
if (coord.x >= state.board.height) return true;
return false; // If it makes it here we are ok.
}
function move(state) {
const head = state.you.body[0];
const moves = ['up', 'down', 'left', 'right'];
for (const move of moves) {
const coord = moveAsCoord(move, head);
// We now know where this is going to be!
}
}
function moveAsCoord(move, head) {
switch (move) {
case 'up':
return {x: head.x, y: head.y-1};
case 'down':
return {x: head.x, y: head.y+1};
case 'left':
return {x: head.x-1, y: head.y};
case 'right':
return {x: head.x+1, y: head.y};