Skip to content

Instantly share code, notes, and snippets.

@andromedarabbit
andromedarabbit / awslogin.sh
Last active August 2, 2018 08:56
awslogin.sh
#!/bin/bash -e
RED='\033[0;31m'
GREEN='\033[0;32m'
NC='\033[0m' # No Color
err_report() {
echo ""
echo -e "${RED}USAGE: $(basename $0)${NC}"
echo -e "${RED}USAGE: AWS_LOGIN_PROFILE=my-profile AWS_PROFILE=my-profile-mfa $(basename $0) 123456${NC}"
echo -e "${RED}See${NC} https://aws.amazon.com/premiumsupport/knowledge-center/authenticate-mfa-cli/"
@andromedarabbit
andromedarabbit / open-firewall-of-my-digitalocean-droplet.sh
Last active March 12, 2019 09:29
Add external IP address of my Mac/Linux to the inbound rules of my DigitalOcean server
# Prerequisites: `doctl`, `curl` and `jq`
# See https://www.digitalocean.com/community/tutorials/how-to-use-doctl-the-official-digitalocean-command-line-client
# In this particular case, we are going to open the port 22 for ssh connection.
MY_IP=$(curl --silent ifconfig.io/ip) && doctl compute firewall add-rules $(doctl compute firewall list --output=json | jq -r '.[].id') --inbound-rules "protocol:tcp,ports:22,address:${MY_IP}/32"

Article: http://mikegerwitz.com/papers/git-horror-story

Theory

  • faking other user's commits is easy with --author flag $ git commit --author='Foo Bar <foo@bar.com>' -m 'some commit'

  • signing commits ensures:

    • someone else can't commit as myself
  • I really commited all the commits I sign

@andromedarabbit
andromedarabbit / elastalert-rule.yaml
Created March 3, 2017 15:44
ElastAlert rule example
# Alert when the rate of events exceeds a threshold
# (Required)
# Rule name, must be unique
name: OutOfMemoryError
# (Required)
# Type of alert.
# the frequency rule type alerts when num_events events occur with timeframe time
type: frequency
@andromedarabbit
andromedarabbit / elasticsearch-x-pack-alerting-example.json
Created February 23, 2017 04:39
Elasticsearch X-Pack Alerting Example
PUT _xpack/watcher/watch/outofmemoryerror
{
"trigger" : {
"schedule" : { "cron" : "0 0/4 * * * ?" }
},
"input" : {
"search" : {
"request" : {
"indices" : [
"</logstash><logstash -{now-1h/d}t{now-1h{HH}}>",
@andromedarabbit
andromedarabbit / check-dd-agent.sh
Created February 2, 2017 04:54
Check if dd-agent is running well on Kubernetes
kubectl exec -it $(kubectl get pod -lapp=dd-agent | head -n 2 | tail -n 1 | cut -d ' ' -f1) -- /opt/datadog-agent/agent/agent.py info
@andromedarabbit
andromedarabbit / ngrinder-agents.yaml
Created December 25, 2016 05:30
Ngrinder agents for Kubernetes
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
 name: ngrinder-agent
spec:
 replicas: 5
 template:
 metadata:
 labels:
 app: ngrinder-agent
@andromedarabbit
andromedarabbit / ngrinder-controller.yaml
Created December 25, 2016 05:30
Ngrinder Controller for Kubnernetes
apiVersion: v1
kind: Service
metadata:
 name: ngrinder
 labels:
 app: ngrinder
 tier: middle
 dns: route53
 annotations:
 domainName: “ngrinder.test.com”
@andromedarabbit
andromedarabbit / artillery-config.yaml
Created December 25, 2016 05:23
Artillery configuration example
config:
target: 'http://my.app.dev'
phases:
- duration: 60
arrivalRate: 20
defaults:
headers:
x-my-service-auth: '987401838271002188298567'
scenarios:
@andromedarabbit
andromedarabbit / check_docker_container.sh
Created October 31, 2016 07:05 — forked from ekristen/check_docker_container.sh
Bash Script for Nagios to Check Status of Docker Container
#!/bin/bash
# Author: Erik Kristensen
# Email: erik@erikkristensen.com
# License: MIT
# Nagios Usage: check_nrpe!check_docker_container!_container_id_
# Usage: ./check_docker_container.sh _container_id_
#
# The script checks if a container is running.
# OK - running