Skip to content

Instantly share code, notes, and snippets.

View flopezluis's full-sized avatar

Félix López flopezluis

  • Salamanca - Spain
View GitHub Profile
@flopezluis
flopezluis / gist:2172067
Created March 23, 2012 15:53
Bookmark to purge all the queues in a vhost. RabbitMQ
//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) {
@flopezluis
flopezluis / gist:2375225
Created April 13, 2012 08:59
require for fabric in ubuntu system
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"
@flopezluis
flopezluis / gist:2375487
Created April 13, 2012 09:53
truncate + suffix
var truncate = function(msg, len, suffix) {
var truncated = msg.substring(0, len);
if (msg.length > len) {
truncated += suffix;
}
return truncated;
}
@flopezluis
flopezluis / DuplicatedChannels.java
Created June 21, 2012 07:44
Check whether you have repeated channels in the spring integration context.
import org.xml.sax.SAXException;
@Component("duplicatedChannels")
public class DuplicatedChannels {
private final Log logger = LogFactory.getLog(this.getClass());
@Autowired
private ApplicationContext appContext;
%%
%%
%% 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
@flopezluis
flopezluis / gist:3255861
Created August 4, 2012 08:21
Bookmark to delete all the queues in a vhost. RabbitMQ
//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 delete_queues = function(name) {
$.ajax({
url:'api/queues/' +vhost+ '/' + name,
type: 'DELETE',
success:function(data) {
@flopezluis
flopezluis / record.py
Created October 6, 2012 06:39
an old script I created to record Vaughan Radio
import sys
import time as timer
import urllib
from datetime import datetime, time
import signal
name = ''
def record():
url_stream = urllib.urlopen("http://vaughanradio.streaming-pro.com:8012/;stream.nsv")
f = open("%s_%s.mp3" %(name, datetime.now().strftime("%y-%m-%d")),"wb");
print ('Recording...')
@flopezluis
flopezluis / example.py
Created October 31, 2012 18:13
Batching with Pika
import logging
import pika
from threading import Timer
BATCH_SIZE = 100
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
LOGGER = logging.getLogger(__name__)
import logging
import sys
import os
import settings
import pika
import re
from threading import Timer
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
import logging
import pika
LOG_FORMAT = ('%(levelname) -10s %(asctime)s %(name) -30s %(funcName) '
'-35s %(lineno) -5d: %(message)s')
LOGGER = logging.getLogger(__name__)
class ExampleConsumer(object):
"""This is an example consumer that will handle unexpected interactions