❌

Reading view

There are new articles available, click to refresh the page.

Password Validator

import java.util.Scanner;

public class PasswordValidator {

	public static void main(String[] args) {
		// PASSWORD MUST CONTAIN MIN 8 CHARS, MAX 12 CHARS, ATLEAST 1 UPPERCASE, 1 LOWERCASE, 1 DIGIT, 1 SPL CHAR 
		Scanner scn = new Scanner(System.in);
		int maxLen = 12, minLen=8;
		System.out.println("Enter a password to validate");
		String pwd = scn.next();
		scn.close();
		int n = pwd.length();
		if (n<minLen || n>maxLen) {
			System.out.println("Password length must be between 8 to 12 characters");
			return;
		}
		char[] pw = pwd.toCharArray();
		int cntLower=0, cntUpper=0, cntDigit=0, cntSpl=0;
		for (int i=0; i<n; i++) {
			char ch = pw[i];
			if (ch>='A' && ch<='Z') cntUpper++;
			else if (ch>='a' && ch<='z') cntLower++;
			else if (ch>='1' && ch<='9') cntDigit++;
			else if (ch=='!' || ch=='Β£' || ch=='$' || ch=='%' || ch=='^' || ch=='&' || ch=='*' || ch=='-' || ch=='_' || ch=='+' || ch=='=' || ch==':' || ch==';' || ch=='@'|| ch=='#'|| ch=='~'|| ch=='>'|| ch=='<'|| ch=='?'|| ch=='.') cntSpl++; 
		}
		if (cntLower>0 && cntUpper>0 && cntDigit>0  && cntSpl>0) System.out.println("Password is valid...");
		else {
			System.out.println("Password is NOT VALID");
			System.out.println("PASSWORD MUST CONTAIN ATLEAST 1 UPPERCASE, 1 LOWERCASE, 1 DIGIT AND 1 SPL CHAR FROM ! Β£ $ % ^ & * - _ + = : ; @ ~ # ?");
		}
	}

}

Git

Git is a powerful version control system which used to manage the code across multiple users and track changes across different versions.

Installation:

Download and install GIT from the below path

https://git-scm.com/download/win

Once installed, Git can be used as a version control system through various commands.
You can configure Git for a specific folder on your computer, allowing you to manage all changes to existing files and the addition of new files within that folder

Basic commands:

1. git init:

This will initialize new repository in the current directory. This also creates .git directory and store all version control information.

2. git config:
git config --global user.name "Ranjith "
git config --global user.mail "ranjith201099@gmail.com"
3. git status

Shows the current status of working area like staged, untracked and unstaged.

4. git add

add changes from working directory to the staging area, preparing them to commit.

To add specific file: git add "filename.py"
To add all changes git add .
5. git commit
git commit -m "<message>"

Commits the staged changes with descriptive mesage

6. git log

Displays the list of commit history for the repository.
It will show commit id, author, dates and commit changes
Creating a branch

git branch <branch_name> - to create branch
git checkout <branch_name> - to switch to the new branch
git branch -b <branch_name> 

to create and switch to branch
git branch - to view all the branches (current branch will be highlighted with asterisk)

Merge a branch:

Once completed work on a branch and want to integrate it into another branch (like master), merging comes to place.

It means all the changes we have made in <branch_name> will be merged with master branch.
First, switch to the branch you want to merge into: git checkout master
Then, use git merge <branch_name> to merge your branch.
Deleting branch
Once the code changes in <branch_name> merged into <master> branch, we might need to delete branch.
use git branch -d <branch_name> to delete branch

Image description

Image description

Lucifer and the Git-Powered Calculator: The Complete Adventure

In losangels , a young coder named Lucifer set out on a mission to build his very own calculator. Along the way, he learned how to use Git, a powerful tool that would help him track his progress and manage his code. Here’s the complete story of how Lucifer built his calculator, step by step, with the power of Git.

Step 1: Setting Up the Project with git init

Lucifer started by creating a new directory for his project and initializing a Git repository. This was like setting up a magical vault to store all his coding adventures.


mkdir MagicCalculator
cd MagicCalculator
git init

This command created the .git directory inside the MagicCalculator folder, where Git would keep track of everything.

Step 2: Configuring His Identity with git config

Before getting too far, Lucifer needed to make sure Git knew who he was. He configured his username and email address, so every change he made would be recorded in his name.


git config --global user.name "Lucifer"
git config --global user.email "lucifer@codeville.com"

Step 3: Writing the Addition Function and Staging It with git add

Lucifer began his calculator project by writing a simple function to add two numbers. He created a new Python file named main.py and added the following code,


# main.py

