Skip to content

Instantly share code, notes, and snippets.

@jeffadams
jeffadams / delete_custom_metrics.py
Created October 11, 2016 15:59
script to delete all custom metrics from a stackdriver account
#!/usr/bin/env python
from google.cloud import monitoring
'''
# Using a service account with credentials in a json file:
JSON_CREDS = '/path/to/json'
from oauth2client.service_account import ServiceAccountCredentials
scopes = ["https://www.googleapis.com/auth/monitoring",]
credentials = ServiceAccountCredentials.from_json_keyfile_name(
#!/bin/bash
while true
do
OUT=`/usr/bin/pmset -g batt`
PERCENTLEFT=`echo $OUT | awk '{print $8}' | sed 's/%;//'`
if [ ${PERCENTLEFT} \< 40 ];
then
echo "${PERCENTLEFT} percent battery left" > /tmp/batterywarning
fi
@jeffadams
jeffadams / gist:eefd93caafe2a598a94e47e64721c952
Last active July 4, 2021 16:05
bashrc function for aws prompt
aws () {
aws_cmd=`command which aws`
if [[ $@ =~ 'help' ]]
then
command $aws_cmd $@
return
fi
identity=`$aws_cmd sts get-caller-identity` || return
account=`echo $identity | jq '.Account' | tr -d '"'`
arn=`echo $identity | jq '.Arn' | tr -d '"'`