Skip to content

Instantly share code, notes, and snippets.

View travisjeffery's full-sized avatar

Travis Jeffery travisjeffery

View GitHub Profile
// error.go
// Copyright 2016 The Upspin Authors. All rights reserved.
// populateStack uses the runtime to populate the Error's stack struct with
// information about the current stack.
func (e *Error) populateStack() {
e.Stack = &Stack{Callers: callers()}
}
provider "datadog" {
api_key = "${var.datadog_api_key}"
app_key = "${var.datadog_app_key}"
}
# Monitor for the the disk usage.
resource "datadog_monitor" "disk_usage" {
name = "Disk usage high"
query = "avg(last_5m):${var.disk_usage["query"]}{*} by ${var.trigger_by} * 100 > ${var.disk_usage["threshold"]}"
type = "metric alert"
resource "aws_security_group" "example-service-balancer" {
 name = "example-service-balancer"
 description = "Allows traffic from the VPC"
 vpc_id = "${module.vpc.vpc_id}"
 ingress {
   from_port = 80
   to_port   = 80
   protocol  = "tcp"
   cidr_blocks = ["10.0.0.0/8"]
@travisjeffery
travisjeffery / functional-options.md
Last active April 23, 2023 11:13
How to do functional options in Golang

Here's the simplest example showing how to do functional options in Golang.

They're a great way to enable users to set options and ease adding new options later.

package main

import (
	"flag"
	"fmt"
@travisjeffery
travisjeffery / influxdb-setup.md
Last active March 17, 2024 15:38
Guide to setting up InfluxData's TICK stack

Guide to setting up InfluxData's TICK stack

InfluxData's T.I.C.K. stack is made up from the following components:

Component Role
Telegraf Data collector
InfluxDB Stores data
Chronograf Visualizer
@travisjeffery
travisjeffery / account_controller_case.ex
Last active December 10, 2016 01:52
Example of using Elixir's pattern matching to simplify and clean up some code
defmodule Stash.AccountController do
use Stash.Web, :controller
def create(conn, %{"accounts" => accounts}) do
case Aggregation.add_all_accounts([
institution_id: accounts["institution_id"],
customer_id: customer_id(conn.assigns.current_user),
credentials: accounts["credentials"]
]) do
{:mfa, %{"questions" => questions, "mfa_session" => mfa_session}} ->
host=$1
echo "finding host for container: $1"
function ec2-ip () {
aws ec2 describe-instances --filter Name=instance-id,Values=$1 | jq '.Reservations[0].Instances[0].PrivateIpAddress' | tr -d '"'
}
instances=$(aws ecs list-container-instances --cluster api --max-items 100 | jq '.containerInstanceArns | .[]' | tr -d '"')
ids=$(echo $instances | xargs aws ecs describe-container-instances --cluster api --container-instances | jq '.containerInstances | .[] | .ec2InstanceId' | tr -d '""')

Keybase proof

I hereby claim:

  • I am travisjeffery on github.
  • I am travisjeffery (https://keybase.io/travisjeffery) on keybase.
  • I have a public key whose fingerprint is D0DD A180 54AA 39AD 4232 F0D5 F675 ACE4 3270 A147

To claim this, I am signing this object:

#!/usr/bin/env sh
dir="$1"
echo_url_for_description() {
local test_description="$1"
local param="$(echo $test_description | sed -e 's//g' | sed -e 's/[^a-zA-Z0-9]/-/g' | tr '[:upper:]' '[:lower:]')"
echo "https://github.com/travisjeffery/tron/wiki/Defaults-Checklist#$param"
}
{
"~f"="moveWordForward:";
"~b"="moveWordBackward:";
"~<"="moveToBeginningOfDocument:";
"~>"="moveToEndOfDocument:";
"^n"="moveDown:";
"^p"="moveUp:";
"~v"="pageUp:";
"^v"="pageDown:";
"~d"="deleteWordForward:";