Skip to content

Instantly share code, notes, and snippets.

View shantanuo's full-sized avatar

Shantanu Oak shantanuo

  • oksoft
  • mumbai
View GitHub Profile
import argparse
import json
import time
import boto.ec2
# Set up argument parser
parser = argparse.ArgumentParser(
description='Request AWS EC2 spot instance and tag instance and volumes.',
$ cd /tmp
$ echo "foo bar baz foo foo quz" > test1
$ echo "bar bar foo bar baz foo quz foo foo" > test2
$ sed -i '.bak' 's/foo/replaced/g' test*
$ tail test1 test2
==> test1 <==
replaced bar baz replaced replaced quz
==> test2 <==
bar bar replaced bar baz replaced quz replaced replaced
import psutil
import simplejson
import time
import urllib2
# Sends the CPU and memory usage stats to Loggly. Sends both a machine total and per process.
def log():
""""""
proc_dict = {}
#!/usr/bin/python
#
# Convert a Row-Based-Replication binary log to Statement-Based-Replication format, cheating a little.
# This script exists since Percona Toolkit's pt-query-digest cannot digest RBR format. The script
# generates enough for it to work with.
# Expecting standard input
# Expected input is the output of "mysqlbinlog --verbose --base64-output=DECODE-ROWS <binlog_file_name>"
# For example:
# $ mysqlbinlog --verbose --base64-output=DECODE-ROWS mysql-bin.000006 | python binlog-rbr-to-sbr.py | pt-query-digest --type=binlog --order-by Query_time:cnt --group-by fingerprint
#
def parse_connection(connection_string):
"""Work out the user name and password in connection_string
Connection string should be of the form 'database://username@password'
"""
if '@' in connection_string:
# Username is characters between '://' and '@'
slash_position = connection_string.find('://')
at_position = connection_string.find('@')
user_name = connection_string[slash_position+3:at_position]
from parse_conn import parse_connection
import unittest
class InvalidInputs(unittest.TestCase):
def testNoAt(self):
"""parse_connection should raise an exception
for an invalid connection string"""
self.assertRaises(ValueError, parse_connection, 'invalid uri')
if __name__ == "__main__":
#!/usr/bin/env python
"""
Recipe for creating and updating security groups programmatically.
"""
import collections
import boto
import pandas as pd
df = pd.DataFrame({'text': [str(i % 1000) for i in range(1000000)],
'numbers': range(1000000)})
import pickle
import cPickle
import json
from functools import partial
from time import time
#!/usr/bin/env python
# -*- python -*-
#
# Plugin to track account balances on ingdirect.com.au, using selenium gymnastics to log in
#
# E.g.
# ln -s /usr/share/munin/plugins/ingdirect.py /etc/munin/plugins/ingdirect
#
# Needs (hint: pip install):
# selenium
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.