Skip to content

Instantly share code, notes, and snippets.

@varunnayal
varunnayal / process_max_n_times.js
Created July 20, 2017 15:09
RabbitMQ: Process a message maximum of "N" times using dead letter exchange
var amqp = require('amqplib');
var url = 'amqp://localhost';
var WORK_QUEUE_NAME = 'work.queue';
var WORK_EXCHANGE_NAME = 'work.exchange';
var DEAD_QUEUE_NAME = 'dead.work.queue';
var DEAD_EXCHANGE_NAME = 'dead.work.exchange';
var MAX_RETRY_COUNT = 3;
@varunnayal
varunnayal / redis_installation_script.sh
Created August 9, 2017 13:29
Install Redis on ubuntu
#!/bin/bash
#TEMP_DIR="$(dirname $(mktemp -u))""/"
TEMP_DIR=$(mktemp -u)
DEFAULT_REDIS_VERSION="3.2.6"
DEFAULT_PORT="6379"
DEFAULT_PID_DIR="/var/run"
# Version to install
@varunnayal
varunnayal / file-next-integer.js
Created November 1, 2017 12:21
Get next filename when files are ordered in format <filename>.<integer>
const fs = require('fs');
const RegExp_escape = function(s) {
return (s ? s + '' : '').replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};
/**
* @prop {Object} options - Options Object or String if Filename
* @param {String} filename - File name
* @param {String} dir - Directory to look for filename pattern