Skip to content

Instantly share code, notes, and snippets.

View officialhopsof's full-sized avatar

Brandon Murphy officialhopsof

  • NextStep
  • Seattle
View GitHub Profile
@officialhopsof
officialhopsof / calc.rb
Created April 15, 2021 17:06
Token based calculator
Inst = Struct.new(:op, :a, :b) do
def comp
raise "Missing Operand: a" unless a
raise "Missing Operand: b" unless b
return a.to_i + b.to_i if op == '+'
return a.to_i - b.to_i if op == '-'
raise "Invalid Op: #{op}"
end
end
// In order to automatically deploy our ApiStage from Cloudformation, our
// Deployment resource name needs to be unique. In order to achieve this,
// we are to create a preprocessor that will find the string "$TIMESTAMP$"
// and replace it with the system time. This will allow us to create a unique
// resource name.
const fs = require("fs")
const path = require("path")
const replacements = [
{ input: /\$TIMESTAMP\$/g, output: Date.now().toString() }