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 / 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 / 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 / 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;
@SpringBootApplication
@EnableRedisRepositories
@EnableWebMvc
public class AsynchronousTaskExecutorApplication {
public static void main(String[] args) {
SpringApplication.run(AsynchronousTaskExecutorApplication.class, args);
}
}
@sonus21
sonus21 / application.properties
Created November 3, 2019 06:44
application.properties
email.queue.name=email-queue
invoice.queue.name=invoice-queue
# 30 seconds delay for invoice
invoice.queue.delay=300000
@sonus21
sonus21 / Invoice.java
Last active November 3, 2019 06:45
Invoice
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Invoice {
private String id;
private String type;
@sonus21
sonus21 / Email.java
Last active November 3, 2019 06:46
Email
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@Data
@AllArgsConstructor
@NoArgsConstructor
public class Email {
private String email;
private String subject;
@sonus21
sonus21 / build.gradle
Created November 5, 2019 17:09
Micrometer dependencies
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-data-jpa'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat'
implementation 'io.micrometer:micrometer-registry-prometheus'
implementation 'org.springframework.boot:spring-boot-starter-actuator'
// https://mvnrepository.com/artifact/com.h2database/h2
compile group: 'com.h2database', name: 'h2', version: '1.4.200'
@sonus21
sonus21 / application.properties
Last active November 8, 2019 04:37
Enable Prometheus In Spring boot app
# Enable prometheus exporter
management.metrics.export.prometheus.enabled=true
# Enable prometheus end point
management.endpoints.web.exposure.include=prometheus
# enable percentile-based histogram for http requests
management.metrics.distribution.percentiles-histogram.http.server.requests=true
# http SLA histogram buckets
management.metrics.distribution.sla.http.server.requests=100ms,150ms,250ms,500ms,1s
# enable JVM metrics
management.metrics.enable.jvm=true