Tuesday, March 4, 2025

Git commands for pushing large files.

 Install Git LFS:

  • Download and install Git LFS from the official Git LFS website (https://git-lfs.com/)
  • Navigate to repo->right click->git bash.
  • Write command git lfs track path of file
  • .gitattributes folder will be generated
  • Write command git add .gitattributes.
  • Write command git commit -m 'your commit message'
  • Write command git push

Friday, February 14, 2025

Google guice vs Picocontainer

 Here’s a code difference between Google Guice and PicoContainer to demonstrate their approach to Dependency Injection (DI).


1. Google Guice Example (Annotation-Based DI)

Steps:

  1. Define an interface and its implementation.
  2. Use @Inject to specify dependencies.
  3. Create a Guice module for binding.
  4. Use an injector to get an instance.
import com.google.inject.*;

// Step 1: Define an interface
interface Service {
    void serve();
}

// Step 2: Implement the interface
class MyService implements Service {
    public void serve() {
        System.out.println("Service is running...");
    }
}

// Step 3: Create a Guice module to bind the implementation
class MyModule extends AbstractModule {
    @Override
    protected void configure() {
        bind(Service.class).to(MyService.class);
    }
}

// Step 4: Inject the dependency using Guice
class Client {
    private final Service service;

    @Inject // Guice will automatically inject the dependency
    public Client(Service service) {
        this.service = service;
    }

    public void doSomething() {
        service.serve();
    }
}

// Step 5: Main method to run the code
public class GuiceExample {
    public static void main(String[] args) {
        Injector injector = Guice.createInjector(new MyModule());
        Client client = injector.getInstance(Client.class);
        client.doSomething();
    }
}

Key Points in Guice:

  • Uses annotations (@Inject) for injection.
  • Uses a module (AbstractModule) to define dependencies.
  • The injector (Guice.createInjector(...)) resolves dependencies at runtime.

2. PicoContainer Example (Constructor-Based DI, No Annotations)

Steps:

  1. Define an interface and its implementation.
  2. Use constructor injection to inject dependencies.
  3. Register classes in PicoContainer and retrieve instances.
import org.picocontainer.*;

interface Service {
    void serve();
}

class MyService implements Service {
    public void serve() {
        System.out.println("Service is running...");
    }
}

class Client {
    private final Service service;

    // No annotations, constructor injection only
    public Client(Service service) {
        this.service = service;
    }

    public void doSomething() {
        service.serve();
    }
}

public class PicoExample {
    public static void main(String[] args) {
        MutablePicoContainer pico = new DefaultPicoContainer();
        
        // Register dependencies
        pico.addComponent(Service.class, MyService.class);
        pico.addComponent(Client.class);

        // Retrieve the Client instance with dependencies injected
        Client client = pico.getComponent(Client.class);
        client.doSomething();
    }
}

Key Points in PicoContainer:

  • Uses constructor injection only (no @Inject annotation).
  • No separate binding module like Guice.
  • Dependencies are registered manually using pico.addComponent(...).

Code Difference Summary

Feature Google Guice PicoContainer
Configuration Uses modules (AbstractModule) Directly registers classes in the container
Injection Type Supports constructor, field, and method injection Constructor injection only
Annotations Uses @Inject for DI No annotations required
Binding Defined in a module using bind(...) Defined using pico.addComponent(...)
Dependency Resolution Uses Injector.getInstance(Class.class) Uses pico.getComponent(Class.class)
Scalability Suitable for large enterprise projects Suitable for small lightweight projects

Which One Should You Use?

  • Use Google Guice if you prefer annotation-based DI, scalable dependency management, and AOP support.
  • Use PicoContainer if you want a lightweight, constructor-based DI with minimal configuration.

Let me know if you need further clarification! 🚀

Picocontainer library in cucumber framework

 PicoContainer is a lightweight, open-source dependency injection container for Java. Like other dependency injection containers, PicoContainer helps manage the dependencies between components in your application. It allows you to define how different parts of your application are connected and then automatically resolves these dependencies at runtime.


With PicoContainer, you can define components (objects) and their dependencies, and then let the container handle the creation and wiring of these components. This makes your code more modular and easier to maintain, as you can change dependencies without modifying the classes themselves. PicoContainer is known for its simplicity and small footprint, making it suitable for small to medium-sized projects.


Certainly! Here's an example of how PicoContainer can be used with Selenium for dependency injection in a test automation scenario:


```java

import org.openqa.selenium.WebDriver;

import org.openqa.selenium.chrome.ChromeDriver;

import org.picocontainer.DefaultPicoContainer;

import org.picocontainer.MutablePicoContainer;


public class SeleniumTest {

    public static void main(String[] args) {

        MutablePicoContainer container = new DefaultPicoContainer();

        

        // Register WebDriver in the container

        container.addComponent(WebDriver.class, new ChromeDriver());

        

        // Register PageObject class

        container.addComponent(LoginPage.class);

        

        // Obtain an instance of the PageObject class from the container

        LoginPage loginPage = container.getComponent(LoginPage.class);

        

        // Use the PageObject in the test

        loginPage.open();

        loginPage.login("username", "password");

    }

}


class LoginPage {

    private WebDriver driver;

    

    public LoginPage(WebDriver driver) {

        this.driver = driver;

    }

    

    public void open() {

        driver.get("https://www.example.com/login");

    }

    

    public void login(String username, String password) {

        // Find and interact with login elements using the WebDriver

        driver.findElement(By.id("username")).sendKeys(username);

        driver.findElement(By.id("password")).sendKeys(password);

        driver.findElement(By.id("loginButton")).click();

    }

}

```


In this example, we are using PicoContainer to manage the WebDriver dependency in the `LoginPage` class. 

We register the WebDriver instance (in this case, a ChromeDriver) in the container, and then obtain an instance of the 

`LoginPage` class from the container. The `LoginPage` class depends on the WebDriver, and PicoContainer takes care of inje

cting this dependency when creating an instance of the `LoginPage` class. This approach promotes a cleaner and more maintainable

 codebase and allows for easy integration of the Selenium WebDriver with the Page Object pattern.

AI Tools for daily work

AI Tools for daily work


S.NO.

Tool

Uses

1.       

Aiease.ai

Free ai photo editor

 

2.       

Usestyle.ai

SEO

3.       

Lovo.ai

Voice

4.       

Numerous.ai

Excel

5.       

Dante.ai

Chatbots

6.       

Syllaby.io

Videos

7.       

10web.io

websites

8.       

1.      Decktopus.io, https://chatslide.ai/,

2.      Eraser.ai,

3.      Gamma.ai (this is amazing) ,

4.      https://app.pitch.com/ (this is amazing)

Slides, PPT

9.       

Rendernet.ai

Images

10.   

Questflow.ai

Automation

 

11.   

Vizard.ai

Vizard.ai is an AI-powered online video editor that helps users create social media videos from long-form videos. It uses AI to automatically identify engaging parts of a video and generate short clips. 

12.   

Vidyo.ai

Not free in India. Video to reel maker.

13.   

1.      Canva

2.      https://designer.microsoft.com

Image editing


Monday, June 13, 2022

Banking transactions terms in banking domain

 Banking transactions terms in banking domain

1. SEPA (Simplifying European Payment, IBAN is required for this).

2. SWIFT (International transfer)

3. BACS (A long-established UK Payment system Bacs stands for Banker’s Automated Clearing Services)

4. CHAPS (Clearing House Automated Payment System) - Same day UK payment (People usually use this for 10000+ British Pound transfer).



Sunday, February 14, 2021

Create a maven project in eclipse

1. Open eclipse tool->File->Other.







2. Click on Other->Select Maven->Click Next button.






3. Select the first checkbox (Skip archetype) What is an archetype






4. Enter Group id and Artificate id.





5. Your Maven project is created.








Saturday, January 2, 2021

Java 8 - Date and Time API

1. Get the Local Date 

package Java8;

import java.time.LocalDate;

public class DateTime {


public static void main(String[] args) {

dateTime dt = new dateTime();

LocalDate date = LocalDate.now();

LocalDate yesterday = date.minusDays(1);

LocalDate tomorrow = yesterday.plusDays(2);

System.out.println("Today date is : " + date);

System.out.println("Yesterday date is : " + yesterday);

System.out.println("Tomorrow date is: " + tomorrow);

}


}


output: 

Today date is: 2021-01-02

Yesterday date is: 2021-01-01

Tomorrow date is: 2021-01-03