Skip to content

Instantly share code, notes, and snippets.

View tadeankur's full-sized avatar

ANKUR TADE tadeankur

  • Gjensidige
  • Oslo
View GitHub Profile
@tadeankur
tadeankur / gist:966fc76ff34b61d234362b7457b1af36
Created December 12, 2022 11:00
Redis testing for hash
package test
import Employee
import HelseKey
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.beans.factory.getBean
import org.springframework.boot.CommandLineRunner
import org.springframework.boot.SpringApplication
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.context.ApplicationContext
@tadeankur
tadeankur / rediscacheconfig
Created December 12, 2022 10:59
Redis configuration
@Configuration
open class RadisCacheConfig {
@Bean
open fun jedisConnectionFactory(): JedisConnectionFactory {
val redisStandaloneConfiguration = RedisStandaloneConfiguration()
redisStandaloneConfiguration.hostName = "localhost"
redisStandaloneConfiguration.port = 6379
val jedisClientConfiguration = JedisClientConfiguration.builder()
fun fetchDeparturesAndLiveTimes(max: Int): List<DepartureWithLiveTime> = runBlocking{
timetableService.departures(max).map {
async(CoroutineName("${it.gate}") + Dispatchers.IO) {
println("#### ${coroutineContext[CoroutineName.Key]} is executing on thread : ${Thread.currentThread().name}")
val liveTime = try {
realTimeService.liveDepartureTime(it.id)
} catch (e: TimeoutException) {
null
@tadeankur
tadeankur / gist:9642aa5d6cda71148c1d8a6d2e452ff5
Created August 11, 2022 13:42
Data class in kotlin with lambda
data class Test(val name: String, val myfun: ( Int) -> Int )
val test = Test("Ankur", { i: Int -> i + 3 } )
println(test)
println(test.copy())
println(test.component1())
println(test.hashCode())
println(test.myfun(1))
@tadeankur
tadeankur / gist:6311dbcb66687da88a09ca8b4c006adf
Created February 14, 2022 11:23
Github actions code to cache the maven dependencies
jobs:
release:
runs-on: "ubuntu-latest"
steps:
- name: "Git checkout"
uses: "actions/checkout@v2"
- name: "Set up JDK 17"
uses: actions/setup-java@v2
with:
@tadeankur
tadeankur / gist:974f71bcedb0a54a2d6598e659c0ae09
Created February 17, 2021 07:59
ListSerializationTest : A program to show that jackson is unable to set the blank string while it receives null from the rest api
package no.nav.sbl.dialogarena.modiabrukerdialog.consumer.service.saker.mediation
import com.fasterxml.jackson.annotation.JsonSetter
import com.fasterxml.jackson.annotation.Nulls
import com.fasterxml.jackson.core.JsonParser
import com.fasterxml.jackson.core.JsonProcessingException
import com.fasterxml.jackson.databind.DeserializationContext
import com.fasterxml.jackson.databind.ObjectMapper
import com.fasterxml.jackson.databind.annotation.JsonDeserialize
import com.fasterxml.jackson.databind.deser.std.StdDeserializer
name: Build, push, and deploy Branch
on: [push]
env:
IMAGE: docker.pkg.github.com/${{ github.repository }}/<application-name>:${{ github.sha }}
TZ: Europe/Oslo
isDeploy: true
deploy_namespace: q0
@tadeankur
tadeankur / NonRepeatingCharacterFinder.java
Created October 20, 2020 19:12
NonRepeatingCharacterFinder
public class NonRepeatingCharacterFinder {
public static void main(String[] args) {
System.out.println("First Nonrepeating Charater is:" + findFirstNonRepeatingCharacter("aabcdb"));
System.out.println("First Nonrepeating Charater is:" + findFirstNonRepeatingCharacter("abcde"));
System.out.println("First Nonrepeating Charater is:" + findFirstNonRepeatingCharacter("aamzbccddb"));
System.out.println("First Nonrepeating Charater is:" + findFirstNonRepeatingCharacter("aammzzbcXssfdsfsasdfdfcddbG"));
}
@tadeankur
tadeankur / runexportscommand.sh
Last active June 9, 2020 07:28
Usage of ts-unused-exports to find unused exports in your ts.files
#!/bin/bash
filename=$1
while read line; do
# reading each line
echo $line
echo -----------------------------------------------------------------
./node_modules/.bin/ts-unused-exports tsconfig.json $line --showLineNumber
echo -----------------------------------------------------------------
done < $filename