Skip to content

Instantly share code, notes, and snippets.

View djosephsen's full-sized avatar

Dave Josephsen djosephsen

View GitHub Profile
@djosephsen
djosephsen / gist:1d526a850debb604600b045b6880d7fb
Created August 22, 2019 20:36
A stupid little cli-thesaurus
#!/usr/bin/env python
import sys
import requests
from termcolor import colored
# get an api key from https://dictionaryapi.com/register/index
APIKEY = '<your api key here>'
URL = 'https://www.dictionaryapi.com/api/v3/references/thesaurus/json/'
word = sys.argv[1]

Keybase proof

I hereby claim:

  • I am djosephsen on github.
  • I am djosephsen (https://keybase.io/djosephsen) on keybase.
  • I have a public key ASCwtAF8cbR98l0U5uP1v4G2XYN7Y-e_okok55Za1f-98wo

To claim this, I am signing this object:

@djosephsen
djosephsen / s3-vdelete
Created December 7, 2018 23:39
Delete all previous versions of an object on S3 except the most recent
#!/usr/bin/env bash
BUCKET=${1}
PREFIX=${2}
function error {
echo "ERROR:: ${@}"
exit 2
}
@djosephsen
djosephsen / developer_anthropolgy_101
Created October 2, 2018 03:26
I'm a newly embedded SRE; how do I get to know my dev team and their product?
Open Curiousity
/ALWAYS ask stupid questions/
Acknowledge design wins, and call out things that don't look right
* If your service has a front-end DNS name, reverse engineer it. What system actually responds to the initial request? An edge cache? A Load Balancer? An Nginx host?
* Make a map of the lifecycle of a request to your team's service that begins at dns, and ends at the service's listening port
* what does a request into your service look like? Is it an API endpoint? can you curl it? If so, craft a CURL request that you can use to test whether or not your service is "up"
def __get_gh_repos(teamname):
'''
looks up team ID from the organization then returns a list of repos
for which that team are collaborators
'''
params = ''
base_url = 'https://api.github.com/'
headers = { 'Accept' :'application/vnd.github.v3+json', "Content-type" : "application/json", \
'User-Agent' : '[email protected]', 'Authorization': 'token ' + app.config['GH_API_TOKEN'] }
req = requests.get(base_url + 'orgs/librato/teams', auth=(app.config['GH_API_TOKEN'], 'x-oauth-basic')).text
#!/bin/bash
NET=$1
MOUNT=$2
PRICE[5]='.30'
PRICE[10]='.25'
PRICE[15]='.20'
PRICE[30]='.15'
PRICE[60]='.10'
PRICE[300]='.5'
[ { "url": "https://api.github.com/repos/docker/docker/issues/18048", "labels_url": "https://api.github.com/repos/docker/docker/issues/18048/labels{/name}", "comments_url": "https://api.github.com/repos/docker/docker/issues/18048/comments", "events_url": "https://api.github.com/repos/docker/docker/issues/18048/events", "html_url": "https://github.com/docker/docker/issues/18048", "id": 117446711, "number": 18048, "title": "docker daemon crash when starting container after: RequestAddress(LocalDefault/172.17.0.0/16, <nil>, map[])", "user": { "login": "bschiffthaler", "id": 8308279, "avatar_url": "https://avatars.githubusercontent.com/u/8308279?v=3", "gravatar_id": "", "url": "https://api.github.com/users/bschiffthaler", "html_url": "https://github.com/bschiffthaler", "followers_url": "https://api.github.com/users/bschiffthaler/followers", "following_url": "https://api.github.com/users/bschiffthaler/following{/other_user}", "gists_url": "https://api.github.com/users/bschiffthaler/gists{/gist_id}", "starred_url":
@djosephsen
djosephsen / run-parts-wrapper
Last active August 29, 2015 14:15
A wrapper for /bin/run-parts that works with shellbrato to capture cron jobs as annotation events in librato
#!/bin/bash
RP='/bin/run-parts-orig' #where's the original run-parts?
SHELLBRATO='/opt/shellbrato/shellbrato.sh' #where's shellbrato?
LBCREDS='/home/dave/librato_creds' #where are the librato creds?
PARENT=$(ps -ocommand= -p $PPID | awk -F/ '{print $NF}' | awk '{print $1}')
START=$(date -d 'now' +%s)
OUT=$(${RP} ${@})
EXIT=${?}
@djosephsen
djosephsen / gist:8306440
Last active January 2, 2016 12:59
nest.py to librato via sh and shellbrato
#!/bin/sh
#use nest.py to gather interesting metrics, and push them to librato
NP="/home/dave/tmp/nest.py show --user dave --password XXX" # the nest.py command
source ${SBHOME}/shellbrato.sh #the librato shell library
${NP} | egrep -w 'current_humidity|current_temperature|hvac_heater_state|target_temperature' | sed -e 's/\.\+: /:/'| while read METRIC
do
read NAME VALUE <<< $(echo ${METRIC} | tr ':' ' ')
[ "${VALUE}" == "True" ] && VALUE=1