Skip to content

Instantly share code, notes, and snippets.

View owning-account-assume-role.tf
# this defines a role "role-name" in the account where this TF will be applied
resource "aws_iam_role" "role_name" {
name = "role-name"
description = "Allows role-name to do things in account"
assume_role_policy = "${data.aws_iam_policy_document.my_role.json}"
}
# this says that any one in a separate account with ID 123456789012 can assume the "role-name" role
data "aws_iam_policy_document" "role_name" {
statement {
@eculver
eculver / batch.go
Created May 31, 2019
Divide slice into batches
View batch.go
// run at: https://play.golang.org/p/bhgYlgGbdHz
package main
import (
"fmt"
)
func main() {
total := 22
batch := 3
@eculver
eculver / Makefile
Created Nov 21, 2018
Makefile capture
View Makefile
foo := a.o b.o c.o
bar := $(foo:%.o=%)
.PHONY: test
test:
echo $(bar)
@eculver
eculver / regex-utils.go
Last active Oct 11, 2018
Find all named match groups and return as a map keyed by the group name
View regex-utils.go
// FindAllGroups returns a map with each match group. The map key corresponds to the match group name.
// A nil return value indicates no matches.
func FindAllGroups(re *regexp.Regexp, s string) map[string]string {
matches := re.FindStringSubmatch(s)
subnames := re.SubexpNames()
if matches == nil || len(matches) != len(subnames) {
return nil
}
matchMap := map[string]string{}
@eculver
eculver / manr.sh
Created May 14, 2017
Learn something new!
View manr.sh
#!/bin/bash
ls /usr/share/man/man* | cut -d '.' -f1 | sort -u | shuf -n1 | xargs man
@eculver
eculver / protocol-fix.txt
Created Mar 16, 2015
How to deal with tmux "protocol version mismatch"
View protocol-fix.txt
$ tmux attach
protocol version mismatch (client 7, server 6)
$ pgrep tmux
3429
$ /proc/3429/exe attach
@eculver
eculver / custom-naming
Created Sep 2, 2014
Sickbeard Custom Naming Pattern
View custom-naming
%SN/S%0S/%S.N-S%0SE%0E-%E.N
Sample:
Show Name/S02/Show.Name-S02E03-Ep.Name.ext
View keybase.md

Keybase proof

I hereby claim:

  • I am eculver on github.
  • I am eculver (https://keybase.io/eculver) on keybase.
  • I have a public key whose fingerprint is 0A08 44A8 D6ED CCDD 4929 9BCD B530 10D9 1726 B005

To claim this, I am signing this object:

@eculver
eculver / command_t.sh
Last active Aug 29, 2015
Shell Notes: Install Command-T
View command_t.sh
# in .vimrc install w/ Vundle/Pathogen/etc
# Bundle "command-t"
# build the extension
cd ~/.vimrc/bundle/command-t/ruby/command-t
ruby extconf.rb
make
# restart vim
View eeek.php
if ($parentId) {
$parentCondition = "node-closure.ancestor = $parentId";
$parentCondition = "node-closure.depth = 1";
} else if ($rootId) {
$parentCondition = "node-closure.ancestor = $rootId";
}
$clientCondition = "node.clientId = $clientId";
$assetCrit->addExpr('where', $parentCondition)