Skip to content

Instantly share code, notes, and snippets.

View kerinin's full-sized avatar

Ryan Michael kerinin

View GitHub Profile
def let_once(method, &block)
before(:all) do
@let_once ||= {}
@let_once[method] = block.call
end
let(method) do
@let_once[method]
end
end
@kerinin
kerinin / backend.md
Last active August 29, 2015 14:08
Parfait Backend API

Parfait API

Start scanning a new account

This assumes the account has already been connected to Context.IO. See http://context.io/docs/lite/users/email_accounts for the field definitions of :id and :label

POST /users/:id/email_accounts/:label

  • 200 - Account added and being scanned
@kerinin
kerinin / foo.rs
Created October 8, 2014 21:02
Traits
pub trait Fooable {
pub fn foo();
}
pub impl Fooable for String {
pub fn foo() {
println!("Hello world");
}
}
@kerinin
kerinin / Gemfile
Last active August 29, 2015 14:07
CIO Ruby Lite
gem 'faraday'
gem 'faraday_middleware'
-- This will need to be built and put on the machine you're running Hive from
add jar json-serde-1.1.9.3-SNAPSHOT-jar-with-dependencies.jar;
-- Creates the table based on the JSON schema
CREATE TABLE json_nested_test (
metadata struct<uuid:string,md5_email:string,received_at:string,message_id:string,from_domain:string,message_signature:string,provider:string>,
headers map<string,struct<length:string,match_counts:map<string,string>,text_hash_counts:array<array<string>>,address_hashes:array<string>>>,
parts array<struct<mime_type:string,length:string,stripped_length:string,match_counts:map<string,string>,urls:array<struct<domain:string,sha:string>>,images:array<struct<domain:string,sha:string,pixel_count:string>>,text_hash_counts:array<array<string>>>>,
attachments array<struct<mime_type:string,bytesize:string,filename_sha:string,filetype:string>>
)
@kerinin
kerinin / thoughts.md
Last active October 20, 2015 08:19
Cluster Management

Cluster Management

Problem Statement

Distributed computing environments face two significant problems

  • Computing resources need to be assigned to computing tasks in a coordinated way (ie, if I have two computers and two tasks, I don't want both of the computers trying to do the same task)
  • Process failure needs to be detected and responded to (ie if I run out of disk space, another process should take over my task)

An ideal solution would satisfy a couple objectives

@kerinin
kerinin / api.rb
Created April 28, 2014 18:20
The API I want Assembler to provide
# This is for building a JSON request to the monitoring service
MonitorClient.group(name: 'my group') do |g|
g.add_watch(name: 'Something fragile') do |w|
w.description = 'information about watch'
w.docs = 'http://triage.com'
w.owners = ['ryan@example.com']
w.metric = MonitorClient::Metric::Graphite.new(target: 'foo.bar.baz')
w.policy = never_be_zero
w.add_action MonitorClient::Action::Email.new
# Basics - if you define an enumerable, you can evaluate it lazily
class Foo
include Enumerable
def each(&block)
(1..20).to_a.each do |i|
yield i
puts "yielded #{i}"
end
end
end
def subnet_ids
# TODO: Changed `availability_zones` key to `subnets` for backwards compatibility.
# Need to change it back here and in the config after all components and stacks
# are ready.
availability_zones.map do |az|
subnet_id(az)
end.compact
end
@kerinin
kerinin / ResponseObject.rb
Last active December 25, 2015 23:19
Shower-thoughts on response objects
class ResponseObject
def initialize
@handlers = Hash.new { [] }
yield self
end
def do(state, *args)
@state = state
@args = args
end