Skip to content

Instantly share code, notes, and snippets.

Avatar

Joshua Garnett joshgarnett

View GitHub Profile
@joshgarnett
joshgarnett / 1-test.proto
Last active Feb 23, 2018
protoc-gen-zsharp example
View 1-test.proto
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 Feb 5, 2018
Proposal for deltas of messages within a RepeatedField
View example.cs
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]}
View EventDataConverter.cs
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 Sep 19, 2017
Adding support for piping task result to actor as a single message
View AkkaTaskExtensions.cs
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 Aug 28, 2017
Log output for log-config-on-start in JVM Akka
View akka.conf
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 / main.tf
Created Nov 9, 2016
Minimal ECS Terraform Example
View main.tf
# 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 Mar 17, 2021
Ruby script to use as a hook for the letsencrypt.sh client
View lets-encrypt-route53.rb
#!/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 / terraform_helper.rb
Created Jul 7, 2016
Ruby helper class for working with terraform
View terraform_helper.rb
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)
View chef_mono_recipe
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.
View keybase.md

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: