This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Handy when you don't care about data and rabbitmq stopped working | |
$ rabbitmqctl add_vhost /sensu | |
Creating vhost "/sensu" ... | |
Error: {node_not_running,'rabbit@ip-X-Y-Z-A'} | |
$ rabbitmqctl cluster_status | |
Cluster status of node 'rabbit@ip-X-Y-Z-A' ... | |
[{nodes,[{unknown,['rabbit@ip-X-Y-Z-A']}]},{running_nodes,[]}] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
"".join((chr(ord(os.urandom(1))/2) for x in range(64))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
def pprinttable(data, headers=None, print=print): | |
""" | |
prints data as a table assuming that data is a list of dictionaries (single level) | |
if headers are provided then they specify sequence of columns | |
example of data: | |
[{'slug': u'ams1', 'name': u'Amsterdam 1', 'region_id': 2}, | |
{'slug': u'sfo1', 'name': u'San Francisco 1', 'region_id': 3}, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from gevent import socket as g_socket | |
assert g_socket.timeout == socket.timeout | |
print "gevent monkey patch for socket confirmed" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BASE_ALPHABET = "123456789abcdefghijkmnopqrstuvwxyz" | |
def encode_base_x(n): | |
base = len(BASE_ALPHABET) | |
def chars(num): | |
while num >= base: | |
num, mod = divmod(num, base) | |
yield BASE_ALPHABET[mod] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mkdir -p /mnt/shared | |
mount -t vboxsf -o uid=1000,gid=1000 shared /mnt/shared |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SchrodingerUser(AnonymousUser): | |
""" | |
Imagine that you are making the experiment and want to measure your results. | |
But Greenpeace has just came to the office and claims that 50% of cats life | |
is better for the cat than certain life or death. | |
Returned on DB access error. | |
""" | |
pass |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class DebugContext(object): | |
def __init__(self): | |
print self.__class__, "init" | |
def __enter__(self): | |
print self.__class__, "enter" | |
def __exit__(self, type, value, traceback): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# from: http://matelakat.blogspot.co.uk/2012/03/lettuce-and-ipython-interactive-shell.html | |
# | |
@step(u'And give me IPython') | |
def and_continue_here(step): | |
import IPython | |
import sys | |
shell = IPython.InteractiveShell() | |
ip = IPython.core.ipapi.get() | |
p = IPython.core.debugger.Pdb(ip.colors) | |
p.reset() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
setup DISPLAY accordingly i.e. | |
export DISPLAY=:0 | |
import -window root file.png |