Skip to content

Instantly share code, notes, and snippets.

View rhenning's full-sized avatar
👻

Richard Henning rhenning

👻
View GitHub Profile
@rhenning
rhenning / tf_aws_sg_name_timeoutt.txt
Created March 2, 2016 14:58
tf_aws_sg_name_timeout
→ time TF_VAR_client_id=rhenning TF_VAR_env=dev TF_VAR_stack_name=rhenning-dev-20160227 TF_VAR_openvpn_pubhost=vpn.dev.rhenning.weblinc.com terraform plan
Refreshing Terraform state prior to plan...
aws_s3_bucket.integration: Refreshing state... (ID: rhenning-dev-20160227-integration)
aws_iam_role.util: Refreshing state... (ID: rhenning-dev-20160227-util)
aws_eip.nat: Refreshing state... (ID: eipalloc-e8aca58c)
aws_iam_user.resources: Refreshing state... (ID: rhenning-dev-20160227-resources)
aws_iam_user.ses: Refreshing state... (ID: rhenning-dev-20160227-ses)
aws_s3_bucket.elblogs: Refreshing state... (ID: rhenning-dev-20160227-elblogs)
aws_iam_role.es: Refreshing state... (ID: rhenning-dev-20160227-es)
@rhenning
rhenning / csr2crt.sh
Last active October 14, 2015 15:13
Quick CSR to Certificate with fake CA
#!/usr/bin/env bash
set -e
if [[ "$#" != "1" ]]; then
echo usage: $0 /path/to/file.csr
exit 1
fi
invoke_dir=$(pwd)
@rhenning
rhenning / pg.sh
Last active January 28, 2017 10:01
Parallel SSH via OpenVPN gateway
#!/bin/bash
gw=$1
hosts=$2
shift 2
pssh --option ForwardAgent=yes --option StrictHostKeyChecking=no --option ProxyCommand="ssh -qW %h:%p -o StrictHostKeyChecking=no openvpnas@${gw}" --user ubuntu --hosts $hosts --print $*
@rhenning
rhenning / sg.sh
Last active February 11, 2016 20:33
SSH via OpenVPN gateway
#!/bin/bash
gw=$1
target=$2
shift 2
ssh -o StrictHostKeyChecking=no -o ProxyCommand="ssh -o StrictHostKeyChecking=no -W %h:%p openvpnas@${gw}" $target -l ubuntu $*
@rhenning
rhenning / gist:b54f12514ca4bbabf65a
Created July 22, 2015 17:44
Mongo embedded array push test
require 'moped'
require 'benchmark'
s = Moped::Session.new(%w(127.0.0.1:27017))
s.use 'junkdb'
s.drop
s[:test].insert(foo: [])
Benchmark.bm do |b|
@rhenning
rhenning / passpack2onepassword.rb
Created July 8, 2015 17:36
Passpack to 1Password CSV converter
require 'csv'
# PASSPACK_CSV_FIELDS = %i[
# title
# username
# password
# url
# tags
# notes
# email

Keybase proof

I hereby claim:

  • I am rhenning on github.
  • I am rhenning (https://keybase.io/rhenning) on keybase.
  • I have a public key whose fingerprint is 71FE AC16 2CFD 4F14 4779 4541 5326 CF40 1F9E 17BB

To claim this, I am signing this object:

#!/usr/bin/env bash
awk '/proftp.*successful/ { print $7 }' /var/log/secure{,.?} \
| cut -f1 -d\[ \
| tr -d '(' \
| sort \
| uniq \
| while read ip ; do
echo flushing $ip from banlist...
for chain in fail2ban-{,REPEAT-}SFTP ; do
@rhenning
rhenning / gist:899c77ba618752fd43c6
Last active August 29, 2015 14:09
Mongo Date ObjectId helpers
var daysAgo = 10;
Date.prototype.toObjectId = function() {
var dateSecs = Math.floor(this.getTime() / 1000);
return ObjectId(dateSecs.toString(16) + "0000000000000000");
}
function daysAgoToDate(daysAgo) {
return new Date(new Date().setDate(new Date().getDate() - daysAgo));
}
@rhenning
rhenning / entity_users.js
Last active August 29, 2015 14:07
Mongo aggregations and date to ObjectId
// run like: nohup mongo --quiet neat_prod > entity_users.js
days_ago = 120
date_after = new Date(new Date().setDate(new Date().getDate() - days_ago))
secs_after = Math.floor(date_after.getTime() / 1000)
oid_after = ObjectId(secs_after.toString(16) + "0000000000000000")
rs.slaveOk()
c = db.entities.find(