Skip to content

Instantly share code, notes, and snippets.

@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:
@jhmartin
jhmartin / gist:44dc673a3c57ffa8ede8388f0f9850dd
Created August 25, 2016 18:21
Docker Swarm Node Filter
To search the node api, filtering by role:manager
http://127.0.0.1:2375/nodes?filters=%7B%22role%22%3A%5B%22manager%22%5D%7D
Filters= is the URLEncoded version of {"role":["manager"]}
@jhmartin
jhmartin / cloudtrail.json
Last active May 4, 2016 04:14
CloudTrail
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {
"AWS::CloudFormation::Designer": {
"f700037a-b1cd-40cc-968f-c67ea5a2d96f": {
"size": {
"width": 60,
"height": 60
},
"position": {
@jhmartin
jhmartin / SSLPoke.java
Last active August 29, 2015 14:24 — forked from 4ndrej/SSLPoke.java
import javax.net.ssl.SSLSocket;
import javax.net.ssl.SSLSocketFactory;
import java.io.*;
/** Establish a SSL connection to a host and port, writes a byte and
* prints the response. See
* http://confluence.atlassian.com/display/JIRA/Connecting+to+SSL+services
*/
public class SSLPoke {
public static void main(String[] args) {
if (request.type == 'LAUNCH_REQUEST')
# Process your Launch Request
# Call your methods for your application here that process your Launch Request.
response.add_speech('House Control online')
response.add_hash_card( { :title => 'My House', :subtitle => 'House Control activated.' } )
end
if (request.type == 'INTENT_REQUEST')
# Process your Intent Request
p "#{request.slots['helper']['value']}"
@jhmartin
jhmartin / gist:cc5582ea767581eabfcf
Created June 1, 2015 22:42
Amazon Echo & Z-Way ZWave
// Based on https://github.com/noelportugal/AmazonEchoApi.git, watches for 'goodnight' and sets a Z-Way scene.
public static void main(String[] args) throws InterruptedException, IOException {
AmazonEchoApi amazonEchoApi = new AmazonEchoApi("https://pitangui.amazon.com","[email protected]", "SNIP");
if (amazonEchoApi.httpLogin()){
while (true) {
String output = amazonEchoApi.httpGet("/api/cards?type=TASK&size=1");
//String output = amazonEchoApi.httpGet("/api/cards?type=TASK&size=1");
//String output = amazonEchoApi.httpGet("/api/todos?type=TASK&size=1");
// Parse JSON
@jhmartin
jhmartin / gist:c09e450853e273ee88f2
Created May 21, 2015 15:47
Multiple Elasticsearch outputs in logstash
#http://pastebin.com/xGt6vv9R from yardenbar
output {
if [type] == "postfix" {
elasticsearch {
host => [ "ES_HOSTNAME" ]
protocol => "transport"
cluster => "elasticsearch"
index => "postfix-%{+YYYY.MM.dd}"
manage_template => true
template_overwrite => true