ReactJS 101

If you have been reading about web technologies recently then it is totally possible that you might come across a word “ReactJS“.

What is ReactJS?

  • React or ReactJS is a JavaScript library.
  • React is not a framework. (unlike Angular, which is more opinionated).
  • React is an open-source project created by Facebook.
  • React is used to build user interfaces (UI) on the front end.
  • React is the view layer of an MVC application (Model View Controller).

ReactJS is a library of JavaScript which actually requires a setup on your local machine. A simple React app can be created using create-react-app.

ReactJS can be set up in a number of ways, let’s look at a few of them.

  1. Using a Static HTML File.
  2. “Create React App” via npm.

In this part we will discuss only 2nd option i.e. via npm. Let’s directly jump into it:-

Create-React-App” via npm

Prerequisite:

Install Node.js and npm globally on your machine.

Fortunately, Facebook has created Create React App, an environment that comes pre-configured with everything you need to build a React app. It will create a live development server, use Webpack to automatically compile React, JSX, and ES6, auto-prefix CSS files, and use ESLint to test and warn about mistakes in the code.

Run the following code in your terminal.

npx create-react-app my-app

Once that finishes installing, move to the newly created directory and start the project.

cd my-app npm start

Once you run this command. In your browser, a new window will pop up at localhost:3000 with your new React app.

If you look into the project structure, you’ll see a /public and /src directory, along with the regular node_modules, .gitignore, README.md, and package.json.

In /public, our important file is index.html, which is very similar to the static index.html file we made earlier — just a root div. This time, no libraries or scripts are being loaded in. The /src directory will contain all our React code.

HAPPY CODING!!

JS to JSON via AJAX

Yes, we are going to talk about the most “famous” programming language in this world, JAVASCRIPT. Just like Object-oriented programming is built on three sturdy pillars: encapsulation , specialization, and polymorphism, Web developement is also laid on these three pillars:-

  • HTML
  • CSS
  • Javascript

JAVASCRIPT

JS is what which makes a web page run. JavaScript was originally designed to be used purely on the front end as a way for web developers to add functionality to their web pages, and in its early days, it did just that. Recently, the introduction of the “V8 engine” by Google has improved the speed and functionality of JS. That led to the development and release of exciting new front end JavaScript frameworks and eventually Node.js, a way to run JavaScript on a server (back end). This new development has led to a resurgence of JavaScript. Now, JavaScript is one of the world’s most widely-used programming languages.

Everyone thinks that it is similar to java, not everyone though!! Just keep it in your mind, Javascript!=Java. Although it shares similar names but Java is purely a Object-Oriented Programming while JS is not a OOP language.

For Javascript, you need to write a .js file which can be run on web browser. By opening the console you can run see running JS in real time. Ohh, By the way it is synchronous.

You can write as many algorithm in JS which can be written by any other programming language. Why Javascript? JavaScript is the standard language of the web platform. Learning it will help you create any app for any platform, using one language.

AJAX

When I was learning javascript, my online tutor directly jumps to Ajax, after which I wonder whats the use of it, since javascript can do pretty most things. So I googled and found out, It is not a programming language or a tool, but a concept. Ajax was originally an acronym for Asynchronous JavaScript and XML. “Asynchronous” means that multiple events are happening independently of one another. 

When we use JS i.e. synchronous, it refreshes the full page even if we need a small change in a web page and lead to poor user experience while using AJAX EMBEDDED IN JS, it will just change the particular part of the web page lead to dynamic web pages.

Another major advance to JavaScript and Ajax is the JavaScript object library called jQuery. This free, open-source software is a wrapper around JavaScript. jQuery is used to easily write client-side JavaScript to navigate and manipulate a page and make asynchronous Ajax callbacks.

By using jQuery and JSON Web Services, Ajax callbacks have become standard programming practices for designing and developing web applications.

JSON

 JSON stands for JavaScript Object Notation — it is usually text based format that represents structured data on JavaScript object syntax. It is a lightweight data representation. JSON is just a string which is following the Javascript Object Literal Syntax, while everything thinks “It is a JS Object”. Even though it closely resembles JavaScript object literal syntax, it can be used independently from JavaScript, and many programming environments feature the ability to read (parse) and generate JSON. Every JSON is needed to convert into JS object by:-

Conversion from JSON to JS Object

var obj = JSON.parse(jsonString);

Conversion from JS Object to JSON string

var str = JSON.stringify(obj);

Square brackets holds array of JSON objects as shown below

So next time you hear or see JSON know that it is used to store data and access it as needed by the client or the server.

Few Good Things In 2020

Okay! We all know 2020 is off to a pretty rough start but there’s always room for some good news, right.

5 months have already been rolled this year and we already understood that it is not going as per the plan. It has already proved itself to be more challenging than expected. But fear not, good things are still happening all over the world. Let’s jump into it.

Protection Of Coral Reefs

You know the island nation of Palau has banned the manufacturing and use of a sunscreens which contains the chemicals which are responsible for wiping out the coral reefs. Isn’t it great!!

Power Of Unity

Despite the major part of world is suffering from corona, many people are stepping out of their comfort zones and helping those who are not even able to keep themselves hydrated.

Cures and vaccines of COVID-19 are Underway

Countries all around the globe are racing to develop the first vaccine against the virus. Israel is claiming to have developed vaccine of COVID-19. Terming the development a ‘major breakthrough’, majority of the countries will start importing the vaccine, if the news is true.

Last Ebola Patient Is Discharged

The end of the Ebola outbreak may be in sight as the last victim from the Democratic Republic of Congo (DR Congo) was discharged last March 3, 2020. The hospital staff celebrated it like a festival.

A vaccine for Ebola, called Ervebo, had also approved by the Food and Drug Administration (FDA) last December 19, 2019. The Ebola virus has an average fatality rate of about 50%, which is significantly higher than that of the novel coronavirus. 

Huge Impact On Environment

As you all know the world is on lockdown, no one is moving out of their homes means almost 0 emission of Carbon. Due to this, Scientist said that the biggest hole in the Ozone layer is now Healed.

China and Northern Italy have also recorded significant reductions in their nitrogen dioxide levels.

A significant dip in air pollution levels was measured across the country. Cities like Delhi, Bengaluru, Kolkata and Lucknow saw their average Air Quality Index (AQI) staying within two digits.

Koalas Are Returning

Koalas that were injured in Australia during forest fire, are now returning to the forest. As the world watched this horror, the forest fire wiped out the large number of forest animals including koalas. Few koalas were rescued and treated and released back to the forest post fire.

Despite all the bad things going on around the world, it’s always best to look at all the good things 2020 has brought. Everybody got a second chance at life, wildlife is thriving, and humans are working tirelessly to fix our mistakes day by day. This year might bring a lot of heartbreak and destruction, as all years do, but it will bring positivity, if we know where to look at.

Introduction to Recommender Systems

There are many companies which are working on daily basis to improve their Recommender System which they are using now like Youtube, Amazon, Netflix and many other such companies which are providing web services. In layman’s term, Recommender system is used to suggest something to the user. Recommender systems are today unavoidable in our daily online journeys.They are typically classified into Content-Based Filtering and Collaborative filtering.

Collaborative filtering

collaborative filtering models which are based on assumption that people like things similar to other things they like, and things that are liked by other people with similar taste. ~Medium

Collaborative algorithm uses “User Behavior” for recommending items. They exploit behavior of other users and items in terms of transaction history, ratings, selection and purchase information. Other users behavior and preferences over the items are used to recommend items to the new users. In this case, features of the items are not known.

User-Based Collaborative Filtering

This is the simplest technique in collaborative filtering in which the recommender system finds the similar users to the active user (to whom we are trying to recommend a movie). A specific application of this is the user-based Nearest Neighbor algorithm. This algorithm needs two tasks:

1.Find the K-nearest neighbors (KNN) to the user a, using a similarity function w to measure the distance between each pair of users:

2.Predict the rating that user a will give to all items the k neighbors have consumed but a has not. We Look for the item j with the best predicted rating.

This can be brief as suppose people A buys product X and product Y and there another person who bought product X the the recommender system will recommend the person to buy product Y also.

Item-Based Collaborative Filtering

Here, instead of focussing on the user similarities, we could focus on what items from all the options are more similar to what we know he enjoys. This new focus is known as Item-Based Collaborative Filtering (IB-CF).

It uses the implementation through cosine similarity but it should be under UB-CF becuase it is also used find the similar user for recommending the item.

IB-CF can be implemented through matrix factorization.

Content-Based Filtering

A content based recommender works with data that the user provides, either explicitly (rating) or implicitly (clicking on a link). Based on that data, a user profile is generated, which is then used to make suggestions to the user. As the user provides more inputs or takes actions on the recommendations, the engine becomes more and more accurate which based on the previous knowledge this system works.

This type of recommender system becomes more and more powerful with more engagement of users.

Since Content-Based Filtering is a large topic, let’s keep it for the next article.

Since, I have made a project using User-Based Collaborative Filtering to recommeng songs to different users. You can have a look here.

5 Best Videoconferencing Apps-Zoom Alternative!!

From the time many big companies started to claim Zoom App for its weak security, many users, out of fear, are starting to shift from zoom app to some good alternative. Germany, Singapore and Taiwan have already banned the application.

zoom app

Indian government also issued an advisory for zoom users and said explicitly that “it is not a safe platform for video-conferencing“.

This official statement lead to start the migration of zoom users to some other reliable and safe video-conferencing app. There are few best apps out there which can be a good alternative to zoom:-

Meet Now

Meet Now in skype is safe platform and allow collaboration of skype user as well as non skype users.During a meeting, participants can open recent chats, view participants currently in the call, can record the call, mute or unmute the microphone, and send a reaction to the call. Meet Now can store the recording for up to 30 days. It can blur background before entering the call. One can also share presentations, work material or designs in a conference call.

Hangout

This must be a familiar platform to you, if you use google. Although it supports video conferencing for up to 10 people and voice conferencing for up to 150 people. You can use it according to your use case within their limitations.

Cisco WebEx

It is a great software for those who wants to conduct sessions for unlimited duration. It supports up to 100 people. It also have call-in for audio.

Jitsi Meet

You probably haven’t heard of it, but yeah it exists.Its features can be given as:-

  • Up to 75 participants (up to 35 for the best experience)
  • Public or private chat
  • Can blur the background (currently in beta)
  • Integrates with Slack, Google Calendar, and Office 365

StarLeaf

You definitely haven’t heard of it because it is not a company, it is a platform for large companies. But it is now offering its basic video and messaging product free of charge for those trying to keep in touch during the pandemic. Great for video conferencing for up to 20 people with 46 min for each meeting.

Automate Excel Using Python

Doing stuff in python is a bliss in itself, it is such a beautiful language which provides us one of the most easiest syntax among any of the programming languages. Being a scripting language, python is used almost everywhere especially when it comes to working with data, manipulating data.

Most of the times when it comes to data, we mostly speaking in reference with Excel spreadsheets. Reading, writing and manipulating data from excel spreadsheets can be easily done using python. There are many third-party packages available to work with spreadsheets using Python. One of the package is xlrd. This package can be used in Linux or Mac or Window, best works with Linux. This package does not come installed with python, we have to install it using:-

pip install xlrd

One can also download the xlrd from here.

Reading an excel

Python script can be easily written to read an excel. It could be anything,

  • Rows
  • Columns
  • Cell value
import xlrd
loc = ("path of file")  

wb = xlrd.open_workbook(loc)
sheet = wb.sheet_by_index(0)  

# For row 0 and column 0
sheet.cell_value(0, 0)

# Extracting number of columns
print(sheet.ncols)

# Program extracting all columns
for i in range(sheet.ncols):
print(sheet.cell_value(0, i))

print(sheet.row_values(1))

The above is written in a way that the code is self-explanatory and you can easily make of what each syntax is doing. With this one can easily read data from excel.

Which module is used for writing and manipulating spreadsheets in python??? Comment down below.

Should You Just Get Rid Of Toxic People From Your Life?

Everybody is well aware that how important is it for our body to give it a break from every “toxicity” like alcohol and cigarettes, but what about giving a break from toxic people from our life.

Tara Mackey, author of Cured by Nature and founder of The Organic Life, “Just like any toxic thing—like food or poison—toxic people are extremely dangerous”.

It is very necessary to get rid of toxic people. They are like mentally harassing you, they distract you from your goal and your positive and productive habits.They’ll do anything to surpass their ego from you by making fun of you just because of wanting a better person.

It is very important for you to find out the toxic people in your life by understanding the difference between the people who are truly toxic to your well-being and who, may not intentionally putting you in depression, but harmful for you. It can be difficult for you to keep distance from these people but I’ll put some points which will help you to do the same and achieve this.

Identify The Toxicity

The first of getting rid of toxic people is actually recognizing them who are “harming you”. “Toxic people are manipulative and often selfish,” says Mackey. Identifying them will help you to rid of them as they are the best distraction from your true purpose.

Stick To It

Don’t let them to manipulate you. If you stick to not talking and keeping a distance from them, then it will help you a lot. Just don’t talk unnecessary to them which would disturb you only, in return. Be very, very clear with the person about your intentions, then keep the necessary distance to make sure your message isn’t misconstrued.

Maintain Boundaries

….and stick to them. If you make your mind not to respond to any of the their messages or texts. Once you’ve made the decision to end a relationship, you’re responsible for keeping the guidelines clear after the fact.

Don’t Be Too Nice

You might think this is not appropriate but you are having this thought because of your positivity, but since toxic people tend to suck all your kindness, being overly nice to them could be detrimental. It doesn’t mean you have to be cruel to them but be neutral with them.

Few Thoughts on Living with Bad Leadership in Corona Time!!!

Since no introduction is needed for the pandemic Corona Virus, How it is spreading and affecting the whole earth, country by country!!! You guyss are well aware about it and with the consequences of it. I’ll directly jump to the topic which is how our country’s leaders are reacting to it.

  1. There is no transparency in the stock and flow of PPE(Personal Protective Equipment) kit in our country.
  2. On social networks, so many rumors are spreading about corona. Even after the rectification in laws about rumors, we re still getting many rumors on WhatsApp and Facebook.
  3. Our so called dharm gurus are saying that no need of developing vaccines, only intake of their own factory’s product will do the job, it seems.
  4. Our media is doing “great” by calling in Muslim and Hindu community leaders and asking them to fight over nonsense topics rather than spreading awareness about corona virus.
  5. Media is calling celebrities and asking them to enlighten their lives instead of questioning government for the preparation of pandemic.
  6. We made sure that social media apps and streaming video services could scale. We forgot to make sure the health system could. The more we can delay the spread, the better.
  7. Doctors are attacked by the mob for testing their health only, like seriously. Police should accompany each team of doctor and they must be punished for the deed.
  8. Due to the lockdown, daily wage earners, contractual labourers and self-employed workers, among others, in the informal economy in rural and urban areas, constrained them out of jobs amid the nation’s high unemployment rate.
  9. These people are moving in large numbers to their respective villages raising a huge question on state and central government’s preparation.

10. Update: Everything is on halt.

Web Scraping 101

If you are interested in Machine Learning and trying to build a project. You will definitely come across the need of huge dataset which is the essential part of a Machine Learning project. Dataset can be easily obtained from internet as it contains tons of data but it is possible that it might not be suitable for your project.

This problem can be solved by scraping some website using python and BeautifulSoup. Many scrapping libraries like BeautifulSoupScrappy, etc.. are available to facilitate us. For me, BeautifulSoup was easily understandable so I suggest Beastifulsoup for smaller project and scrappy for larger ones.

Setting up the libraries!

There are two libraries which you need to set up before starting the web scrapping.

  1. BeautifulSoup
  2. Pandas

to install these on Linux type the following command,

pip3 install -U BeautifulSoup pandas

Getting Started

After installing the libraries, you can directly jump to the coding part. Before that you need to have some basic knowledge of tags in HTML which you can read by clicking here.

I prefer to use Jupyter Notebooks as it is more convenient to have have live output of the code and it also offers many other features. You could work with any editor or IDE of your choice but keep in mind that we are working with python3 and some of the libraries may not be the same in python2.

Now comes the coding part in which the first part is to access the HTML.

import requests
URL = “website url
r = requests.get(URL)
print(r.content)

After that you can parse the HTML using Beautiful Soup by soup=BeautifulSoup(r.content,’htmllib’)

The third thing is to search and navigate through the parse tree which means now the main task of your code is to extract data and you are going to the same thing for which you can write the code respective to your requirement.

The last thing is to save all the extracted data into a csv file which can be easily done by impoting the csv module( example code given below )

import csv
import requests
from bs4 import BeautifulSoup

link = "https://www.top500.org/list/2018/06/?page={}"

def get_data(link):
    for url in [link.format(page) for page in range(1,6)]:
        res = requests.get(url)
        soup = BeautifulSoup(res.text,"lxml")

        for items in soup.select("table.table tr"):
            td = [item.get_text(strip=True) for item in items.select("th,td")]
            writer.writerow(td)

if __name__ == '__main__':
    with open("tabularitem.csv","w",newline="") as infile: #if encoding issue comes up then replace with ('tabularitem.csv', 'w', newline="", encoding="utf-8")
        writer = csv.writer(infile)
        get_data(link)

Thankyou!!!!

Python and SQLite3-The Best Pair, Why?

There are various opportunities after being a Data Analyst. Everyone is thinking of doing at-least one course on python and a database. But since there are various databases out there with various functionalities, it becomes difficult to choose one from different databases like MySQL, PostgreSQL, Sybase and Oracle which are supported by python as well.

So we have to make a decision by choosing a suitable database which is SQLite3, according to me. I have also worked on MySql Workbench which I found to be very heavy application to work on.

Source-python-para-impacientes

These days connecting a apllication with the database plays an important role. Because of the need to save the data securely as much as possible. Python is well-known as the language for data science. But its use in web development is very notable, specially because of Django and Flask.

Below are the 3 reasons why SQLite3 is the best suite for experimentation with Python :-

  1. Lightweight Database

We know that SQLite3 is a very lightweight database which make its very easy to use and handle. It do not require any separate database process to be maintained.

We can also store the database in our internal storage based on our use.

2. Both are written in C

We have studied that python compiler is written in C while SQLite3 is also a C library that provides a lightweight disk-based database.

Both written in C makes it more compatible to run and work with each other.

3. Easy Integration

SQLite3 and Python can be very integrated simply by using a header file “include sqlite3”, this will be enough to do the job.

4. Sql like SQLite3

SQLite makes use of the very easy english-like SQL codes, which makes it more viable for use by the programmers as in the picture above, even with Python.

5. Prototyping

Lastly, It is wise of you to use SQLite3 with python to store data because prototyping in the lightweight SQLite3 helps in migrating the code to heavier weight / larger databases such as PostgreSQL or Oracle.

Design a site like this with WordPress.com
Get started