Skip to content

Instantly share code, notes, and snippets.

View robbwagoner's full-sized avatar

Robb Wagoner robbwagoner

View GitHub Profile
@robbwagoner
robbwagoner / ~tmux.conf
Created July 5, 2019 21:58
Revert CTRL+B as the TMUX Prefix
set-option -g prefix C-b
@robbwagoner
robbwagoner / fix.sh
Created July 23, 2018 19:49
Git unable to update local ref error
# https://stackoverflow.com/questions/2998832/git-pull-fails-unable-to-resolve-reference-unable-to-update-local-ref
git gc --prune=now
git remote prune origin
@robbwagoner
robbwagoner / awscli-pex.md
Last active June 8, 2021 12:49
AWS CLI with PEX

What is PEX?

build with Docker image... e.g. Ubuntu 14.04

$ docker run --rm -it -v $PWD:/src -w /src ubuntu:14.04

Install PEX

@robbwagoner
robbwagoner / enabling-aac-and-aptx-over-bluetooth-on-macos.md
Created March 8, 2018 14:37
Enabling AptX over Bluetooth on macOS
@robbwagoner
robbwagoner / prune-elasticsearch-filebeat.sh
Last active September 13, 2017 15:38
Prune Elasticsearch indexes N days old - use cron.daily to execute once a day to keep only 90 days of indexes on Elasticsearch
#!/usr/bin/env bash
#
# Delete indexes from N days ago
#
for arg in ${@} ; do case $arg in (-h|-\?) echo "USAGE: [INDEX_PREFIX=[filebeat]] $BASH_SOURCE [DAYS_AGO]" 1>&2 ; exit 255 ;; esac ; done
DAYS_AGO=${1:-90}
INDEX_PREFIX_DEFAULT="filebeat"
"""
Copy objects from one bucket/prefix to another bucket with the same prefix.
Used to allow CloudFront logs to get parsed for uploading to ES *AND* analyzed
by WAF.
CloudFront Distribution logs -> s3://es-bucket/incoming -> Lambda (this) -> s3://waf-bucket/
Set environment variable `destination_bucket`
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --name SSH_RATE_LIMIT --set
iptables -I INPUT -p tcp --dport 22 -i eth0 -m state --state NEW -m recent --name SSH_RATE_LIMIT --update --seconds 60 --hitcount 4 -j DROP
@robbwagoner
robbwagoner / s3-to-es-lamba.py
Created January 9, 2017 15:49 — forked from s-fujimoto/s3-to-es-lamba.py
Import Elasticsearch from ELB access log for AWS Lambda Function
##################################################
### Elasticsearch host name
ES_HOST = "search-******************.ap-northeast-1.es.amazonaws.com"
### Elasticsearch prefix for index name
INDEX_PREFIX = "awslogs"
#################################################
### ELB access log format keys
ELB_KEYS = ["timestamp", "elb", "client_ip", "client_port", "backend_ip", "backend_port", "request_processing_time", "backend_processing_time", "response_processing_time", "elb_status_code", "backend_status_code", "received_bytes", "sent_bytes", "request_method", "request_url", "request_version", "user_agent"]
@robbwagoner
robbwagoner / curlit.sh
Last active December 13, 2019 12:09
Measure Latency With Curl
#!/usr/bin/env bash
#
# curl wrapper returning timing information.
#
# ORIGIN: https://github.com/mat/dotfiles/blob/master/bin/curlt
#
# curl format adapted from
# http://josephscott.org/archives/2011/10/timing-details-with-curl/
#
# Example usage:
@robbwagoner
robbwagoner / nvm-install.sh
Created September 15, 2016 16:45
NVM Bootstrap for OSX and Ubuntu Linux
#!/usr/bin/env bash
#
# https://github.com/creationix/nvm
#
DIR="$(cd $(dirname $0) ; pwd)"
# Error codes
ERROR_NVM_INSTALL_SHA=2
# Installer script from NVM repo