# my net house

WAHEGURU….!

## Category Archives: Enlightenment

## Some more Aspects Kubernetes!!

May 7, 2021

Posted by on - RepicationControler: it is “kind” of kubernetes which is responsible to take care about number of replications to use for service, container-image, Container-port, Service-name
- Service: It is responsible to make your Custer talk to outside world, It could be loadBalance, or Proxy service.

Now something a little more about Networking!!

- Cluster_IP-> it is the most basic type of service, An IP is assigned to service so Other services Could use this Service. Outside word can talk to your POD but wil have to go through some sort of PROXY!!
- TargetPort-> It allows you to separate the port from where you want to expose your service and where it is actually running inside container!!
- Nodeport-> it’s bit special and coulb be little scary as well but just hang-tight, nodeport makes service available to each node via statis port, so assume ou have three nodes, IP1, IP2, IP3 each are having same service running inside, You will assign some port number say 8081 and each node will be accessible on same port using Node’s IP and port. something like:

IP1:8081, IP2:8081, IP3:8081

4. ExternalIP: Another approach to making a service available outside of the cluster is via External IP addresses.

5. LoadBalancer: When running in the cloud, such as EC2 or Azure, it’s possible to configure and assign a Public IP address issued via the cloud provider. This will be issued via a Load Balancer such as ELB. This allows additional public IP addresses to be allocated to a Kubernetes cluster without interacting directly with the cloud provider.

For more one can follow following POST on linkedin!

`https://www.linkedin.com/posts/dr-rabi-prasad-padhy-%E2%98%81%E2%98%81%E2%98%81-396804110_service-types-in-kubernetes-when-we-are-activity-6796285869864169472-gXF1`

## Understanding YAML in-Depth!!

April 30, 2021

Posted by on Basically there are three parts of Every YAML file.

- MetaData(we define it)
- spec (specifications) (we define that too)
- state(that depennds on kubernetes brain!! which is “etcd!”)

rest is version and kind, version define which API version we are going to use and kind defines the type of deployment or POD we are going to implement here/!!

When you use the Kubernetes API to create the object (either directly or via `kubectl`

), that API request must include that information as JSON in the request body. **Most often, you provide the information to kubectl in a .yaml file.**

`kubectl`

converts the information to JSON when making the API request.Source: https://kubernetes.io/docs/concepts/overview/working-with-objects/kubernetes-objects/

Metadata: It helps uniquely to understand an object, in

cluding a `name`

string, `UID`

, and optional `namespace`

`spec`

– What state you desire for the object

to be continued –> https://cloudplex.io/tutorial/how-to-write-yaml-files-for-kubernetes/

## Kubernetes Basics(pods creation and understanding)

April 29, 2021

Posted by on Create a Cluster Using MiniKube:

https://minikube.sigs.k8s.io/docs/start/

start your Cluster:

`$ minikube start # start your Kubernetes cluster`

`$ kubectl get po -A # get list of all pods and your cluster. `

Get to know your cluster.

(base) khangura@metal-machine:~$ kubectl get po -A

NAMESPACE NAME READY STATUS RESTARTS AGE

kube-system coredns-74ff55c5b-zxngm 1/1 Running 1 66d

kube-system etcd-minikube 1/1 Running 1 66d

kube-system kube-apiserver-minikube 1/1 Running 4 66d

kube-system kube-controller-manager-minikube 1/1 Running 1 66d

kube-system kube-proxy-dgvds 1/1 Running 1 66d

kube-system kube-scheduler-minikube 1/1 Running 1 66d

kube-system storage-provisioner 1/1 Running 14 66d

kubernetes-dashboard dashboard-metrics-scraper-c95fcf479-th7gh 1/1 Running 1 66d

kubernetes-dashboard kubernetes-dashboard-6cff4c7c4f-pvs5r 1/1 Running 10 66d

Remember each different service name has different significance.

etcd-minicube – etcd is configuration management system.

apiserver-minicube – for your cluster to interact with clients.

controller-manager-minikube : – A cluster manager node.

there is much ore deep to each node, Need to follow docs to understand things into more deep dive, Right-Now need to remember that Each unit of POD plays significant role in the structure of Cluster.

$ minikube dashboard # To start minikube Dashboard and to analyse how things are going.

```
$ kubectl create deployment hello-minikube --image=k8s.gcr.io/echoserver:1.4
```

Create a Sample deploymen, Remember that, You can’ expose Pods You need to expose deployent to external posrts.

```
$ kubectl expose deployment hello-minikube --type=NodePort --port=8080
```

Link with external port.

You can check status of your deployment.

```
$ kubectl get services hello-minikube
```

Use kubectl to forwrd your port.

```
$ kubectl port-forward service/hello-minikube 7080:8080
```

## Dijkastra’s Algorithms! (SPF-hortest Path Finder Algorithm!)

April 27, 2021

Posted by on Steps to perform Algorithm:

- Mark all nodes as un-Visited.
- Set values to all nodes, Set zero for Initial-Node/First-Node, and infinity for all other nodes.
- Visit all adjacent-Nodes and update the assigned values if new-found-Value is less than already assigned value.
- When completed visit of all adjacent nodes for current-node Mark current Node as Visited and Remove it from UnVisited List.
- If the destination node has been marked visited (when planning a route between two specific nodes) or if the smallest tentative distance among the nodes in the
*unvisited set*is infinity (when planning a complete traversal; occurs when there is no connection between the initial node and remaining unvisited nodes), then stop. The algorithm has finished. - Otherwise, select the unvisited node that is marked with the smallest tentative distance, set it as the new “current node”, and go back to step 3.

## Quantum Computer Init__

February 19, 2021

Posted by on Grover’s Algorithm: Algorithm that runs on Quantum computer to find specific information in Unmanaged Data.

DWave: Dwave is using 533 Qbit Computer to Solve challences in AI and Voice+Image-Recognization!!

## Steps to Solve Rubik’s Cube in 2 mintues!(Practice Matters!)

December 16, 2020

Posted by on **Make a buttefy first:**Yellow step in the center and White pieces adjacent to Yello y 90 degree.- Match corner pieces adjacent to White Pieces with Center of other color and make two rotations.
**White Cross:**After competing the Second step you will be having White Cross.- Keep white cross in the botttom, White cross will remain entirely on the Bottom.
- Time to Perform Left-And Right Trigres:
**Solve the entire White Face**: To sove entire White face you need to match white faces on the upper-most layer with center of same color and perform left-right trigger, which-ever is required.- After completing all left and right triggers you would be having complete White face Solved.
**NoN-Yello Pieces on the top**: Find out each non-Yeo pieces on the top layer and match corner pieces with center, After that Perform again left and right Corners.

**But this time you have to do Left/Right Trigers twice in a Row**:

- After Completing 8th step you would be having bottom layer and two side layers solved till now.
**Get Yello Cross on the top**:

Now to get yellow cross on the top you need to perfom few Algorithms:

R = Rotate Right-side cloclwise.

R’ = Rotate Right-side Anti-clockwise.

R2 = Rotate Right-Side twice Clockwise.

So first Notation is as follows:

F-U-R-U’-R’-F’

**If you have two Yellow pieces in the Edge which makes Single Yelow Line, turn the Yellow line towards you Again Perform FURU’R’F’**

**If you have two Edge yellow pieces which perform Backworf L then turn BackWard l away From you and Again Perform FURU’R’F’**

After performing above steps you would be Having yellow corss on the Top, There could be other yelow pieces as well.

**3. Now Solve the Entire Yellow Side**

At this point you have to find Yellow color on the TopMost layer and bring it to lleft Corner and Perform following Algorithm:

R-U-R’-U-R-U2-R

**Again Perform following if you have Yellow corners on the Upper side layer. **‘

R-U-R’-U-R-U2-R

**After this you might have got FISH on the Top Yellow Side**, **Rotate Fish downward towards you down to left and perform algorithm again. **

R-U-R’-U-R-U2-R

**4. Position the Corners of the Cube:** (At 19:31) in the Video Link.

on the top side layer you have to match the side pieces. using following Algorithm:

L’-U-R-U’-L-U-R’-R-U-R’-U-R-U2-R’

You might find that None of your Side Pieces have Same Color:

L’-U-R-U’-L-U-R’-R-U-R’-U-R-U2-R’

**5. One of the face matching the the corner Pieces:**

Hold the face matchig the Corner Piece on your left hand and perfor the following Algorithm:

L-U-R-U’-L-U-R’-R-U-R’-U-R-U2-R’

**6. At this point all of your Corner Pieces Should Match:**

If your Corner pieces don’t match you have to Match Step 5’s Algorithm one more time.

**7. Final Step: -. Positn the Edges::**

If you are having one side solved till now keep it away from you.

F2-U-R’-L-F2-L’-R-U-F2

after that you need to swap Edge pieces Counter-Clockwise.

F2-U’-R’-L-F2-L’-R-U’-F2

**If still None of your Side are solved::** -> Perform Counter-Clockwise Algorithm.

F2-U’-R’-L-F2-L’-R-U’-F2

You migght have on Solved face, Keep it away from you and Perform Counter-CockWse Algorithm one more Time.

F2-U’-R’-L-F2-L’-R-U’-F2

That’s It. Your Cube is Solved till now!!

## Heap and Heap Sorts]draft[

December 14, 2020

Posted by on Heap Sort is bit different from Other types of SOrts.

Things we need in HeapSort:

- Priority Queue: Implement Set S of Elements, Each of Elements is Associated with Key.
- Insert Operation(): insert Element x into Set S
- Max(S): eturn element of S with largest key.
- Extract-Max(S): Extract max and remove it from S.
- IncreaseKey() : Increase the value of x’s key to new Value.

Heap a tree: Root of tree First ELement (i=1)

parent of i = i/2

left of i = 2i , right of i = 2i+1

MaxHeap: The key of Node>=Key of Children!

Big Question: how we maintain the Max-Heap() ?

Another Big Question: How we rae gong to Build Max-Heap?

Heap-Operations:

build_max_heap(): Produces Max heap from un-ordered Array()

max_heapify(): Correct the single violation of heap.

Look for the children in the Condition and Check

Convert Array A[….n] into Max-Heap

Code is:

def build_max_heap(A):

for i=n/2 down to 1:

do max_heapify(A,i)

Present-Complexity: O(NlogN)

How to get Better Complexity like: O(N)?

Need to underStand Convergence-Series!

Conclusion in Five-Steps of HeapSorting:

- Build Max Heap from un-ordered array.
- Find/Assume Max element is A[1]
- Swap element A[1] with A[n] now maxElement is at end of the array.
- Discard N Element from the array and decrement the heap by n-1
- Now new root may violate the max heap but children are “Max-Heap”

Again MaxHeapify() which means Loop to step2 to 5 until array size is not 1!!

Thenkkewwww

## IBM Quantum Course Application

December 12, 2020

Posted by on My Passion for advanced technologies has grown tremendously from the day my father brought Pentium-3 Intel-based computer at home, I was 14 years old at that time. My curiosity had taken me to complete graduation in Information-Technology and working in the field of Software-Development since 2013. I have taken multiple courses in my graduation like Advanced Data Structures, Machine learning, Discrete Mathematics, Microprocessor and assembly language programming, Digital Circuits, and Logic Design.

My Github Profile Link: https://github.com/arshpreetsingh

Over the past years, I have worked in multiple roles in the Software industry and taught myself various Programming languages like Python, Julia, C, C++, Scala, and Go-Lang. I have industry-wide experience in Software development, Database-management, System-architecture, Data Operations, and Automated Tests. I always concentrate on using Open-Source technologies to cut down costs and making great use of Automation to decrease the cost across different areas.

I have contributed to Open Source Projects as well like TuxMath, TuxBlocks, Plyer, FreeCAD, and Open Street Mapping

Some of my featured Articles on Python, Julia, and Quantitative Finance has been published at medium.com as well.

[Python3 for Text Processing]

https://medium.com/@arshpreetsingh/python-for-text-processing-e8fa81802a71

[Guide to Julia Programming]

https://medium.com/@arshpreetsingh/julia-15da0fb911d6

[Hacker’s Guide to Quantitative Finance]

