Skip to content

Instantly share code, notes, and snippets.

View rkpattnaik780's full-sized avatar
🎯
Focusing

Ramakrishna Pattnaik rkpattnaik780

🎯
Focusing
View GitHub Profile
@rkpattnaik780
rkpattnaik780 / KafkaConfig.java
Last active March 7, 2024 14:08
Code snippets for Springboot Kafka client using SASL/OAuthBearer
import java.util.HashMap;
import java.util.Map;
public class KafkaConfig {
static Map<String, Object> config() {
Map<String, Object> config = new HashMap<>();
config.put("bootstrap.servers", KAFKA_HOST);
@rkpattnaik780
rkpattnaik780 / PriceConsumer.java
Created November 29, 2022 12:56
Code snippet for Quarkus Kafka using SASL/OAUTHBEARER
package org.acme.kafka;
import javax.enterprise.context.ApplicationScoped;
import org.eclipse.microprofile.reactive.messaging.Acknowledgment;
import org.eclipse.microprofile.reactive.messaging.Incoming;
import org.eclipse.microprofile.reactive.messaging.Outgoing;
import io.smallrye.reactive.messaging.annotations.Broadcast;
@rkpattnaik780
rkpattnaik780 / ConsumerExample.java
Created November 29, 2022 09:52
Code snippets for Java Kafka client using SASL/OAuthBearer
import java.util.Arrays;
import org.apache.kafka.clients.consumer.ConsumerConfig;
import org.apache.kafka.clients.consumer.KafkaConsumer;
import org.apache.kafka.common.serialization.StringDeserializer;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.apache.kafka.clients.consumer.ConsumerRecords;
import java.time.Duration;
public class ConsumerExample {
@rkpattnaik780
rkpattnaik780 / config.py
Last active January 18, 2023 12:45
Code snippets for confluent-python using SASL/OAuthBearer
import time
import requests
def _get_token(config):
payload = {"grant_type": "client_credentials", "scope": "api.iam.service_accounts"}
resp = requests.post(
RHOAS_SERVICE_ACCOUNT_OAUTH_TOKEN_URL,
auth=(
RHOAS_SERVICE_ACCOUNT_CLIENT_ID,
RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET,
@rkpattnaik780
rkpattnaik780 / config.py
Last active November 22, 2022 10:52
Sample producer, consumer and configuration code
KAFKA_HOST=
RHOAS_SERVICE_ACCOUNT_CLIENT_ID=
RHOAS_SERVICE_ACCOUNT_CLIENT_SECRET=
{
"swagger":"2.0",
"info":{
"description":"This is a sample server Petstore server via JSON.",
"version":"1.0.0",
"title":"Swagger Petstore (JSON)",
"termsOfService":"http://helloreverb.com/terms/",
"contact":{
"email":"apiteam@wordnik.com"
},
@rkpattnaik780
rkpattnaik780 / tweet.avsc
Created May 23, 2022 18:30
Avro for tweet objects
{
"type" : "record",
"name" : "Tweet",
"fields" : [
{
"name" : "user",
"type" : "string"
},
{
"name" : "text",
@rkpattnaik780
rkpattnaik780 / util.go
Created March 28, 2022 13:31
GetCurrentContext
// GetCurrent_Context returns the name of the currently selected context
func GetCurrent_Context(svcContext *servicecontext.Context, localizer localize.Localizer) (*servicecontext.ServiceConfig, error) {
if svcContext.CurrentContext == "" {
return nil, localizer.MustLocalizeError("context.common.error.notSet")
}
currCtx, ok := svcContext.Contexts[svcContext.CurrentContext]
if !ok {
return nil, localizer.MustLocalizeError("context.common.error.context.notFound", localize.NewEntry("Name", svcContext.CurrentContext))
const template = document.createElement('template');
template.innerHTML = `
<div>
Hello Weather App
</div>
`
class WeatherCard extends HTMLElement {
constructor() {
@rkpattnaik780
rkpattnaik780 / HelloWorld.vue
Created August 6, 2019 04:41
client/src/components/HelloWorld.vue
<template>
<div class="hello">
<a href="http://localhost:3000/auth/github">
<button>Sign-In With Github</button>
</a>
</div>
</template>
<script>
import axios from "axios";