Skip to content

Instantly share code, notes, and snippets.

View sonus21's full-sized avatar

Sonu Kumar sonus21

View GitHub Profile
@sonus21
sonus21 / tmux_local_install.sh
Last active November 20, 2015 07:55 — forked from sharjeelsayed/tmux_local_install.sh
bash script for installing tmux without root access.Updated to include latest Tmux version and some other minor changes
#!/bin/bash
# Source: https://gist.github.com/sonus21/53cd486fb0bdb83cd10d/
# Script for installing tmux on systems where you don't have root access.
# tmux will be installed in $HOME/local/bin.
# It's assumed that wget and a C/C++ compiler are installed.
# exit on error
set -e
@sonus21
sonus21 / counter_tag.py
Last active October 11, 2023 05:01
Django counter tag, can generate counter in case of single or multiple for loop.
#Adapted from https://djangosnippets.org/snippets/2619/
@register.tag(name='counter')
def do_counter(parser, token):
"""
Counter tag. Can be used to output and increment a counter.
Usage:
- {% counter %} to output and post-increment the counter variable
- {% counter reset %} to reset the counter variable to 1
@sonus21
sonus21 / mapred-site.xml
Created April 17, 2016 07:24
This will solve error pydoop.LocalModeNotSupported: ERROR: Hadoop is configured to run in local mode
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<!--
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
@sonus21
sonus21 / binary_search.py
Created March 4, 2017 05:09
Generic Binary Search in Python
def binary_search(values, key, lo=0, hi=None, length=None, comp=None):
"""
This is a binary search function which search for given key in values.
This is very generic in the sense values and key can be of different type.
If they are of different type then caller must specify comp function to
perform comparision between key and values's item.
:param values: List of items in which key has to be search
:param key: search key
:param lo: start index to begin search
:param hi: end index where search will be performed
@sonus21
sonus21 / array.cpp
Last active June 19, 2019 16:39
Dynamic array in C++ which grows/shrink at the rate of 2.
#include <iostream>
#include <cstring>
#include <exception>
#include <stdexcept>
using namespace std;
class IndexError: public exception {
public: IndexError(char * msg) {
this -> msg = new char[strlen(msg)];
cout << msg;
@sonus21
sonus21 / Message Sender.java
Last active July 24, 2020 03:56
Message Sender Methods
public interface RqueueMessageSender {
/**
* Enqueue a message on given queue without any delay, consume as soon as possible.
*
* @param queueName on which queue message has to be send
* @param message message object it could be any arbitrary object.
* @return message was submitted successfully or failed.
*/
boolean enqueue(String queueName, Object message);
@sonus21
sonus21 / RqueueListener.java
Last active July 24, 2020 03:57
Listener without dead later queue
@RqueueListener(value = "job-queue",numRetries = "3")
public void onMessage(Job job) throws Exception {
//
}
@sonus21
sonus21 / RqueueListener.java
Last active July 24, 2020 03:57
Listener with dead later queue
@RqueueListener(value = "job-queue",numRetries = "3", deadLetterQueue="job-dlq")
public void onMessage(Job job) throws Exception {
//
}
@sonus21
sonus21 / build.gradle
Last active May 13, 2021 11:58
Build gradle
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'com.github.sonus21:rqueue-spring-boot-starter:2.7.0-RELEASE'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
testImplementation('org.springframework.boot:spring-boot-starter-test') {
exclude group: 'org.junit.vintage', module: 'junit-vintage-engine'
}
@SpringBootApplication
@EnableRedisRepositories
@EnableWebMvc
public class AsynchronousTaskExecutorApplication {
public static void main(String[] args) {
SpringApplication.run(AsynchronousTaskExecutorApplication.class, args);
}
}