Skip to content

Instantly share code, notes, and snippets.

const express = require('express');
const app = express();
app.listen(3000, () => {
console.log("Listening on port 3000");
});
const express = require('express');
const app = express();
function start() {
return { color: "#3d00a6" }
}
function move(state) {
console.log(state);
return { move: 'right' }
@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)
@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:
def move(state)
puts state
{ move: 'right' }
end
def move(state)
head = state[:you][:body][0]
...
end
def move_as_coord(move, head)
case move
when 'up'
return {x: head[:x], y: head[:y]-1}
when 'down'
return {x: head[:x], y: head[:y]+1}
when 'left'
return {x: head[:x]-1, y: head[:y]}
when 'right'
return {x: head[:x]+1, y: head[:y]}
@colinjfw
colinjfw / move_1.rb
Last active September 28, 2019 01:08
def move(state)
head = state[:you][:body][0]
moves = ['up', 'down', 'left', 'right']
moves.each do |move|
coord = move_as_coord(move, head)
# We now know where this is going to be!
end
end
def off_board(state, coord)
return true 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 false # If it makes it here we are ok.
end
def move(state)
head = state[:you][:body][0]
moves = ['up', 'down', 'left', 'right']
moves.each do |move|
coord = move_as_coord(move, head)
unless off_board(state, coord)
return { move: move }
end
end