Skip to content

Instantly share code, notes, and snippets.

View rajeevprasanna's full-sized avatar

Rajeev Kumar kallempudi rajeevprasanna

View GitHub Profile

This gist describes the configuration required for Spring reactive WebClient to make a call to an OAuth2 protected resource through OAuth2.0 Client Credentials Grant Type Flow.

Assumption is that the Authorization Server supports OpenId Connect 1.0 specifications.

/**
* Hacky Workaround for Getting the Current Context Classloader
* Executing Some arbitrary Sync with the Hbase Classloader
* Then reseting that thread to how it was previously.
*
* The moments I believe this is neccessary is when connections or
* configurations are being created to HBase. At these times it
* needs to have the hbase-default.xml which it will be lacking
* otherwise.
*
@ChristopherDavenport
ChristopherDavenport / HbaseClassloader.scala
Created November 15, 2018 14:04
HBase Class Loading Trick
/**
* Hacky Workaround for Getting the Current Context Classloader
* Executing Some arbitrary Sync with the Hbase Classloader
* Then reseting that thread to how it was previously.
*
* The moments I believe this is neccessary is when connections or
* configurations are being created to HBase. At these times it
* needs to have the hbase-default.xml which it will be lacking
* otherwise.
*
@domnikl
domnikl / build.gradle.kts
Last active October 11, 2024 11:06
Gradle Kotlin DSL: set main class attribute for jar
tasks.withType<Jar> {
manifest {
attributes["Main-Class"] = "com.example.MainKt"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="X-UA-Compatible">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Test</title>
<!-- Office JavaScript API -->
<script type="text/javascript" src="https://appsforoffice.microsoft.com/lib/1/hosted/office.js"> </script>
<!DOCTYPE html>
<html lang="en">
<head>
<title>File downloader</title>
</head>
<body>
<div id="progress-msg">File is downloading. Please wait...</div>
<script>
function saveAs(blob, fileName) {
@cer
cer / DefaultController.java
Last active January 14, 2023 18:17
Spring Webflux-based proxying controller
import org.springframework.core.io.buffer.DefaultDataBufferFactory;
import org.springframework.http.MediaType;
import org.springframework.http.server.reactive.ServerHttpRequest;
import org.springframework.http.server.reactive.ServerHttpResponse;
import org.springframework.stereotype.Controller;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.reactive.function.client.WebClient;
import cats.MonadError
import cats.instances.either._
import cats.instances.future._
import cats.instances.try_._
import cats.syntax.applicativeError._
import cats.syntax.flatMap._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future}
@rajeevprasanna
rajeevprasanna / statefactorial.scala
Created June 29, 2017 10:35 — forked from calvinlfer/statefactorial.scala
Factorial using the State monad
import cats.data.State
import cats.data.State._
def factorialWithState(x: Int): Int = {
def stateFactorial: State[Int, Int] =
get.flatMap(x =>
if (x <= 1)
State.pure(1)
else {
set[Int](x - 1).flatMap(_ => stateFactorial.map(z => x * z))
@zsolt-donca
zsolt-donca / Main2.scala
Created June 7, 2017 19:44
Playing around with Cats' State monad
package testing
import cats._
import cats.data._
import cats.implicits._
object Main2 extends App {
case class Stats(warning: Int, error: Int)