Skip to content

Instantly share code, notes, and snippets.

View milescrabill's full-sized avatar
🔑

Miles Crabill milescrabill

🔑
View GitHub Profile
@milescrabill
milescrabill / instance.sh
Created October 16, 2020 00:45
find ec2 instances by Name tag, autoscaling group name, and apply jq filters
# get matching ec2 instances (matches name, asg name)
function instance() {
instance_name="${1:-no-instance-name-provided}"
name_tag_instances=$(aws ec2 describe-instances --filter "Name=tag:Name,Values=*$instance_name*" | jq "[.Reservations[].Instances] | add // []")
asg_tag_instances=$(aws ec2 describe-instances --filter "Name=tag:aws:autoscaling:groupName,Values=*$instance_name*" | jq "[.Reservations[].Instances] | add // []")
all_instances=$(echo "$name_tag_instances" | jq ". + $asg_tag_instances | unique // []")
if [[ "$2" != "" ]]; then
out=$(echo "$all_instances" | jq -r ".[] | $2")
else
out=$(echo "$all_instances" | jq -r ".")
@milescrabill
milescrabill / aws-sso-creds.py
Last active September 30, 2020 16:26
updates your ~/.aws/credentials file with sso creds
#!/usr/bin/env python3
from configparser import ConfigParser
from collections import namedtuple
from datetime import datetime, timezone
from pathlib import Path
import argparse
import re
import os
import json
# steps for getting cloudhsm going
# this method volume mounts the cloudhsm libs into the container from the host
# based on debian stretch
# docker run --rm -it -u 0 -v /opt/cloudhsm:/opt/cloudhsm golang:1.10 /bin/bash
# rest of steps are inside container
# you can throw it all in a text file in the container
# steps for getting softhsm going
# based on debian stretch
# docker run -it golang:1.10 /bin/bash
# rest of steps are inside container
# you can throw it all in a text file in the container
# like so: cat <<'eof'>test.sh
# bash test.sh
# steps for getting cloudhsm going
# based on debian stretch
# docker run -it golang:1.10 /bin/bash
# rest of steps are inside container
# you can throw it all in a text file in the container
# like so: cat <<'eof'>test.sh
# bash test.sh
@milescrabill
milescrabill / create_and_reindex.sh
Last active July 5, 2017 21:40
Creates indices socorro2017[02-27] and starts reindexing tasks in the background
#!/bin/bash
for i in $(seq -w 2 27); do
# curl -XDELETE "localhost:9200/socorro2017{$i}"
curl -XPUT "localhost:9200/socorro2017${i}" -H 'Content-Type: application/json' -d @create-socorro-index.json
curl -XPOST 'localhost:9200/_reindex?pretty&wait_for_completion=false' -H 'Content-Type: application/json' -d "
{
\"source\": {
\"remote\": {
\"host\": \"https://socorro-es-external.mocotoolsstaging.net:9200\"
},
@milescrabill
milescrabill / create-socorro-index.json
Created July 5, 2017 19:38
Socorro index creation for reindex-from-remote. Note that # of replicas and refresh interval should be changed upon the completion of the reindex operation.
{
"mappings": {
"crash_reports": {
"_all": {
"enabled": false
},
"properties": {
"raw_crash": {
"dynamic": "true",
"type": "object",
#include <NewPing.h>
#include <Stepper.h>
// ultrasonic sensor
#define TRIGGER_PIN 13 // Arduino pin tied to trigger pin on the ultrasonic sensor.
#define ECHO_PIN 12 // Arduino pin tied to echo pin on the ultrasonic sensor.
#define MAX_DISTANCE 200 // Maximum distance we want to ping for (in centimeters). Maximum sensor distance is rated at 400-500cm.
// stepper motor
#define DIRECTION_PIN 2 // Arduino pin for the direction pin on the stepper motor
@milescrabill
milescrabill / default.rb
Created February 23, 2014 21:02
scapy cookbook
package "python-crypto"
package "python-pyx"
package "tcpdump"
# python_virtualenv "/home/ubuntu/ve" do
# interpreter "python2.5"
# owner "ubuntu"
# group "ubuntu"
# action :create
# end