Skip to content

Instantly share code, notes, and snippets.

View shekhargulati's full-sized avatar

Shekhar Gulati shekhargulati

View GitHub Profile
import retrofit2.Call;
import retrofit2.Response;
import retrofit2.Retrofit;
import retrofit2.converter.gson.GsonConverterFactory;
public class RetrofitExample {
public static void main(String[] args) throws IOException {
Retrofit retrofit = new Retrofit.Builder()
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.URL;
public class HttpClient {
public int getHttResponseCode(String url) throws RuntimeException {
HttpURLConnection connection = null;
try {
URL u = new URL(url);
@shekhargulati
shekhargulati / StatusChecker.java
Last active September 13, 2019 05:26
Refactoring Example 2 - Status Checker
import java.io.IOException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.Date;
public class StatusChecker {
public WebsiteStatus getStatus(String url) {
WebsiteStatus websiteStatus = new WebsiteStatus();
@shekhargulati
shekhargulati / OrderService.java
Created September 13, 2019 05:24
Refactoring Example 1
import java.util.List;
public class OrderService {
void print(List<Order> list, String n) {
double outstanding = 0.0;
System.out.println("*****************************");
System.out.println("****** Customer Outstanding Total ******");
System.out.println("*****************************");
import java.nio.file.Files;
import java.nio.file.Paths;
import static adventofcode.Utils.toInt;
import static strman.Strman.repeat;
public class Problem09 {
public static void main(String[] args) throws Exception {
String input = Files.readAllLines(Paths.get("src", "test", "resources", "problem09.txt")).get(0);
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import static adventofcode.Utils.toInt;
import static java.util.stream.Collectors.joining;
package playground
import akka.actor.{Actor, ActorLogging, ActorRef, Props}
import playground.Parent.{BulkTasks, Finish, TaskCompleted, TaskFailed}
import scala.util.{Failure, Success, Try}
trait Task {
val id: String
@shekhargulati
shekhargulati / SlidingString.java
Last active October 17, 2015 07:51
Java 8 String Sliding Example. Given a String "abcdef" the program should print >> a ab abc abcd abcde abcdef
import java.util.stream.IntStream;
/**
* Given a String "abcdef" the program should print
* a
* ab
* abc
* abcd
* abcde
* abcdef
<rule name="yakCiRule" scope="deployed">
<conditions>
<type>udm.BaseDeployed</type>
<operation>CREATE</operation>
</conditions>
<steps>
<complex-step>
<ci>
<rules-test.Yak id="Infrastructure/tmp/yak007">
</rules-test.Yak>
<rule name="yakCiRule" scope="deployed">
<conditions>
<type>udm.BaseDeployed</type>
<operation>CREATE</operation>
</conditions>
<steps>
<complex-step>
<ci>
<rules-test.Yak id="Infrastructure/tmp/yak007">
</rules-test.Yak>