Skip to content

Instantly share code, notes, and snippets.

View maplebed's full-sized avatar

Ben Hartshorne maplebed

View GitHub Profile
@maplebed
maplebed / chef_download_checksum.rb
Created November 18, 2016 06:38
Chef recipe snippet to verify the checksum on a downloaded binary before using it
# download the binary 'foo' at a specific version to a local file that includes
# the version number. The effect of this is that by changing the version number
# you get a new copy of the file, and you don't need to check the remote URL to
# determine if you have the right version
remote_file "/usr/local/bin/foo-#{node['foo']['download']['version']}" do
source "#{node['foo']['download']['URL']}/#{node['foo']['download']['version']}"
owner 'ubuntu'
group 'ubuntu'
mode '0755'
action :create
@maplebed
maplebed / split_logstash.conf
Created November 1, 2016 03:35
Logstash config that sends sampled traffic to Honeycomb and all traffic to stdout
input { stdin { } }
filter {
grok {
match => ["message", "%{HAPROXYHTTP}"]
remove_field => ["message"]
}
mutate {
convert => { "actconn" => "integer"
"backend_queue" => "integer"
"beconn" => "integer"
@maplebed
maplebed / honeytail.rb
Created October 19, 2016 17:44
Chef config snippet for installing honeytail
# write the binary to the datestamped location so the not_if works
# to prevent re-downloading the bin every chef run
remote_file "/srv/infra/bin/#{node['honeytail']['version']}" do
source "#{node['honeytail']['URL']}"
owner 'ubuntu'
group 'ubuntu'
mode '0755'
action :create
not_if do
File.exist?("/srv/infra/bin/#{node['honeytail']['version']}")
@maplebed
maplebed / tailrdslog.go
Last active October 10, 2016 16:36
Experimenting trying to tail the mysql slow query log from a database in Amazon RDS
package main
import (
"fmt"
"log"
"strconv"
"strings"
"time"
"github.com/aws/aws-sdk-go/aws"
@maplebed
maplebed / goflags_ini.go
Created September 26, 2016 19:06
Sample code testing use of an ini file with go-flags - config file is string
package main
import (
"fmt"
flag "github.com/jessevdk/go-flags"
)
type Opts struct {
TestFlag string `short:"t" description:"just here to aid in testing ini files and defaults" default:"default"`
@maplebed
maplebed / goflags_ini.go
Created September 26, 2016 18:54
Sample code testing use of an ini file with go-flags - config file is a callback
package main
import (
"fmt"
flag "github.com/jessevdk/go-flags"
)
type Opts struct {
TestFlag string `short:"t" description:"just here to aid in testing ini files and defaults" default:"default"`
Using terraform v0.6.12
Steps to reproduce:
1) create a module in your local filesystem, use that module from within the root module
eg: module "foo" { source = "./foomod" }
2) run terraform get -update
3) confirm the cached module is a symlink: ls -l .terraform/modules/ should have a file that links to ./foomod
4) change the root module's invocation to point at a github repo instead (doesn't matter which one but it must exist)
eg module "foo" { source = "github.com/terraform-community-modules/tf_aws_sg" }
5) run terraform get -update
<!-- Keyboard Layout Switching with F-keys -->
<item>
<name>F7 Qwerty to Dvorak</name>
<identifier>private.f7_qwerty_to_dvorak</identifier>
<autogen>__KeyToKey__
KeyCode::F7,
KeyCode::VK_OPEN_URL_APP_Karabiner_Profile0
</autogen>
</item>
<item>
<!-- Keyboard Layout Switching with F-keys -->
<item>
<name>F7 Qwerty to Dvorak</name>
<identifier>private.f7_qwerty_to_dvorak</identifier>
<autogen>__KeyToKey__
KeyCode::F7,
KeyCode::VK_OPEN_URL_APP_Karabiner_Profile0
</autogen>
</item>
<item>
<!-- Keyboard Layout Switching -->
<item>
<name>Switch to Dvorak</name>
<identifier>private.qwerty_to_dvorak</identifier>
<autogen>
__SimultaneousKeyPresses__
<!-- from -->
@begin
KeyCode::A, KeyCode::S, KeyCode::D, KeyCode::F,
@end