def add(x, y):
    return x + y

# Simple test to ensure it's working
print(add(5, 3))  # Output should be 8

Happy with his progress, Lucifer used the git add command to stage his changes. This was like preparing the code to be saved in Git’s memory.


git add main.py

Step 4: Committing the First Version with git commit

Next, Lucifer made his first commit. This saved the current state of his project, along with a message describing what he had done.


git commit -m "Added addition function"

Now, Git had recorded the addition function as the first chapter in the history of Lucifer’s project.

Step 5: Adding More Functions and Committing Them

Lucifer continued to add more functions to his calculator. First, he added subtraction,


# main.py

def add(x, y):
    return x + y

def subtract(x, y):
    return x - y

# Simple tests
print(add(5, 3))       # Output: 8
print(subtract(5, 3))  # Output: 2

He then staged and committed the subtraction function,


git add main.py
git commit -m "Added subtraction function"

Lucifer added multiplication and division next,


# main.py

def add(x, y):
    return x + y

def subtract(x, y):
    return x - y

def multiply(x, y):
    return x * y

def divide(x, y):
    if y != 0:
        return x / y
    else:
        return "Cannot divide by zero!"

# Simple tests
print(add(5, 3))       # Output: 8
print(subtract(5, 3))  # Output: 2
print(multiply(5, 3))  # Output: 15
print(divide(5, 3))    # Output: 1.666...
print(divide(5, 0))    # Output: Cannot divide by zero!

Again, he staged and committed these changes,


git add main.py
git commit -m "Added multiplication and division functions"

Step 6: Branching Out with git branch and git checkout

Lucifer had an idea to add a feature that would let users choose which operation to perform. However, he didn’t want to risk breaking his existing code. So, he created a new branch to work on this feature.


git branch operation-choice
git checkout operation-choice

Now on the operation-choice branch, Lucifer wrote the code to let users select an operation,


# main.py

def add(x, y):
    return x + y

def subtract(x, y):
    return x - y

def multiply(x, y):
    return x * y

def divide(x, y):
    if y != 0:
        return x / y
    else:
        return "Cannot divide by zero!"

def calculator():
    print("Select operation:")
    print("1. Add")
    print("2. Subtract")
    print("3. Multiply")
    print("4. Divide")

    choice = input("Enter choice (1/2/3/4): ")

    num1 = float(input("Enter first number: "))
    num2 = float(input("Enter second number: "))

    if choice == '1':
        print(f"{num1} + {num2} = {add(num1, num2)}")

    elif choice == '2':
        print(f"{num1} - {num2} = {subtract(num1, num2)}")

    elif choice == '3':
        print(f"{num1} * {num2} = {multiply(num1, num2)}")

    elif choice == '4':
        print(f"{num1} / {num2} = {divide(num1, num2)}")

    else:
        print("Invalid input")

# Run the calculator
calculator()

Step 7: Merging the Feature into the Main Branch

After testing his new feature and making sure it worked, Lucifer was ready to merge it back into the main branch. He switched back to the main branch and merged the changes


git checkout main
git merge operation-choice

With this, the feature was successfully added to his calculator project.

Conclusion: Lucifer’s Git-Powered Calculator

By the end of his adventure, Lucifer had built a fully functional calculator and learned how to use Git to manage his code. His calculator could add, subtract, multiply, and divide, and even let users choose which operation to perform.

Thanks to Git, Lucifer’s project was well-organized, and he had a complete history of all the changes he made. He knew that if he ever needed to revisit an old version or experiment with new features, Git would be there to help.

Lucifer’s calculator project was a success, and with his newfound Git skills, he felt ready to take on even bigger challenges in the future.

GIT - Basics

GIT is a powerful version control system which used to manage the code across multiple users and track changes across different versions.

Installation:

Download and install GIT from the below path
https://git-scm.com/download/win

  • Once installed, Git can be used as a version control system through various commands.
  • You can configure Git for a specific folder on your computer, allowing you to manage all changes to existing files and the addition of new files within that folder

Basic commands:

1. git init:

This will initialize new repository in the current directory. This also creates .git directory and store all version control information.

2. git config:
git config --global user.name "Suresh"
git config --global user.mail "Suresh.Sundararaju@gmail.com"

3. git status
Shows the current status of working area like staged, untracked and unstaged.

4. git add
add changes from working directory to the staging area, preparing them to commit.

  • To add specific file: git add "filename.py"
  • To add all changes git add .

5. git commit

  • git commit -m "<message>"
  • Commits the staged changes with descriptive mesage

6. git log

  • Displays the list of commit history for the repository.
  • It will show commit id, author, dates and commit changes

