Skip to content

Instantly share code, notes, and snippets.

View devdazed's full-sized avatar

Russ Bradberry devdazed

View GitHub Profile
@devdazed
devdazed / ri-audit.py
Created December 7, 2016 15:38
EC2 Reserved Instance auditing
import boto.ec2
def get_running_instances(region):
ec2 = boto.ec2.connect_to_region(region)
instances = [i for r in ec2.get_all_reservations() for i in r.instances]
return filter(lambda i: i.state == 'running', instances)
def get_reserved_instances(region):
ec2 = boto.ec2.connect_to_region(region)
reserved_instances = ec2.get_all_reserved_instances()
@devdazed
devdazed / gist:749d046b1a1da8869d68
Last active February 12, 2016 17:12
Jupyter on DSE

On your client machine

As the root user

  1. Install DSE
  2. In the cassandra.yml file, ensure the datacenter and cluster match your analytics datacenter
  3. In the cassandra-env.sh file add this configuration line toward the bottom JVM_OPTS="$JVM_OPTS -Dcassandra.join_ring=false" This will make your DSE node a coordinator only, it will not own any data. You can use this node to submit jobs to DSE locally without the need to know which is the master node.
  4. start DSE
@devdazed
devdazed / slack-pagerduty-oncall.py
Last active April 18, 2024 10:28
Updates a Slack User Group with People that are on call in PagerDuty
#!/usr/bin/env python
from __future__ import print_function
import json
import logging
from urllib2 import Request, urlopen, URLError, HTTPError
from base64 import b64decode
#!/usr/bin/env python
from __future__ import print_function
import json
import logging
import re
from base64 import b64decode, b64encode
from urllib2 import Request, urlopen, URLError, HTTPError
@devdazed
devdazed / tc.py
Created December 2, 2015 21:29
SSTable Tombstone Counter
import fileinput, re, operator
from collections import Counter
def sizeof_fmt(num, suffix='B'):
for unit in ['', 'Ki', 'Mi', 'Gi', 'Ti', 'Pi', 'Ei', 'Zi']:
if abs(num) < 1024.0:
return "%3.1f%s%s" % (num, unit, suffix)
num /= 1024.0
return "%.1f%s%s" % (num, 'Yi', suffix)
@devdazed
devdazed / tombstone_count.py
Created November 24, 2015 22:04
Count tombstones in a Cassandra Table
#!/usr/bin/env python
"""
Counts the number of tombstones in a keyspace.table and reports the top N highest counts
tombstone_count.py
[-h] This help screen
[--data-dir DATA_DIR] The C* data directory (/var/lib/cassandra/data)
[--top-k TOP_K] The top number of keys with highest tombstone counts to display.
keyspace The keyspace that contains the table
class TunableRetryPolicy(RetryPolicy):
""" A retry policy that allows you to decide if you want to downgrade consistency before
attempting to retry, additionally, you can specify the number of retries to try
"""
def __init__(self, read_retries=3, write_retries=3, downgrade_consistency=True):
self._read_retries = read_retries
self._write_retries = write_retries
self._downgrade_consistency = downgrade_consistency
@devdazed
devdazed / .zuul.yml
Created February 24, 2014 19:52
There is only....
ui: mocha-qunit
browsers:
- name:chrome
- version: latest
scripts:
- "http://d8rk54i4mohrb.cloudfront.net/js/reach.js"
server: ./server.js
class Result(threading.Event):
exception = None
def execute():
cql = 'select * from events limit 10'
response = Result()
def _on_error(error):
response.exception = error
@devdazed
devdazed / load.py
Created January 2, 2014 21:45
Threa
for args in tables_for_load:
thread = FileLoaderWorker(*args)
thread.start()
completed = 0
while completed < len(tables_for_load):
try:
response, exception = response_queue.get(block=False, timeout=0.1)
if exception: