Skip to content

Instantly share code, notes, and snippets.

View tgvdinesh's full-sized avatar

Dinesh V tgvdinesh

View GitHub Profile
@tgvdinesh
tgvdinesh / gradle.rb
Last active January 13, 2022 07:41
How to install specific Gradle Version?
# brew install --build-from-source ./gradle.rb
# All Gradle version - https://gist.github.com/l1x/d8ba66343fceb927d691
# Install Gradle from local Formule - https://github.com/Homebrew/brew/issues/1468
# Or you can download distribution from official site https://services.gradle.org/distributions/
# When you run the above local Formule build and if the build fails with sha mismath, Replace sha256 below with the Actual sha256 returned by your run also don't forget to replace gradle version in url
# Below is sample Gradle class
class Gradle < Formula
desc "Build system based on the Groovy language"
homepage "https://www.gradle.org/"
url "https://services.gradle.org/distributions/gradle-2.13-all.zip"
@tgvdinesh
tgvdinesh / rabbitmq-makefile
Created April 24, 2018 09:46
makefile for Rabbit mq
build:
@docker pull rabbitmq:3.7.4-management
run:
@docker run -d --hostname localhost --name my-rabbitmq -p 8080:61617 -p 8081:15672 -e RABBITMQ_DEFAULT_USER=user -e RABBITMQ_DEFAULT_PASS=password rabbitmq:3-management
start http://localhost:8081
start:
@docker start my-rabbitmq
stop:
@docker stop my-rabbitmq
clean:
@tgvdinesh
tgvdinesh / XMLParser.java
Created February 6, 2017 10:46
Recursively looks for a node name and prints specified attribute value
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import java.io.IOException;
@tgvdinesh
tgvdinesh / ThreadJoin.java
Created February 6, 2017 00:58
Sometimes we need to wait for other threads to finish it’s execution before we can proceed. We can achieve this using Thread join, learn how it works and when we should use it.
import java.util.logging.Logger;
/**
* Thread join
* <a href="http://www.journaldev.com/1024/java-thread-join-example">Java Thread Join</a>
*/
class ThreadJoin {
static Logger logger = Logger.getLogger(App.class.getSimpleName());
@tgvdinesh
tgvdinesh / ExceptionHandling.java
Created February 5, 2017 09:02
Exception handling in Java 1.6
package com.example.java;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
/**
* Exception handling
* <a href="http://www.journaldev.com/1696/exception-handling-in-java">Exception Handling in Java</a>
@tgvdinesh
tgvdinesh / Tree.c
Created January 19, 2017 03:38
Tree DS implementation in C language
int main(){
node * root = NULL;
int a[100005],K,i = 0,j = 0, _element, present;
scanf("%d",&K);
for( j = 0; j < K;j++ ) {
scanf("%d",&a[i++]);
}
for( i = 0; i < K;i++ ){
@tgvdinesh
tgvdinesh / Tree.cpp
Created January 19, 2017 03:38
Tree DS implementation in C++ language
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
@tgvdinesh
tgvdinesh / Summation.java
Created January 17, 2017 03:13
Summation program with file read & write snippet
class Summation {
public static void main(String[] args) throws IOException {
// Read & write data from file.
Scanner in = new Scanner(System.in);
final String fileName = System.getenv("OUTPUT_PATH");
BufferedWriter bw = new BufferedWriter(new FileWriter(fileName));
int res;
int _numbers_size = 0;
_numbers_size = Integer.parseInt( in .nextLine().trim());
@tgvdinesh
tgvdinesh / maxInversions.java
Created January 14, 2017 04:00
Count Inversions in an array (Possible inversion 3) - http://www.geeksforgeeks.org/counting-inversions/
public class App {
public static void main(String[] args) {
int[] prices = {5, 8, 6, 1, 4, 5};
int count = 0;
if (prices.length >= 1 && prices.length <= 5000) {
for (int i = 0; i < prices.length; i++) {
if (i <= prices.length - 2) {
for (int j = i + 1; j < prices.length; j++) {
if (j <= prices.length - 1) {
if (prices[i] > prices[j]) {
@tgvdinesh
tgvdinesh / App.java
Created November 18, 2016 08:29
Divide and conquer approach to find if sum of any two value a and b is equal to user given input.
public class App {
public static void main(String[] args) {
int x = 8;
int[] arr = {-3, -2, 1, 7, 8, 11, 12, 21};
for (int i = 0; i < arr.length; i++) {
int a = arr[i];
int b = x - a;
if (b <= arr[arr.length - 1]) {
int result = divideAndConquer(arr, b, i + 1, arr.length - 1);
if (result != -1) {