Skip to content

Instantly share code, notes, and snippets.

@code-4-fun
code-4-fun / GoogleGeoCodeExample.java
Last active April 10, 2017 02:39
Sample Boilerplate Code to Parse GeoCode API Response and extract necessary parameter values.
/**
Dependencies Used:
<dependencies>
<dependency>
<groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId>
<version>4.5.3</version>
</dependency>
<dependency>
<groupId>org.json</groupId>
@code-4-fun
code-4-fun / RollingDiceProblem.java
Created March 30, 2017 11:32
Given a fair 6 sided dice, find out how many possible ways in which a SUM of face value can be obtained.
import java.math.BigInteger;
import java.text.NumberFormat;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import java.util.stream.IntStream;
/**
* @author devendra.nalawade on 3/30/17
import java.util.List;
import java.util.ArrayList;
/**
* @author devendra.nalawade on 2/14/17
* output:
* Response for 0: Zero Dollar
* Response for 54: Fifty Four Dollars
* Response for 333: Three Hundred and Thirty Three Dollars
* Response for 5457: Five Thousand Four Hundred and Fifty Seven Dollars
@code-4-fun
code-4-fun / MissingWords.java
Last active October 16, 2022 03:13
Java Program to compare and find differences between two string... Missing Word Problem
package test.concurrency;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
public class MissingWords {
public static void main(String[] args) {
String s = "I often wonder how good this Java World is...";
@code-4-fun
code-4-fun / CompletableFutureTest.java
Created January 11, 2017 09:07
Sample Program to demonstrate how Java 8's CompletableFuture can be used to perform operations in Non-Blocking way
package test.concurrency;
import com.sun.tools.javac.util.Assert;
import java.util.Calendar;
import java.util.Date;
import java.util.concurrent.CompletableFuture;
/**
* @author devendra.nalawade on 1/11/17
@code-4-fun
code-4-fun / BlockingResourcePool.java
Created January 4, 2017 09:33
Sample Implementation of Blocking Resource Pool which performs light weight resource pooling
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.locks.Condition;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
public class BlockingResourcePool {
private final Lock OWN_LOCK = new ReentrantLock();
@code-4-fun
code-4-fun / DemoApplication.java
Created November 30, 2016 07:33
Ordered Bean Initialisation
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.DisposableBean;
import org.springframework.beans.factory.InjectionPoint;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;