https://medium.com/@arshpreetsingh/hackers-guide-to-quantitative-trading-algorithmic-trading-part-1-ea479ab2e790

I am working in Finance-Industry and using Machine-learning, Statistics, Applied Mathematics to build financial models since 2017.

The finance industry is already using Pythsics and Applied Mathematics; few Examples are Bolinger Band, Black-Scholes-Merton model, Binomial Distributions, and Bayesian Statistics. Quantum Computing will be more efficient than classical computers to find patterns in data such will lead to the development of better Algorithms.

The detection of fraudulent activities using pattern recognization will be faster using Quantum computers in the financial world. Data will be more secure once encapsulated using quantum-cryptography techniques. One cannot read data encoded in quantum states because they shapeshift by changing states and as such prevent eavesdropping, Usage of quantum computers for “ML and AI models” could lead to more optimized models and will be able to improve the accuracy of the model. I have explored the Applications of Quantum-Technology in Portfolio-optimisation, Credit Risk Analysis, and Time-Series Analysis using Qiskit-Tutorials from Github using this link(https://github.com/Qiskit/qiskit-tutorials/tree/master/tutorials/finance). Apart from that, I have also completed Qiskit-Foundations on youtube taught by Abraham Asfaw.

Using Quantum Computer technology, I want to develop useful Algorithms for Arbitrage and Portfolio-Rebalance, Which I am considering as the first goal in the journey of learning Quantum Computers.

Looking forward to diving into the Quantum Realm and coming out with new forms of life.

## Graph-Algorithms in Python Part-1

November 25, 2020

Posted by on Things required in Graph-Base-Class:

- Number of vertices.
- Graph Type-(Directed or un-directed)
- Method to add Edges
- Method to find adjacent Vertices.
- Method to Get InDegree
- Method to Get Edge Weight
- method to Display the Graph

https://github.com/arshpreetsingh/GraphAlgos/blob/master/graph.py#L11

Adjacency Set: Use the folowing image to learn about Adjacency-Set.

Node:

A single node in a graph represented by an adjacency set. Every node

has a vertex id, Each node is associated with a set of adjacent vertices

Link for Node Code here: https://github.com/arshpreetsingh/GraphAlgos/blob/master/graph.py#L45

**AdjacencyGraph:**

Represents a graph as an adjacency set. A graph is a list of Nodes

and each Node has a set of adjacent vertices.

This graph in this current form cannot be used to represent

weighted edges only unweighted edges can be represented

Inherit from Graph Class,

Number of vertices—Graph Type

1. Add multiple-Nodes in the init() method of the class.

2. Method to add vertices/Edges with some Checks(vertex should not be equal to zero and Vertices value should not be more than nuber of vertices )

```
if v1 >= self.numVertices or v2 >= self.numVertices or v1 < 0 or v2 < 0:
raise ValueError("Vertices %d and %d are out of bounds" % (v1, v2))
```

3. Get Adjacent Vertex.

**For specific Location on Vertex List get adjacent value. **

`self.vertex_list[v].get_adjacent_vertices()`

4. Get Iindegree of Vertex.

Find all the vertices which are connected with specifc vertex.

```
indegree = 0
for i in range(self.numVertices):
if v in self.get_adjacent_vertices(i):
indegree = indegree + 1
return indegree
```

5. Display a Graph:

iterate through list of vertices(self.vertex_list) after that iterate through each Node in the list to get_adjacent_verices!

```
def display(self):
for i in range(self.numVertices):
for v in self.get_adjacent_vertices(i):
print(i, "-->", v)
```

https://github.com/arshpreetsingh/GraphAlgos/blob/master/graph.py#L68

**AdjacencyMatrixGraph:**

Represents a graph as an adjacency matrix. A cell in the matrix has

a value when there exists an edge between the vertex represented by

the row and column numbers.

Weighted graphs can hold values > 1 in the matrix cells

A value of 0 in the cell indicates that there is no edge

Rest of the methods will be Same as AdjacencyGraph. All operaitions will be replaced by matrix operarions insted of set().

## Computational Gemometry Course!

August 28, 2020

Posted by on