Skip to content

Instantly share code, notes, and snippets.

x = [
"blah",
"woot",
"foo"
]
# python
Python 2.7.2 (default, Oct 11 2012, 20:14:37)
[GCC 4.2.1 Compatible Apple Clang 4.0 (tags/Apple/clang-418.0.60)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from botocore import session
>>> s = session.get_session()
>>> sqs = s.get_service('sqs')
>>> rcv = sqs.get_operation('ReceiveMessage')
>>> sqs.region_names
[u'us-east-1', u'ap-northeast-1', u'eu-west-1', u'ap-southeast-1', u'ap-southeast-2', u'us-west-2', u'us-gov-west-1', u'us-west-1', u'sa-east-1']
>>> def breadth_first(start_list, callback):
... working = start_list
... while working:
... for i, sublist in enumerate(working):
... try:
... v = sublist.pop(0)
... callback(v)
... except IndexError:
... del(start_list[i])
... working = start_list
>>> def breadth_first(sequence):
... import copy
... tmp_seq = list(reversed(copy.deepcopy(sequence)))
... while tmp_seq:
... for i in xrange(len(tmp_seq) -1, -1, -1):
... try:
... v = tmp_seq[i].pop(0)
... print v
... except IndexError:
... del(tmp_seq[i])
import imp
import os
config_path = os.environ.get('CONFIG_FILE', '/etc/blah')
path, module = os.path.split(config_path)
module_info = imp.find_module(module, [path])
settings = imp.load_module('settings', *module_info)
import collections
import sys
import traceback
S_OK = 0
S_UP = 0
S_WARNING = S_WARN = 1
S_CRITICAL = S_CRIT = 2
S_DOWN = 2
S_UNKNOWN = 3
>>> string = """Namespace Queue Messages
... SJHENT Alert_Operation_Router 0
... SJHENT Alert_Process_Router 0
... SJHENT Alert_Service_Restart 0
... SJHENT Alert_Service_Router 0
... SJHENT BadMessageHandler 0
... SJHEDI EMailAlert 0
... SJHENTPMM Ens.Actor 0
... BLAHBLAH WOOTWOOT 501"""
>>> lines = string.split('\n')
import SimpleHTTPServer
import SocketServer
PORT = 8000
Handler = SimpleHTTPServer.SimpleHTTPRequestHandler
httpd = SocketServer.TCPServer(("", PORT), Handler)
print "serving at port", PORT

Keybase proof

I hereby claim:

  • I am phobologic on github.
  • I am phobologic (https://keybase.io/phobologic) on keybase.
  • I have a public key whose fingerprint is 523F 7875 B0FE 563E 22D0 1B8E C71A D757 0989 4912

To claim this, I am signing this object:

t.add_resource(
ec2.SecurityGroup(
"SecurityGroup1",
GroupDescription="SecurityGroup1"))
t.add_resource(
ec2.SecurityGroup(
"SecurityGroup2",
GroupDescription="SecurityGroup2"))
# Allow hosts in SecurityGroup2 to access Hosts in SecurityGroup1 on port 80