Skip to content

Instantly share code, notes, and snippets.

View kalpeshp0310's full-sized avatar
🏠
Working from home

Kalpesh Patel kalpeshp0310

🏠
Working from home
View GitHub Profile
@kalpeshp0310
kalpeshp0310 / main.go
Created January 8, 2018 12:45 — forked from enricofoltran/main.go
A simple golang web server with basic logging, tracing, health check, graceful shutdown and zero dependencies
package main
import (
"context"
"flag"
"fmt"
"log"
"net/http"
"os"
"os/signal"
@kalpeshp0310
kalpeshp0310 / NetworkHelper.java
Last active April 14, 2017 08:25
Network Helper for RxJava, OkHttp, Gson
public class NetworkHelper {
private OkHttpClient okHttpClient;
private Gson gson;
public NetworkHelper(OkHttpClient okHttpClient, Gson gson) {
this.okHttpClient = okHttpClient;
this.gson = gson;
}
/**
@kalpeshp0310
kalpeshp0310 / File.java
Created April 7, 2016 15:43 — forked from dlew/File.java
Automated onError() message generation
public static Action1<Throwable> crashOnError() {
final Throwable checkpoint = new Throwable();
return throwable -> {
StackTraceElement[] stackTrace = checkpoint.getStackTrace();
StackTraceElement element = stackTrace[1]; // First element after `crashOnError()`
String msg = String.format("onError() crash from subscribe() in %s.%s(%s:%s)",
element.getClassName(),
element.getMethodName(),
element.getFileName(),
element.getLineNumber());