Skip to content

Instantly share code, notes, and snippets.

@sujeet100
sujeet100 / KafkaConnectDockerFileWithAdditionalConnectors
Last active June 15, 2022 16:30
Setup Debezium Oracle Conenctor
FROM confluentinc/cp-kafka-connect-base:6.1.1
RUN confluent-hub install --no-prompt hpgrahsl/kafka-connect-mongodb:1.1.0 \
&& confluent-hub install --no-prompt microsoft/kafka-connect-iothub:0.6 \
&& confluent-hub install --no-prompt wepay/kafka-connect-bigquery:1.1.0 \
&& confluent-hub install --no-prompt confluentinc/kafka-connect-jdbc:latest \
&& confluent-hub install --no-prompt confluentinc/kafka-connect-datagen:0.1.0 \
&& confluent-hub install --no-prompt debezium/debezium-connector-postgresql:latest
# -----------
@sujeet100
sujeet100 / MyFutures.java
Last active October 11, 2021 14:44
Completable Futures
package com.sujit;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
record Person(int id, String name, List<Score> scores, Address address, Account account) {
}
@sujeet100
sujeet100 / ingress-virtual-service.yaml
Last active June 4, 2021 13:33
Kong ingress / Istio gateway and routing example (covers path based routing with url rewrite)
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
name: moviesservice
spec:
hosts:
- "*"
gateways:
- istio-gateway
http:
This file has been truncated, but you can view the full file.
[{"productKey":149039373,"productName":"homely-seat-scribble","buyingPrice":10,"currentPrice":32,"recommendedPrice":65,"compName":"loose-seed-warn","compPrice":14,"region":"EAST"},{"productKey":149039373,"productName":"homely-seat-scribble","buyingPrice":10,"currentPrice":32,"recommendedPrice":65,"compName":"loose-seed-warn","compPrice":14,"region":"WEST"},{"productKey":149039373,"productName":"homely-seat-scribble","buyingPrice":10,"currentPrice":32,"recommendedPrice":65,"compName":"loose-seed-warn","compPrice":14,"region":"NORTH"},{"productKey":149039373,"productName":"homely-seat-scribble","buyingPrice":10,"currentPrice":32,"recommendedPrice":65,"compName":"loose-seed-warn","compPrice":14,"region":"SOUTH"},{"productKey":709644620,"productName":"mellow-lawyer-inventory","buyingPrice":25,"currentPrice":67,"recommendedPrice":44,"compName":"awake-marble-wind","compPrice":53,"region":"EAST"},{"productKey":709644620,"productName":"mellow-lawyer-inventory","buyingPrice":25,"currentPrice":67,"recommendedPrice":44,
This file has been truncated, but you can view the full file.
[{"productKey":374,"productName":"childlike-studio-miss","buyingPrice":4,"currentPrice":83,"recommendedPrice":20,"compName":"messy-toys-soothsay","compPrice":45,"children":[{"productKey":374,"productName":"childlike-studio-miss","buyingPrice":4,"currentPrice":83,"recommendedPrice":20,"compName":"messy-toys-soothsay","compPrice":45,"region":"EAST"},{"productKey":374,"productName":"childlike-studio-miss","buyingPrice":4,"currentPrice":83,"recommendedPrice":20,"compName":"messy-toys-soothsay","compPrice":45,"region":"WEST"},{"productKey":374,"productName":"childlike-studio-miss","buyingPrice":4,"currentPrice":83,"recommendedPrice":20,"compName":"messy-toys-soothsay","compPrice":45,"region":"NORTH"},{"productKey":374,"productName":"childlike-studio-miss","buyingPrice":4,"currentPrice":83,"recommendedPrice":20,"compName":"messy-toys-soothsay","compPrice":45,"region":"SOUTH"}]},{"productKey":880,"productName":"flowery-cobweb-target","buyingPrice":22,"currentPrice":3,"recommendedPrice":21,"compName":"noiseless-desk-
@sujeet100
sujeet100 / TupleQuery.scala
Last active November 14, 2017 04:16
Quill: Tail recursive liftQuery macro
trait TupleQuery {
this: io.getquill.context.Context[_, _] =>
def liftTuples[T1: Encoder, T2: Encoder](l: List[(T1, T2)]): Quoted[Query[(T1, T2)]] =
liftTuples(l, (t: (T1, T2)) => infix"(${lift(t._1)}, ${lift(t._2)})", null)
private def liftTuples[T, U](l: List[T], f: T => Quoted[Any], acc: Quoted[Query[U]]): Quoted[Query[U]] = {
l match {
case Nil => infix"".as[Query[U]]
case head :: Nil => infix"${f(head)}, $acc".as[Query[U]]
//Scala
assert(books.filter{_.numberOfPages > 100}.take(2) == List(new Book("Refactoring", "Martin", 300), new Book("Extreme Programming", "Bob", 200)))
//Java 8
assertThat(books.stream()
.filter(book -> book.getNumberOfPages() > 100)
.limit(2)
.collect(Collectors.toList())
, is(Arrays.asList(new Book("Refactoring", "Martin", 300), new Book("Extreme Programming", "Bob", 200))));
//Scala
assert(books.find(_.name == "TDD") == Option(new Book("TDD", "Kent", 250)))
//Java 8
assertThat(books.stream()
.filter(book -> book.getName().equals("TDD"))
.findFirst(),
is(Optional.of(new Book("TDD", "Kent", 250))));
//Groovy
//Scala
assert(books.filter((book: Book) => book.author == "Bob") == List(new Book("Clean Code", "Bob", 100), new Book("Extreme Programming", "Bob", 200)))
//Or
assert(books.filter(book => book.author == "Bob") == List(new Book("Clean Code", "Bob", 100), new Book("Extreme Programming", "Bob", 200)))
//Or
assert(books.filter(_.author == "Bob") == List(new Book("Clean Code", "Bob", 100), new Book("Extreme Programming", "Bob", 200)))
//Java
assertThat(
List<Book> books = new ArrayList<Book>() {
{
add(new Book("Clean Code", "Bob", 100));
add(new Book("Refactoring", "Martin", 300));
add(new Book("Extreme Programming", "Bob", 200));
add(new Book("TDD", "Kent", 250));
}
};