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"| // 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"] |
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"| 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 '""') |
I hereby claim:
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:"; |