Creating a branch

  • git branch <branch_name> - to create branch
  • git checkout <branch_name> - to switch to the new branch
  • git branch -b <branch_name> - to create and switch to branch
  • git branch - to view all the branches (current branch will be highlighted with asterisk)

Merge a branch:
Once completed work on a branch and want to integrate it into another branch (like master), merging comes to place.

  • It means all the changes we have made in <branch_name> will be merged with master branch.
  • First, switch to the branch you want to merge into: git checkout master
  • Then, use git merge <branch_name> to merge your branch.

Deleting branch
Once the code changes in <branch_name> merged into <master> branch, we might need to delete branch.

  • use git branch -d <branch_name> to delete branch

import Project from Github to Eclipse

Click Next and Next Accept the license and click finish to complete installation. click file menu and chose import option select Git option and choose Project from GitHub and select clone URL Open your github project and copy the .git url paste below URL into that URL click next and next then click finish to […]

Types of Version Control System

version control system tracks changes to a file or set of files over time. There are three types of version control system: Local Version Control Systems: Centralized Version Control Systems: Distributed Version Control Systems: Popular version control systems and tools Here’s a brief overview of some commonly used version control tools and their pros and […]

Git Commands

  • git clone
  • git add
  • git commit
  • git push
  • git pull
  • git branch
  • git checkout
  • git status

git clone remote

to create new repository in github cloud , then create a local repo and clone 2 repositories using git clone remote (repo link).

git add filename
git add .

to add a single file using git add and add all the files which present in the current repo the use git add . | . represent add all the files.

git commit -m "message"

commit the added file using git commit and put some mesagges about the file using -m ” ” .

some ideas of commit messages are available in below mentioned link.

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

git rm --cached filename
if incase want to remove the added file use git remove
git rm --cached -f filename
-f --> forcefully remove the file.
git push

push the commited file from the local to cloud repo using git push. it will push the file to remote repository.

git pull 

when u need to change or edit or modify the remote file first you will pull the file to local repository from remote using git pull.

git branch 
Branch means where will you store the files in git remote.git branch is to specify the branch name it will push the file to current remote branch.

git checkout -b "branchname"
to create a new branch.

git checkout branchname
check the created branch or new branch

git branch -M branchname
to modify or change the branch name

git branch -a
to listout all branches.
git status
check all the status of previously used command like know the added file is staged or unstaged

Reference : https://www.markdownguide.org/cheat-sheet/

markdown cheathseet for readme file

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

for commit messages.

Git Commands

  • git clone
  • git add
  • git commit
  • git push
  • git pull
  • git branch
  • git checkout
  • git status

git clone remote

to create new repository in github cloud , then create a local repo and clone 2 repositories using git clone remote (repo link).

git add filename
git add .

to add a single file using git add and add all the files which present in the current repo the use git add . | . represent add all the files.

git commit -m "message"

commit the added file using git commit and put some mesagges about the file using -m ” ” .

some ideas of commit messages are available in below mentioned link.

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

git rm --cached filename
if incase want to remove the added file use git remove
git rm --cached -f filename
-f --> forcefully remove the file.
git push

push the commited file from the local to cloud repo using git push. it will push the file to remote repository.

git pull 

when u need to change or edit or modify the remote file first you will pull the file to local repository from remote using git pull.

git branch 
Branch means where will you store the files in git remote.git branch is to specify the branch name it will push the file to current remote branch.

git checkout -b "branchname"
to create a new branch.

git checkout branchname
check the created branch or new branch

git branch -M branchname
to modify or change the branch name

git branch -a
to listout all branches.
git status
check all the status of previously used command like know the added file is staged or unstaged

Reference : https://www.markdownguide.org/cheat-sheet/

markdown cheathseet for readme file

Reference : conventional commit.org | https://www.conventionalcommits.org/en/v1.0.0/

for commit messages.

GitHub, Git & Jenkins

Github:

It allows collaboration with any developer all over the world. Open Source solutions enable potential developer to contribute and share the knowledge to benefit the Global Community. At a high level, GitHub is a website and cloud-based service that helps developers store and manage their code, as well as track and control changes to their code. To understand exactly what GitHub is, you need to know two connected principles:

  • Version control
  • Git

What Is Version Control?

Version control helps developers track and manage changes to a software project’s code. As a software project grows, version control becomes essential. Take WordPress…

At this point, WordPress is a pretty big project. If a core developer wanted to work on one specific part of the WordPress codebase, it wouldn’t be safe or efficient to have them directly edit the β€œofficial” source code.

Instead, version control lets developers safely work throughΒ branchingΒ andΒ merging.

