Skip to content

Instantly share code, notes, and snippets.

@jhmartin
jhmartin / gist:481c713435985aa473f595cf1db40e09
Last active August 7, 2019 15:14
Generate Cloudformation command from stack
aws cloudformation describe-stacks --stack-name STACKNAMEHERE --output=text|grep -i PARAMETERS | awk '{print "ParameterKey=" $2 ",ParameterValue=" $3 " \\"}'
@jhmartin
jhmartin / createpoints.rb
Last active August 19, 2018 21:37
DNS LB Test compose
#!/usr/bin/env ruby
# Input is an ip address. Map it to a position in a list.
positioncount=0
linecount=0
indexes=Hash.new
STDIN.read.split("\n").each do |a|
a=a.chomp
if (! indexes.has_key?(a))
@jhmartin
jhmartin / davincisrt.pl
Created July 18, 2018 19:27
Davinci Resolve Close-Captions SRT to Youtube SRT converter
#!/usr/bin/perl -w
use strict;
while (<STDIN>) {
chomp;
if (/^\s*$/) {
next;
}
if (/^\d+$/) {
@jhmartin
jhmartin / gist:d3f72246881a07c3d7efe0e14e8fd3c0
Last active July 5, 2018 20:23
Pull recent CW stats for pasting
#!/bin/sh
# Fetch 2-3 minutes in the past as current data isnt there yet
NOWDATE=$(date -v-2M -u +"%Y-%m-%dT%H:%M:%SZ")
LASTDATE=$(date -v-3M -u +"%Y-%m-%dT%H:%M:%SZ")
date
#-start-time 2014-04-08T23:18:00Z --end-time 2014-04-09T23:18:00Z --period 3600 --namespace AWS/EC2 --statistics Maximum --dimensions Name=InstanceId,Value=i-abcdef
export AWS_PROFILE=jmtdlcw
UTILSLATENCY=$(aws cloudwatch get-metric-statistics --start-time $LASTDATE --end-time $NOWDATE --metric-name Latency --period 60 --namespace AWS/ELB --statistic Average --dimensions Name=LoadBalancerName,Value=abc-prod-utilsapi|jq .Datapoints[0].Average)
input {
lumberjack {
port => 5043
type => "squid"
ssl_certificate => "/home/ec2-user/logstash-forwarder/logstash-forwarder.crt"
ssl_key => "/home/ec2-user/logstash-forwarder/logstash-forwarder.key"
}
udp {
@jhmartin
jhmartin / nod10.xml
Created November 20, 2017 00:59
Zooz ZSE40 Openhab XML
<node>
<deviceClass>
<basicDeviceClass>ROUTING_SLAVE</basicDeviceClass>
<genericDeviceClass>SENSOR_NOTIFICATION</genericDeviceClass>
<specificDeviceClass>NOTIFICATION_SENSOR</specificDeviceClass>
</deviceClass>
<homeId>0xd91cc41a</homeId>
<nodeId>10</nodeId>
<version>4</version>
<manufacturer>0x27a</manufacturer>
@jhmartin
jhmartin / vault_intermediate_ca_setup.sh
Last active September 1, 2017 20:10 — forked from codekoala/vault_intermediate_ca_setup.sh
Setting Up Hashicorp Vault with an intermediate CA based on https://gist.github.com/jefferai/092d2cd728ff66089f17
#!/bin/bash -e
# Setup a Root CA in vault
# Generate and sign an Intermediate cert
#
# Requires:
# * A running vault server already initialzed and unsealed
# * Environment variable VAULT_TOKEN is set
# * vault cli (https://www.vaultproject.io)
# * httpie (https://github.com/jkbrzt/httpie)
@jhmartin
jhmartin / gist:c669c902c59d2dc33741d42b4e20fbf7
Created January 23, 2017 22:02
How to use cross-account roles in AWS RUby SDK
require 'aws-sdk'
role_credentials = Aws::AssumeRoleCredentials.new(
client: Aws::STS::Client.new(),
role_arn: "arn:aws:iam::123:role/cross-account-role",
role_session_name: ENV['USER'],
serial_number: "arn:aws:iam::123:mfa/usernamehere",
token_code: ARGV[0]
)
[Unit]
Description=Var Lib Expansion Mount
[Mount]
What=/dev/disk/by-label/DOCKER
Where=/var/lib/docker
[Install]
RequiredBy = local-fs.target
### Keybase proof
I hereby claim:
* I am jhmartin on github.
* I am toger (https://keybase.io/toger) on keybase.
* I have a public key whose fingerprint is C79F 0853 C15A C7E9 E798 C97E D81C 9326 A979 840A
To claim this, I am signing this object: