Tuesday, August 31, 2021

Day1 - Docker - Introduction to docker

 Docker is very light weight mini os which does not include kernel. It is good for developers and sysadmins to build, ship and run the distributed application. 
Containerization::
- It is not a new concept. There were jail, zomes, containers, LDOMs,, LXC - linux containers
but all of these virtualization technologies could not do optimim job. 
Docker took over. Its a client/server model. First release in 2013.
Advantage of docker::
- Reduce the size of dev env with the help of small os foot print
  Centos/ubuntu
VM os size     4 GB
Container size  200MB(appx)
- Docker does not need kernel, it gets all support from host os.
- You can develop on one platform and deploy on any platform
- Container/dockers are very light weight
Docker os is called docker images
- very lighweight os and easy to deploy

Lets contair the VMs
Guest VM | Guest VM        c1|c2|c3|c4  -> Containers - container contains some binary/library
Virtualization layer Host OS + Docker Service
Host OS HW
Hardware

You can develop your app -> create your image -> upload to repo -> install (pull) and start using it
- Install on windows/linux/Mac. It just works on any env.
- You generate project image (tomcat, ubuntu, centos)
 For docker imatallation, you can follow the link below
https://get.docker.com/
To install on windows, docker for windows
You can use cloud env link gcp/aws
just follow the installation steps
$ sudo usermod -aG docker jay
$ sudo systemctl start docker
$ sudo systemctl enable docker
$ docker version

Docker works on concepts of image.
Docker registry -> Where docker images are stored/present
hub.docker.com -> docker HUB
You can have public/private registry (repo)
- company info may go private.
search -> centos and look for official
search for apache, java, ubuntu, nginx
these are pre-configured images.
To download the image
$ docker pull centos
check available images
$ docker info -> shows everything . Check the output line by line.
image - pre-configure class (group of objects)
container - is like os and it has application.
How to run container
1. Interactive (it) mode 
2. Detach (dt) mode
Running container in interactive mode
$ docker ps
$ docker run -it centos bash
it -> interactive
centos - name of image
bash - shell it will load
when you run the command, you will be on centos bash prompt.
# cat /etc/os-release
Now, lets try something interesting
$ linux1
$ docker images  -> lists images
look at the output carefully
- check the size, its so light
every image has container ID.
$ exit
you docker stops. 
$ docker ps -> you will see no container running
This is an interactive mode where container dies when you exit out.

Lets run an docker instance
$ docker run -it centos bash
open a new instance of host os and run
$ docker ps -> you will see continer still running
run the top command on both host and container.
you will see lots of processes on host but very few on container.
now, exit out from container, and run
$ docker ps ->  no container is running
$ docker ps -a -> you will see the history
2. Running docker in detach mode
$ docker run -dt centos bash
-dt -> detach mode
you will still on host command prompt, docker is running on the background
$ docker ps -> you will see the instance running
How to loign to docker
$ docker exec -it bash
look at the error message
$ docker exec -it <container id> bash
you will get container id from docker ps command output
you exit out of docker. it is still running. 
if you want to stop, you have to stop manually
$ docker ps
$ docker --help -> search for how to stop
$ docker container stop <container ID>
The beauty of docker is that you can ship your application fast and 
docker starts in seconds.
docker is infact a process. 
HW: download image/install some container such as apache/tomcat/nginx/java/jinkins or more ..

Saturday, August 21, 2021

Day3 - Object Oriented Programming in Python

 Day3 - Object Oriented Programming in Python 
8/21/2021

What is behavior?
-> Behavior represent functionality (functionality is a logic)
We can define following behavior in python
1. Constructor
2. Method

What is method?
- a behavior which represent some functionality will execute whenever programmer will call is called method
for eg, c1.m1 or c1.m2
here, m1 and m2 methods are calling

Types of method 
There are two types of methods
1. Instance method
2. Static method

Instance method
- A method which is taking 'self' keyword as first parameter is called instance method
- Instance method address will be available within the object. Due to this reason, instance method we have to access by using the object.
Some questions you can create from above statement
- What is method?
- What keyword do you use as a first parameter?
- How do you access instance method address?

<Syntax to define instance method>
- To define a method or construct in python, we should prefix 'def' keyword.
def <methodname(Self)>
  <logic>
Example to define instance method
def MyFun(Self):
   print("MyFun is calling")
<SYNTAX to invoke instance method>
<objectname>.<instance methodname()>
eg, 
obj.MyFun()
here, obj is object name and
MyFun method name
What is an object?
- An object is an instance of a class
car is a class
  - your car is an object of class car
  - my car is an object of class car
pem is a class
   - your pen is an object
   - my pen is an object
Human is class
   - Ram is an object
   - Sam is an object of human class
instance is a physical representation
so, class is a logical representation
object is a physical representation of class

What an object contains?
-> An object contains instance variables and address addresses of the instance method.
<SYNTAX to create object>
<ObjectName>=<ClassName()>
for eg,
obj=MyClass()
eg,
class MyClass():
   def MyFun(self):
      print("MyFun is calling ..")
obj=MyClass()
obj.MyFun()


Thursday, August 19, 2021

Day2 - Object oriented programming in Python

 Day2 - Object oriented programming in Python
OOP principles
1. Encapsulation
2. Abstraction
3. Polymorphysm
3. Inheritance
Reading concept
1. Read the book and write notes
2. Record what you learn on your phone
3. Prepare all the questions from the book you read
4. Write the answer to the question
5. Select the best question and take a test without a book.
What is class?
- Class is a collection of states and behaviors
to define a class, we have to use class keyword. 
<syntax>
class <classname>
  <states>
  <behaviours>
First understand the state. What is state?
-> State represents some value. State can be variable or constant.
Types of variables in python
There are 3 types of variables in python
1. Local variable
2. Instance variable
3. State variable
What is a local variable?
-> a variable which is declared inside the method (or function) is called local variable
-> local variable can access only within the method or function.
-> Local variable will be getting memory at the time of method execution.
-> Local variable will be destroyed once method execution is completed.

Create some question based on above definition.
1. What is local variable?
2. What is the scope of local variable?
3. How memory is allocated for local variable?
4. How memory is de-allocated?
Reading tips
Think how many questions can you create on the topic above?
2. Instance variable
-> A variable which is declared inside the constructor or inside the instance method by using self keywork is instance variable.
- Instalce variable gets the memory within the object 
- 'self' is a keyword which represent current class object
- Intance variable will be getting memory at the time of object is creating.
- Instance variable will destroyed once the object is destroyed.
Questions?
1. What is instance variable?
2. How instance variable gets the memory?
3. What keyword is used in instance variable?
4. When instance variable is de-allocated or destroyed?
What is static variable?
static/dynamic coding ..
i and j 
i=j; i<j; i>j ; multiple if, else if, nested if
decision/control statement
A variable which is declared inside the class or inside the static method by prefixing classname is static variable.
Q. When the static variable will be getting memory?
- at the time of class is loading
Q. When the static variable will be destroyed or de-allocated memory?
- At the time of class is unloading
Example to declare instance variable
self.a=10
MyClass.b = 20
Here,
name of the class is: MyClass
b is: name of variable
20 is: the value assigned to a variable
as we know, class is collection of state and behaviour. We just discussed about state, now we will discuss about behaviour.
What is behaviour?
- Next class
Reading, writing and implementing tacktics
1. Read the book first topicwise and write the notes on each topic
2. After completing reading and taking notes, close your book and write on a paper without looking at the book.
3. Now, record what you learn on your mobile phone topic wise without looking at the book.
4. Prepare questions and answer of the topic by looking at the book.
5. Now, prepare fews questons by summarizing your old questions
6. Write your answer and record the question and answer.



Wednesday, August 18, 2021

Day1 - Object oriented programming in Python

 8/18/2021
Day1 - Object oriented programming in Python
When you are learning something, learn like a child.
When you are working, work like a professional.
Programming language approach
1. Procedural
2. Object oriented
Procedural oriented programming approach
- In procedural oriented programming approach, program (solution) is a collection of function, or method or, procedure. (Block which represent some logic)
Structure of procedural oriented programming
m1() # Method definition
  {
    logic # some logic
  }
m2() # define m2 method
  {
    logic     # some logic
  }
main() # Main method
 {
   m1
   m2
  }
In this program we have three methods: m1, m2 and main methods. 
We have 50 sits and one driver sit. 
driver is a main method. main method controls the program the way driver controls the bus.
In above program
- First program execution starts from main method
- Second, it reads the m1 method and control goes to look for m1 method and when it finds, it executes it
- 3rd, it reads m2 and control goes to look for m2 method and reads the logic and executes the block of code.
A programming language which follows the above programming approach is a procedural oriented programming language.
Due to some limitation of this approach, industry experts are intruducing a new programming approach which is called object oriented programming approach.
Object Oriented programming approach (OOP)
-> In OOP approach, the program is a collection of classes. A programming language that follows above programming approach is an object oriented programming language.
Structure of OOP approach
class c1 # definition of class
{
  m1() # definition of mdule
     {
        logic
     }
   m2() # definition
     {
         logic
     }
}
class c2
{
  main() # definition of main method. programming execution control by main method
  {
    c1.m1 # calling
    c1.m2
  }
}

Program execution starts from main method. After that control checks c1.m1 and start look for c1 and m1 and executes when it finds it
after that control goes to c1.m2. It start looking for c1 cladd and go to m2. once it reads, it executes. 
when control reaches the closing braces, program terminates. This kind of programming approach is called OOP. languages
Some of them are c++, JAVA, C#.net
What about python?
- python is procedural as well as oop.
function, method -> procedural
class - oop
m1() # function, method
{
}
m2()
{
}
class c1 # class
{
 m3()
  {
  }
}

OOPS methods
Every OOP language follows 4 principles
1. Encapsulation
2. Abstraction
3. Polymorphism
4. Inheratence
To achieve all 4 princliples, every object oriented programming language has to follow the 2 object orientted concepts below.
1. class
2. object
What is object?

Friday, August 13, 2021

links

 https://rhtapps.redhat.com/promo/course/do007?segment=3
https://www.youtube.com/watch?v=dadKFIEJQbc&list=PL55uMtDpag8psxkSr3PrK6Jx0G7EfCRYw&index=7
https://www.udemy.com/course/git-github-crash-course/learn/lecture/25672800#overview
https://www.youtube.com/watch?v=sNDs6AoNmA8
https://www.udemy.com/course/automate/learn/lecture/3465796#overview
https://www.udemy.com/course/mastering-git-for-beginners-and-experts/learn/lecture/26290392#overview
https://drive.google.com/file/d/1mi4WjUWQ1AqB1LM_RThwQ0-FEz5u9xhr/view



Thursday, August 12, 2021

Ansible for begginers

 Ansible for begginers
- Ansible introduction and setup
- Playbooks, modules
- Inventory and Variables
- Roles, loops & benefits
- Troubleshooting

Module1: Introduction to Ansible
1. What will you learn in this course?
2. Introduction to ansible automation.
3. Why ansible?
4. Ansible features
5. Why should we automate?
Lab: Instal and set up ansible

Module2: Ansible inventory and ad-hoc commands
1. Ansible inventory
2. Host patterns
3. Ansible Ad-Hoc commands
LAB: Create inventory file and running ad-hoc commands

Module3: Ansible playbook, modules and priviledge escalation
1. Ansible play, playbook
2. Ansible modules
3. Ansible roles



manchhe ko kuro

 दर्द को भी अब दर्द होने लगा है,
दर्द ही आपके घाव धोने लगा है,
दर्द के साथ कभी रोए आप
अब दर्द आपको छू कर रोने लगा है।


नारी नहीं बेचारी इसके सब्र का बांध ना तोड़ो !
दुर्गा बन प्रतिशोध ये लेगी अबला ka भ्र्म छोडो !
     नारी शक्ति की सुपरहिट कविता

मैंने डर को डरते देखा है,
मैने मौत को मरते देखा है,
दिल में उम्मीद जिंदा रख ये मेरे दोस्त,
मैने अन्धों को पढ़ते देखा है।


ख्वाब टूटे हैं मगर हौंसले ज़िंदा हैं।
हम वो हैं जहां मुश्किलें शर्मिंदा हैं।।

21वीं सदी के स्वावलंबी ,स्वाभिमानी भारतीय नारी को सलाम🙏🙏
सक्षम बनो और आगे बढ़ो,जय हिंद

Tuesday, August 3, 2021

X11 Forwarding through SSH using PuTTy

 


1. Open putty
2. Click on connection under Category on the left pane
3. Expand SSH and click on X11
4. Click on check box next to Enable X11 forwarding
5. Go to the session and enter the hostname and also type host name under saved Session
6. Click Save and click on open
7. Enter your username and Passwd
8. Run echo "DISPLAY" and see if your display is exported.
Note: If not, run your X Server (MobaX term comes with X server)
9. Type xhost or any GUI program to load your application on GUI.

Git branch show detached HEAD

  Git branch show detached HEAD 1. List your branch $ git branch * (HEAD detached at f219e03)   00 2. Run re-set hard $ git reset --hard 3. ...