Skip to content

Instantly share code, notes, and snippets.

View joshgarnett's full-sized avatar

Joshua Garnett joshgarnett

View GitHub Profile
@joshgarnett
joshgarnett / main.tf
Created November 9, 2016 00:03
Minimal ECS Terraform Example
# Update your region
provider "aws" {
region = "${var.aws_region}"
}
resource "aws_ecs_cluster" "ecs_cluster" {
name = "test-cluster"
}
#
@joshgarnett
joshgarnett / lets-encrypt-route53.rb
Last active March 17, 2021 09:01
Ruby script to use as a hook for the letsencrypt.sh client
#!/usr/bin/env ruby
require 'aws-sdk'
#
# This script requires you to have the following environment variables set:
# AWS_REGION="us-west-2"
# AWS_ACCESS_KEY_ID="<YOUR_KEY>"
# AWS_SECRET_ACCESS_KEY="<YOUR_SECRET_KEY>"
#
@joshgarnett
joshgarnett / 1-test.proto
Last active February 23, 2018 20:28
protoc-gen-zsharp example
syntax = "proto3";
import "event_plugin.proto";
package example;
message Foo {
option (com.zynga.runtime.protobuf.event_sourced) = true;
int32 foo_id = 1;
Bar bar = 2;
}
@joshgarnett
joshgarnett / example.cs
Last active February 5, 2018 22:41
Proposal for deltas of messages within a RepeatedField
var foo = new SimpleNestedMessage();
list.Add(foo);
// Generates: new EventData { Action = AddList, EventContent = foo.toByteString() , Path = [1, 0]} // 0 is the index of foo object
// Sets _root and _path in the foo instance
// if _root already exists throw exception, can't add message to two parents at once
foo.a = 10;
// Generates: new EventData { Action = Set, EventContent = 10 , Path = [1, 0, 1]}
foo.b = "hello";
// Generates: new EventData { Action = Set, EventContent = "hello" , Path = [1, 0, 2]}
@joshgarnett
joshgarnett / EventDataConverter.cs
Last active February 4, 2018 02:23
zsharp list support
using Zynga.Protobuf.Runtime.EventSource;
namespace Zynga.Protobuf.Runtime {
public abstract class EventDataConverter<T> {
/// <summary>
/// Returns EventContent for the specified data
/// </summary>
public abstract EventContent GetEventData(T data);
/// <summary>
@joshgarnett
joshgarnett / AkkaTaskExtensions.cs
Created September 19, 2017 14:55
Adding support for piping task result to actor as a single message
public class TaskResult<T> {
public bool IsFailed { get; }
public T Result { get; }
public Exception Exception { get; }
public TaskResult(bool isFailed, T result, Exception ex) {
IsFailed = isFailed;
Result = result;
Exception = ex;
}
@joshgarnett
joshgarnett / akka.conf
Created August 28, 2017 15:12
Log output for log-config-on-start in JVM Akka
10:55:21.045 [Test-akka.actor.default-dispatcher-4] INFO akka.actor.ActorSystemImpl - {
# merge of String: 2,application.conf @ file:/Users/jgarnett/Development/project/server/project/target/scala-2.11/classes/application.conf: 1-406,reference.conf @ jar:file:/Users/jgarnett/.ivy2/cache/com.typesafe.akka/akka-testkit_2.11/jars/akka-testkit_2.11-2.4.17.jar!/reference.conf: 8,reference.conf @ jar:file:/Users/jgarnett/.ivy2/cache/com.typesafe.akka/akka-stream_2.11/jars/akka-stream_2.11-2.4.17.jar!/reference.conf: 5,reference.conf @ jar:file:/Users/jgarnett/.ivy2/cache/com.typesafe.akka/akka-remote_2.11/jars/akka-remote_2.11-2.4.17.jar!/reference.conf: 15-689,reference.conf @ jar:file:/Users/jgarnett/.ivy2/cache/com.typesafe.akka/akka-persistence_2.11/jars/akka-persistence_2.11-2.4.17.jar!/reference.conf: 12-283,reference.conf @ jar:file:/Users/jgarnett/.ivy2/cache/com.typesafe.akka/akka-persistence-query-experimental_2.11/jars/akka-persistence-query-experimental_2.11-2.4.17.jar!/reference.conf: 10,reference.
@joshgarnett
joshgarnett / terraform_helper.rb
Created July 7, 2016 18:57
Ruby helper class for working with terraform
require 'json'
require 'logger'
# Helper class for interacting with Terraform
class TerraformHelper
def initialize(s3_bucket)
@logger = Logger.new(STDOUT)
@logger.level = Logger::DEBUG
@logger.formatter = proc do |severity, datetime, _progname, msg|
format("%-5s [%s] - %s\n", severity, datetime.strftime('%F %T,%L'), msg)
yum_repository 'mono' do
description 'Mono repository'
baseurl node['mono']['yum_repository']
gpgkey node['mono']['yum_repository_key']
end
# yum install does not play well with older versions of the mono-complete package. It marks many
# packages as obsolete and then tries to upgrade everything to version 4. To work around this we
# will download the rpms manually and then use yum localinstall.

Keybase proof

I hereby claim:

  • I am joshgarnett on github.
  • I am nylan (https://keybase.io/nylan) on keybase.
  • I have a public key whose fingerprint is B57A BE08 8C77 4585 6177 8600 8310 91A8 27D6 1CBD

To claim this, I am signing this object: