Friday, 27 December 2024

List and change into diffrent shell.

list all shell in moc os

cat /etc/shells

print current shell 

echo $SHELL;

witch to bash shell

chsh  -s /bin/bash

then close your terminal and reopen it.


Monday, 23 December 2024

MVL rule engine

 https://medium.com/@er.rameshkatiyar/implement-your-own-rule-engine-java8-springboot-mvel-5928474e1ba5



Thursday, 19 December 2024

project code execution flow

 1 step .idl -> create method -> then genertae struct like resquest and response boady

2 step event file -> declare method name like ignore or full 

3 step then barrister will generate interface and resquest and response file in code base

4 step then implement interface method and write your own logic 

5 step then pack you logic response into barrister generated response payload

6 step excpetion-> exception handling using barrister

7 step write test cases 


Tuesday, 10 December 2024

JDBI JOIN example

 import org.jdbi.v3.core.Jdbi;

import org.jdbi.v3.core.handle.Handle;

import org.jdbi.v3.sqlobject.SqlObjectPlugin;

import java.math.BigDecimal;

import java.sql.Date;

import java.util.List;


public class Main {

    public static void main(String[] args) {

        // Create a Jdbi instance using your database connection

        Jdbi jdbi = Jdbi.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1");

        jdbi.installPlugin(new SqlObjectPlugin());


        // Use a handle to execute queries

        try (Handle handle = jdbi.open()) {

            // Create tables

            handle.execute("CREATE TABLE users (id INTEGER PRIMARY KEY, name VARCHAR)");

            handle.execute("CREATE TABLE orders (id INTEGER PRIMARY KEY, user_id INTEGER, order_date DATE, FOREIGN KEY (user_id) REFERENCES users(id))");

            handle.execute("CREATE TABLE products (id INTEGER PRIMARY KEY, name VARCHAR, price DECIMAL)");

            handle.execute("CREATE TABLE order_details (id INTEGER PRIMARY KEY, order_id INTEGER, product_id INTEGER, quantity INTEGER, FOREIGN KEY (order_id) REFERENCES orders(id), FOREIGN KEY (product_id) REFERENCES products(id))");


            // Insert test data

            handle.execute("INSERT INTO users (id, name) VALUES (1, 'John Doe')");

            handle.execute("INSERT INTO orders (id, user_id, order_date) VALUES (1, 1, '2023-01-01')");

            handle.execute("INSERT INTO products (id, name, price) VALUES (1, 'Product A', 10.0)");

            handle.execute("INSERT INTO order_details (id, order_id, product_id, quantity) VALUES (1, 1, 1, 2)");


            // Fetch order summaries

            String sql = "SELECT u.name AS userName, o.order_date AS orderDate, p.name AS productName, od.quantity " +

                         "FROM users u " +

                         "JOIN orders o ON u.id = o.user_id " +

                         "JOIN order_details od ON o.id = od.order_id " +

                         "JOIN products p ON od.product_id = p.id";


            List<OrderSummary> summaries = handle.createQuery(sql)

                .mapToBean(OrderSummary.class)

                .list();


            for (OrderSummary summary : summaries) {

                System.out.println("User: " + summary.getUserName() +

                                   ", Order Date: " + summary.getOrderDate() +

                                   ", Product: " + summary.getProductName() +

                                   ", Quantity: " + summary.getQuantity());

            }

        }

    }

}


Spring 4 tutorial

 https://www.dineshonjava.com/spring-4-tutorials-step-to-new-spring/

Bazel cheet set

 https://www.hackingnote.com/en/cheatsheets/bazel/


# Single target.
$ bazel build //go/util:util

# All targets under a directory and any subdirectoriews.
$ bazel build //go/...

# All targets in the repository.
$ bazel build //...

Monday, 9 December 2024

JDBI tutorial advance version of JDBC

 https://jdbi.org/

https://jdbi.org/jdbi2/

Barrister RPC

 http://barrister.bitmechanic.com/docs.html

Java program on string manipulation

 String name="pawanpawan";

Map<Character, Long> charCount=name.chars().mapToObj(c->(char)c).collect(Collectors.groupingBy( s-> s,Collectors.counting()));
System.out.println(name.chars().distinct().mapToObj(c-> (char)c).map(String::valueOf).collect(Collectors.joining()));
charCount.entrySet().stream().forEach(System.out::println);
Map<Character,Integer> characterCount = new HashMap<>();
for( Character ch:name.toCharArray()) {
System.out.println("ch"+ch);
if(characterCount.containsKey(ch)) {
System.out.println("ch"+ch);
characterCount.put(ch,characterCount.get(ch)+1);
} else{
characterCount.put(ch,1);
}
}
System.out.println("char count"+characterCount.toString());