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
%% | |
%% | |
%% This plugin is based on rabbitmq-recent-history-exchange | |
%% from Alvaro Videla https://github.com/videlalvaro/rabbitmq-recent-history-exchange | |
%% | |
%% This is plugin has been developed by ShuttleCloud. | |
%% | |
%% This exchange gives you the possibility to set throttling to any | |
%% exchange. This exchange receives a message and after a time it's delivered | |
%% to the final exchange. It works as an intermediary |
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 org.xml.sax.SAXException; | |
@Component("duplicatedChannels") | |
public class DuplicatedChannels { | |
private final Log logger = LogFactory.getLog(this.getClass()); | |
@Autowired | |
private ApplicationContext appContext; | |
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
var truncate = function(msg, len, suffix) { | |
var truncated = msg.substring(0, len); | |
if (msg.length > len) { | |
truncated += suffix; | |
} | |
return truncated; | |
} |
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
def require(package): | |
with settings(hide('stdout'), warn_only=True): | |
out = run('dpkg -s %s' %package) | |
if not out.succeeded: | |
print "The package is not installed. Installing \n" | |
sudo("apt-get install %s" %package) | |
else: | |
print "The package is installed.\n" | |
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
//add this to your bookmarks. The default vhost in RabbitMq is "/", | |
// so you should have as virtualhost %2F, but due to chrome escape it, i used %252f | |
//i assume you're in the management site (http://www.rabbitmq.com/management.html) | |
javascript: | |
vhost="%252f"; | |
var purge = function(name) { | |
$.ajax({ | |
url:'api/queues/' + vhost + "/" + name + '/contents/', | |
type: 'DELETE', | |
success:function(data) { |
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
#modification of http://stackoverflow.com/questions/5983265/pythonic-way-of-determining-if-the-current-element-is-the-first-or-last-element | |
def annotate_last_item(gen): | |
prev_val = gen.next() | |
for val in gen: | |
yield False, prev_val | |
prev_val = val | |
yield True, prev_val |
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 DictAsMember(dict): | |
def __getattr__(self, name): | |
""" | |
From : http://docs.python.org/reference/datamodel.html#object.__getattr__ | |
Called when an attribute lookup has not found the attribute in the usual places | |
(i.e. it is not an instance attribute nor is it found in the class tree for self). | |
name is the attribute name | |
http://stackoverflow.com/questions/8709975/overwrite-in-python | |
""" | |
value = self[name] |
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 itertools import imap, groupby | |
def get_duplicates(sec): | |
return [x for x in sec if sec.count(x) > 1] | |
class SumEquals(object): | |
""" | |
Ones, Twos, Threes, Fours, Fives, Sixes: | |
""" |
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 heapq import heappush, heappop | |
def heapsort(iterable, priorities={}): | |
""" | |
Sorted the secuence according to the priorities | |
the biggest number is the less prioritary | |
>>> priorities ={'Como': 1} | |
>>> sec = ['camino', 'Como', 'test'] | |
>>> heapsort(sec, priorities) |
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 django import template | |
register = template.Library() | |
@register.filter | |
def get_parameters(request): | |
""" | |
Returns the list of get paremeter | |
""" | |
parameters = "?" |