WithΒ branching, a developer duplicates part of the source code (called theΒ repository). The developer can then safely make changes to that part of the code without affecting the rest of the project.

Then, once the developer gets his or her part of the code working properly, he or she canΒ mergeΒ that code back into the main source code to make it official.

What Is Git?

Git is aΒ specific open-source version control systemΒ created by Linus Torvalds in 2005.It is used for coordinating work among several people on a project and track progress over time. It is used for source code management for software development.

GitHub is a Git repository hosting service which provides a web-based graphical interface that helps every team member to work together on the project from anywhere and makes it easy to collaborate.

Jenkins

Jenkins isΒ a Java-based open-source automation platform with plugins designed for continuous integration.

It helps automate the parts of software development related to building, testing, and deploying, facilitating continuous integration, and continuous delivery, making it easier for developers and DevOps engineers to integrate changes to the project and for consumers to get a new build. It is a server-based system that runs in servlet containers such as Apache Tomcat.

Git vs Jenkins: What are the differences?

Git and Jenkins are both popular tools, Git is a distributed version control system and Jenkins is a continuous integration and automation tool. Let’s explore the key differences between the two:

  1. Code Management vs. Automated Builds: Git is primarily used for code management and version control. It allows developers to track changes, collaborate on code, and handle code branching and merging efficiently. On the other hand, Jenkins focuses on automated builds, testing, and deployment. It helps in integrating code changes from multiple team members and automates the build process, including compiling, testing, and packaging the software.
  2. Local vs. Remote: Git operates locally on the developer’s machine, allowing them to work offline and commit changes to their local repository. Developers can then push their changes to a remote repository, facilitating collaboration with other team members. In contrast, Jenkins is a remote tool that runs on a dedicated server or cloud platform. It continuously monitors the code repository and triggers automated builds or tests based on predefined conditions or schedules.
  3. Version Control vs. Continuous Integration: Git’s primary focus is on version control, tracking changes to files and directories over time. It provides features like branching, merging, and resolving conflicts to manage code versions effectively. Jenkins, on the other hand, emphasizes continuous integration (CI), which involves frequently integrating code changes from multiple developers into a shared repository. Jenkins automatically builds and tests the integrated code, highlighting any conflicts or issues that arise during the process.
  4. User Interface: Git primarily relies on a command-line interface (CLI) for executing various operations. However, there are also graphical user interface (GUI) clients available for more user-friendly interactions. Jenkins, on the other hand, provides a web-based graphical user interface that allows users to configure and manage Jenkins jobs, view build reports, and monitor the status of automated builds and tests.
  5. Plugin Ecosystem: Git has an extensive ecosystem of third-party plugins that extend its functionality and integrations with other development tools. These plugins cover various areas, including code review, issue tracking, and build automation. Jenkins, being an automation tool, has a rich plugin ecosystem as well. These plugins enable users to integrate Jenkins with different build tools, testing frameworks, version control systems, and deployment platforms, enhancing its capabilities and flexibility.
  6. Ease of Use: Git can have a steep learning curve for beginners, particularly when it comes to understanding concepts like branching, merging, and resolving conflicts. However, once users become familiar with its core functionality, it provides a powerful and flexible version control system. Jenkins, on the other hand, aims to simplify the CI process and provide an intuitive user interface for managing builds and automation. While some initial setup and configuration may be required, Jenkins offers ease of use in terms of managing continuous integration workflows.

In summary, Git focuses on code management and version control, while Jenkins specializes in continuous integration and automation. Git operates locally, while Jenkins runs remotely on dedicated servers. Git’s primary interface is command-line-based, with additional GUI clients available, whereas Jenkins offers a web-based graphical user interface. Both Git and Jenkins have plugin ecosystems that extend their functionality, but Jenkins prioritizes automation-related integrations. Finally, while Git has a steeper learning curve, Jenkins aims to provide ease of use in managing continuous integration workflows.

Source: https://stackshare.io/stackups/git-vs-jenkins#:~:text=Git%20operates%20locally%2C%20while%20Jenkins,web%2Dbased%20graphical%20user%20interface.

Github Configuration Commands

sudo apt update git
sudo apt install git
git --version
git config --global user.name "Muthukumark98"
git config --global user.email "muthukumar1998mk98@gmail.com"
git config --list
pwd
mkdir workspace
cd workspace/
git clone https://github.com/Muthukumark98/hello_test.git
ls
cd hello_test/
touch hello.py
ls
cat README.md 
ls
vim hello.py
cat hello.py
git status
git add hello.py
git status
git commit -m "first python code"
git status
git push origin main
git remote set-url origin https://<token>/<username>/<repo>
git push origin main
❌