Skip to content

Instantly share code, notes, and snippets.

View dineshbhagat's full-sized avatar
🌏 dev-engers assemble

DB dineshbhagat

🌏 dev-engers assemble
View GitHub Profile
MyServer.java
import com.sun.net.httpserver.Filter;
import com.sun.net.httpserver.Headers;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
import com.sun.net.httpserver.HttpHandlers;
import com.sun.net.httpserver.HttpServer;
@dineshbhagat
dineshbhagat / brin_btree_demo.md
Created October 24, 2022 03:20 — forked from dmagda/brin_btree_demo.md
A little demo for the BRIN vs. B-tree index in PostgreSQL

Reload application properties dynamically

import java.io.File
import java.util.*
import java.util.concurrent.TimeUnit
import mu.KLogging
import org.apache.commons.configuration2.FileBasedConfiguration
import org.apache.commons.configuration2.PropertiesConfiguration
  • Add driver class

        // https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client
      implementation group: 'org.mariadb.jdbc', name: 'mariadb-java-client', version: '2.7.3'
  • Mariadb installation Ref

@dineshbhagat
dineshbhagat / Steps to upgrade spring-boot 1.x to 2.x.md
Last active April 26, 2021 06:16
Steps to upgrade spring-boot 1.x to 2.x
  1. Upgrade gradle/maven wrapper, here gradle
    Ref
    Make sure execute this program on success build.

     ./gradlew wrapper --gradle-version 5.6.4  --distribution-type all  
  2. spring-boot-gradle-plugin changes,

  3. bootRepackage to bootJar or bootWar

@dineshbhagat
dineshbhagat / resilience4j Spring boot properties.md
Created September 10, 2020 13:04
Spring boot 2 properties for resilience4j
resilience4j.circuitbreaker.metrics.enabled=true
resilience4j.circuitbreaker.metrics.legacy.enabled=true

# following properties can be added for individual circuit breakers (CB-name is one of the circuit breaker, replace it)

resilience4j.circuitbreaker.instances.<CB-name>.sliding-window-type=TIME_BASED
resilience4j.circuitbreaker.instances.<CB-name>.sliding-window-size=100
resilience4j.circuitbreaker.instances.<CB-name>.minimum-number-of-calls=100
resilience4j.circuitbreaker.instances.<CB-name>.failure-rate-threshold=10
public class PascalTriangle {
// Ref: https://leetcode.com/submissions/detail/293484403/
// if you do not see "hello" as output in console, it means 2311 is prime number:
// Ref: https://www.youtube.com/watch?v=D7AHbyAlgIA&list=PL5KkMZvBpo5CdoOxa3dqll2n6KsXqerYO&index=11
// https://en.wikipedia.org/wiki/AKS_primality_test
public static void main(String[] args) throws Exception {
List<BigInteger> generate = generate(2311);
System.out.println(generate);
for (int i = 0; i < generate.size(); i++) {
@dineshbhagat
dineshbhagat / zigzag-encoding.README
Created November 9, 2019 06:55 — forked from mfuerstenau/zigzag-encoding.README
ZigZag encoding/decoding explained
ZigZag-Encoding
---------------
Maps negative values to positive values while going back and
forth (0 = 0, -1 = 1, 1 = 2, -2 = 3, 2 = 4, -3 = 5, 3 = 6 ...)
(i >> bitlength-1) ^ (i << 1)
with "i" being the number to be encoded, "^" being
XOR-operation and ">>" would be arithemtic shifting-operation
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.google.gson.JsonElement;
import com.google.gson.JsonPrimitive;
import com.google.gson.JsonSerializationContext;
import com.google.gson.JsonSerializer;
import com.google.gson.reflect.TypeToken;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
@dineshbhagat
dineshbhagat / configure-iterm2.sh
Last active June 21, 2023 17:50
Shell script to configure iterm2 with oh-my-z, nerd font, powerlevel10k
brew install zsh;
sh -c "$(curl -fsSL https://raw.github.com/robbyrussell/oh-my-zsh/master/tools/install.sh)";
cd $ZSH/custom/plugins;
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git && git clone https://github.com/zsh-users/zsh-autosuggestions && git clone https://github.com/zsh-users/zsh-completions;
# from now on your default shell is zsh, customize by editing ~/.zshrc file
brew tap homebrew/cask-fonts;
brew install --cask font-hack-nerd-font;
brew install coreutils
cd ~/Desktop;