Skip to content

Instantly share code, notes, and snippets.

@mlehner616
mlehner616 / cmd_line
Last active May 1, 2019 01:20
lifecycled-pprof-with-spot-listener-enabled
./lifecycled --cloudwatch-group=${LIFECYCLED_CLOUDWATCH_GROUP} --handler=${LIFECYCLED_HANDLER} --sns-topic=${LIFECYCLED_SNS_TOPIC} --json
@mlehner616
mlehner616 / redis_migrate.py
Created August 20, 2018 05:20 — forked from josegonzalez/redis_migrate.py
A simple script to migrate all keys from one Redis to another
#!/usr/bin/env python
import argparse
import redis
def connect_redis(conn_dict):
conn = redis.StrictRedis(host=conn_dict['host'],
port=conn_dict['port'],
db=conn_dict['db'])
return conn
# Usage:
# encrypt kms-key-id plaintext
function encrypt () {
key_id=$1
plaintext=$2
aws kms encrypt --key-id $key_id --plaintext fileb://<(echo $plaintext) --query CiphertextBlob --output text
}
# Usage:
# decrypt ciphertext
@mlehner616
mlehner616 / gist:98b6227a20e76aa6705ac8c24f954d62
Created July 15, 2017 05:33 — forked from hSATAC/gist:5343225
Http Redirect in Golang
package main
import (
"log"
"net/http"
)
func redirect(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "http://www.google.com", 301)
@mlehner616
mlehner616 / nomad.err
Last active July 10, 2017 19:06
nomad-0.6.0-rc1-crash-7-10-2017
panic: runtime error: slice bounds out of range
goroutine 29 [running]:
github.com/hashicorp/nomad/scheduler.(*allocReconciler).computeGroup(0xc42020e620, 0xc4206a1a40, 0x11, 0xc42026e930, 0xc42026e900)
/opt/gopath/src/github.com/hashicorp/nomad/scheduler/reconcile.go:393 +0x1592
github.com/hashicorp/nomad/scheduler.(*allocReconciler).Compute(0xc42020e620, 0xc42063d080)
/opt/gopath/src/github.com/hashicorp/nomad/scheduler/reconcile.go:182 +0x1f1
github.com/hashicorp/nomad/scheduler.(*GenericScheduler).computeJobAllocs(0xc420704fc0, 0xc4204b4a80, 0xc42063c940)
/opt/gopath/src/github.com/hashicorp/nomad/scheduler/generic_sched.go:391 +0x3cc
github.com/hashicorp/nomad/scheduler.(*GenericScheduler).process(0xc420704fc0, 0x24, 0x24, 0xc4210cf7b0)
### Keybase proof
I hereby claim:
* I am mlehner616 on github.
* I am mlehner616 (https://keybase.io/mlehner616) on keybase.
* I have a public key ASDeVJfhkM4vdJDSYzrqofTQRR_i24nSZmVnSgGkriHK7go
To claim this, I am signing this object:
@mlehner616
mlehner616 / aws-asg-suspend
Last active November 5, 2015 00:08
zpress-ASG-suspend
# aws autoscaling suspend-processes --auto-scaling-group-name zpress-app-v004 --scaling-processes AlarmNotification
# aws autoscaling resume-processes --auto-scaling-group-name zpress-app-v004 --scaling-processes AlarmNotification
#!/bin/bash -e
#
# Pass this script an AWS access key ID and it will show you what IAM user
# has that key.
#
# Usage:
# aws-access-key-to-iam-name some_key_id
#
readonly PROGNAME=$(basename $0)
require 'facter'
require 'json'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --region #{region} --filters \"Name=resource-id,Values=#{instance_id}\" --query 'Tags[*].{value:Value,key:Key}'")
parsed_tags = JSON.parse(tags)
parsed_tags.each do |tag|
require 'facter'
require 'json'
if Facter.value("ec2_instance_id") != nil
instance_id = Facter.value("ec2_instance_id")
region = Facter.value("ec2_placement_availability_zone")[0..-2]
tags = Facter::Util::Resolution.exec("aws ec2 describe-tags --region #{region} --filters \"Name=resource-id,Values=#{instance_id}\" --query 'Tags[*].{value:Value,key:Key}'")
parsed_tags = JSON.parse(tags)
parsed_tags.each do |tag|