Skip to content

Instantly share code, notes, and snippets.

View frodopwns's full-sized avatar
😅

Erin Corson frodopwns

😅
View GitHub Profile
package main
import (
"fmt"
"io/ioutil"
"log"
"golang.org/x/oauth2"
"golang.org/x/oauth2/google"
"google.golang.org/cloud"
cfg := api.DefaultConfig()
cfg.Address = "https://your_vault_addr:8200"
client, err := api.NewClient(cfg)
if err != nil {
fmt.Println(err)
}
inputs := map[string]string{
"mount": "github",
"token": "token",
}
#setup ~/.boto first
from boto.support.layer1 import SupportConnection
conn = SupportConnection()
checks = conn.describe_trusted_advisor_checks("en")
ids = [c['id'] for c in checks['checks']]
summaries = conn.describe_trusted_advisor_check_summaries(ids)
@frodopwns
frodopwns / dps.py
Created September 22, 2015 21:30
pretty print docker ps commands
import re
import json
import sys
import os
from subprocess import Popen, PIPE
if __name__ == '__main__':
base_path = os.path.abspath(os.path.dirname(__file__))
args = sys.argv
@frodopwns
frodopwns / ansiblehoster.yml
Created August 26, 2015 15:32
push hostnames to all ansible hosts
- hosts: all
sudo: yes
tasks:
- name: "Build hosts file"
lineinfile:
dest=/etc/hosts
regexp=".*{{ item }}$"
line="{{ hostvars[item].ansible_eth1.ipv4.address }} {{item}}"
state=present
when: hostvars[item].ansible_eth1.ipv4.address is defined
@frodopwns
frodopwns / partia.py
Created August 12, 2015 16:32
partial func example
>>> from urlparse import urljoin
>>> from functools import partial
>>> api_url = "http://my-eve-api.com/api/"
>>> endpointer = partial(urljoin, api_url)
>>> endpointer("sites")
'http://my-eve-api.com/api/sites'
>>> endpointer("contacts")
'http://my-eve-api.com/api/contacts'
@frodopwns
frodopwns / elasticagg.py
Last active August 29, 2015 14:18
elastic aggs
import elasticsearch
from pprint import pprint
es = elasticsearch.Elasticsearch()
query = {'size': 0, 'aggs': {'institutions': {'terms': {'field': 'institution', 'size': 10}}}}
res = es.search(index='courses', doc_type='class', body=query)
pprint(res['aggregations'])
@frodopwns
frodopwns / gist:9b65bd7c7610b9e82235
Created December 16, 2014 18:26
Grok Pattern for Drupal Syslog Messages
%{SYSLOGBASE} %{URI:base_url}\|%{INT:unix_timestamp}\|%{DATA:category}\|%{IP:ip}\|%{URI:request_url}\|(?:%{URI:referrer}|)\|%{INT:uid}\|(?:%{URI:link}|)\|%{GREEDYDATA:errmsg}
@frodopwns
frodopwns / resymlink.py
Last active August 29, 2015 14:06
re-symlink profiles
@frodopwns
frodopwns / fabfile.py
Created July 8, 2014 17:39
Deploy repos with nested submodules
from fabric.api import *
def deep_snd(path_to_repo):
if path_to_repo[0] != '/':
path_to_repo = local("readlink -f {}".format(path_to_repo), capture=True)
dirs = local("find {} -name .gitmodules".format(path_to_repo), capture=True)
dirs = [x.rstrip(".gitmodules") for x in dirs.split()]