Posts

Showing posts from July, 2022

Object Oriented Programming using Python

Image
Object-oriented programming Object-oriented programming is a paradigm of programming that models software code after real-life objects. Just like objects, you can have instances of objects and objects can have attributes. Let's get into it. Figure [1] - OOP Creating an object: class Car :     pass car1 = Car () print ( car1 ) In the script above, we first defined a class Car, then instantiated Car class on variable 'car1' and we received the following output for our print statement. <__main__.Car object at 0x0124E490> This refers to the object stored at a particular memory location. We will see how to make this output more user friendly later on. Adding attributes to an object: All cars would have a make, model, and year of manufacture, so we can set those as attributes for our car1. In the script below, we have done just that. class Car :     pass car1 = Car () car1 .make = 'Volkswagen' ca

Python Paramiko module

Image
Introduction: Figure [1] Raspberry Pi A computer by definition is a digital electronic machine that can be programmed to carry out sequences of arithmetic or logical operations (computation) automatically & looks like the image above. As we can see, its not possible to input commands and receive output from the physical device itself so we need some form of input and output device attachments. This is where a ' computer terminal ' comes in, its a device that can be used for entering data into, & transcribing data from a computer. Early computer terminals looked like the image below. You can see some familiar elements from modern day computers such as a keyboard in the image. Figure [2] Early computer terminal VT100 A later improvement to the computing world was the concept of ' time-sharing ' which is the sharing of a computing resource among many users at the same time by means of multiprogramming and multi-tasking. Main Section: A typical modern day data cente

Terraform Introduction

Image
Infrastructure as a Code (IaC): So, what is IaC? It's just a fancy made-up term for deploying and controlling the cloud infrastructure as a series of configuration files instead of using the GUI and the most popular IaC tool is Terraform. Terraform is a program written in the 'Go' language that lets us deploy infrastructure on different platforms using plugins called  providers . Providers let us perform CRUD (Post Get Put Delete) operations on the Target APIs as depicted below: Figure [1] Terraform calls We write Terraform scripts in a Terraform Domain-Specific language called ' Hashicorp Configuration Language ' (HCL). Working with Terraform and AWS: Terraform lets you declare infrastructure in a Declarative manner .  Modules are reusable Terraform configurations that may contain one or more providers. Step 1 - Install Terraform (we will only cover RHEL 8 here for the sake of brevity): sudo yum install -y yum-utils sudo yum-config-manager --add-repo https://rpm.re

Working with APIs using Python

Image
I love automation and believe automating repetitive tasks makes the world a better place as it would free up humans to work on more interesting challenges! APIs are one of the most useful tools in setting up automation so I thought I'd take some time to write about them and share my experience using them. Let's start by defining the word 'Program'. 'Program' can be used as a noun or a verb, in the noun form, it means a set of instructions provided to a computer to perform a certain task while in the verb form it means to provide a human/computer a set of instructions to perform a task automatically. Figure 1: API/Program Illustration API stands for Application Programming Interface and it is a way for humans and programs to interact with programs. Here's a simple illustration of how an API works: Figure 2: API Analogy What this means is that the application has some endpoint that you can reach (such as an HTTP GET request to a particular website endpoint) th

July 3rd 2022 - Day 3 of 3 day study bender

Image
 The final study bender day went great! Started the day out by watching CS50 lecture 6 on Python and since I have had extensive experience coding in Python, skipped through most of the lecture. Here are some key points/takeaways that you don't think of often. Note all notes here pertain to Python3. 1) Unlike 'C' programming language, in Python, at the end of every print statement, we get a new line character implicitly. * Indentation is important in Python programming language, unlike 'C' programming language. 2) Data types available in Python -> string, integer, float, complex, list, tuple, range, dictionary, boolean, None (not an exhaustive list). * Python programming languages do not need to be compiled. Python is an interpreted language. 3) We use a 'main()' function to call functions before defining them, this way our code is more readable, and we need to make sure to call the main function before the end of our program. * We often see something like