teleren/devto huggingface dataset:
Learn Python - 1. Start with python🥳
Tags: programming, python, tutorial
Published: 2021-12-15 20:16:04

## Install Python

Python is installed by default on Mac and Linux operating systems. To check if Python is installed on Windows, first open cmd and type the following command in it: `C: \ Users \ Your Name> python –version`

For Mac and Linux, type the above command on the command line or terminal. If Python is not installed on your computer, you can download it from python.org.


## Running Python Programs
As mentioned earlier, Python is an interpretive programming language. This means that you, as a developer, write Python (py.) Files in a text editor or development environment (IDE) such as Eclipse and execute them with the Python interpreter.
 
The following command in the command line executes a python file called helloworld.py:

`C:\Users\Your Name>python helloworld.py`


Let's write our first program in a Python file called helloworld.py

`print("Hello, World!")`


To run the program, just run the above command line command. The output is as follows:

`Hello, World!`

congratulation! You wrote your first program in Python🥳🥳

## Python Command Line

To test shortcodes, you can write them on the command line to a file. This method is easier and faster. Open the operating system command line and type and run the phrase python. There you can write any program by Python:

`C:\Users\Your Name>python
Python 3.6.4 (v3.6.4:d48eceb, Dec 19 2017, 06:04:45) [MSC v.1900 32 bit (Intel)] on win32
Type “help”, “copyright”, “credits” or “license” for more information.
>>>print(“Hello, World!”)`

Which prints the phrase inside the quotation mark in the same place. You can use exit () to exit the Python command line.


## Structure of Python Commands
 

## Indentations in Python

While Tab is used for readability in programming languages, this is a must in Python. Python uses indentations to specify blocks of code:

`if 5 > 2:
  print("Five is greater than two!")`

If you run the following commands, Python will give an error:

	
`if 5 > 2:
print("Five is greater than two!")`


Comments Descriptions are used to explain part of the code and document the code. Comments start with a footnote and continue to the end of the same line:



`#This is a comment.
print("Hello, World!")`


Python has also developed a documentation feature called docstrings. docstrings can contain one or more lines. The docstring begins and ends with three quotation marks:

`"""This is a
multiline docstring."""
print("Hello, World!")`


The start-up session with Python is over. In the next session, we will teach variables in Python.

Do not forget to like!
Bye until the next post👋
Code Smell 110 - Switches With Defaults
Tags: oop, cleancode, codesmells, tutorial
Published: 2021-12-15 19:57:29

*Default means 'everything we don't know yet'. We cannot foresee the future.*

> TL;DR: Don't add a default clause to your cases. Change it for an exception. Be Explicit.

# Problems

- Coupling

- [Fail Fast principle violation](https://dev.to/mcsee/fail-fast-48dm)

- Open closed principle violation

# Solutions

1. Replace if and cases with polymorphism

2. Change Default code to an Exception

# Context

When using cases, we usually add a default case so it doesn't fail. 

Failing is always better than taking decisions without evidence.

Since [case and switches](https://dev.to/mcsee/code-smell-36-switch-case-elseif-else-if-statements-h6c) are also an smell, we can avoid them.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/ddad35dc0be43c82d4aff94ad2b79d09)
```javascript
switch (value) {
  case value1:
    //if value1 matches the following will be executed..
    doSomething();
    break;
  case value2:
    //if value2 matches the following will be executed..
    doSomethingElse();
    break;
  default:
    //if value does not presently match the above values
    //or future values
    //the following will be executed
    doSomethingSpecial();
    break;
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/78ca0363b28677b5ff24973b2fc4806f)
```javascript
switch (value) {
  case value1:
    //if value1 matches the following will be executed..
    doSomething();
    break;
  case value2:
    //if value2 matches the following will be executed..
    doSomethingElse();
    break;
  case value3:
  case value4:
    //We currently know these options exist
    doSomethingSpecial();
    break;
  default:
    //if value does not match the above values we need to take a decision
    throw new Exception('Unexpected case ' + value + ' we need to consider it');
    break;
}
```

# Detection

[X] Semi Automatic 

We can tell our linters to warn us on default uses unless there's an exception.

# Tags

- Fail Fast

# Conclusion

Writing robust code doesn't mean we need to take decisions without evidence.

# Relations

{% post https://dev.to/mcsee/code-smell-36-switch-case-elseif-else-if-statements-h6c %}

# More Info

- [Fail Fast](https://dev.to/mcsee/fail-fast-48dm)

# Credits

Photo by <a href="https://unsplash.com/@joshua_j_woroniecki">Joshua Woroniecki</a> on <a href="https://unsplash.com/s/photos/crystal-ball">Unsplash</a>
  
* * *
  
> The cost of adding a feature isn’t just the time it takes to code it. The cost also includes the addition of an obstacle to future expansion. The trick is to pick the features that don’t fight each other.

_John Carmack_

{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}
Text to audio Application
Tags: android, flask, python, b4a
Published: 2021-12-15 19:51:39

Hi developers,
This is an Android application for say a text as an audio file with mp3 format.
What do you think about this program?

[TTA APK Link](https://drive.google.com/file/d/16nbWwrbEGZ5ugIwLXCDyjixhAP_cUxMO/view?usp=drivesdk)
React Componenets in Markdown articles
Tags: react, javascript, markdown, blog
Published: 2021-12-15 19:51:27

As I decided to create my blog I choose Next.js as my framework of choice, as a backend I use markdown files stored in a git repo. 

To render my files I use [React Markdown](https://github.com/remarkjs/react-markdown). It's an awesome component that can render markdown files without any config.

After a few posts, I figured out that I need some custom components rendered with my posts. One was for images, to make them zoomable for phones and the second one was a syntax highlighter for code snippets. 

React has a huge amount of components that can help us with both of these. I decided to use  [react-zoom-pan-pinch](https://github.com/prc5/react-zoom-pan-pinch) for image zoom and [react-syntax-highlighter](https://github.com/react-syntax-highlighter/react-syntax-highlighter) for syntax highlight.

Ok. I have my components, not how to render them from our markdown files. Fortunately, React Markdown has us covered. It allows us to do a custom rendering of some tags. 

We can do something like this:

```javascript
import ReactMarkdown from 'react-markdown';
import { Prism as SyntaxHighlighter } from "react-syntax-highlighter";
import { materialDark } from "react-syntax-highlighter/dist/cjs/styles/prism";
import { TransformWrapper, TransformComponent } from "react-zoom-pan-pinch";

<ReactMarkdown
    components={{
        p: ({ node, children }) => {
            if (node.children[0].tagName === "img") {
                const image = node.children[0];
                return (
                    <TransformWrapper>
                        <TransformComponent>
                            <img
                                alt={image.properties.alt}
                                src={`${image.properties.src}`}
                            />
                        </TransformComponent>
                    </TransformWrapper>
                );
            }
            // Return default child if it's not an image
            return <p>{children}</p>;
        },
        code({ className, children }) {
            // Removing "language-" because React-Markdown already added "language-"
            let language = "";
            if (className) {
                language = className.replace("language-", "");
            }
            return (
                <SyntaxHighlighter
                    style={materialDark}
                    language={language}
                    children={children[0]}
                />
            );
        },
    }}
>
    {postData.contentMarkdown}
</ReactMarkdown>
```

For images, we must hook into <p> tag, as ReactMarkdown is wrapping images in paragraphs. So with a simple if we decide if the first child of the paragraph is an image. If so we replace the whole thing. 

For code, we are just replacing the whole code tag.

---

If you like this article you can follow me on [Twitter](https://twitter.com/pavel_polivka).
Is Data Analyst a Good Career in Pakistan?
Tags: career, pakistan, datascience, beginners
Published: 2021-12-15 19:37:20

### Introduction
Due to its multidimensional economy with strong global impact, Pakistan is in dire need of trained data analysts to face the challenges ahead both nationally and internationally. Data analysts can prepare the country for improved productivity or profitability through the utilization of resources. Data analysis in Pakistan is a rapidly emerging field; there is much to do. Is data analyst a good career in Pakistan? Yes, it is.

## The Future of a Data Analyst in Pakistan
Today the world has transformed into a techno world. The fourth industrial revolution has influenced the nature and future of jobs. Pakistan is no exception. Data analysis is not just programming skills; rather, it is a multidimensional field that involves statistics, data management, mathematics, machine learning, and data visualization as well. The profession offers many benefits.

#### Highlights
 - A Good Salaried Job
 - A Versatile career
 - Flexibility
 - The field has not reached the apex yet

### A Good Salaried Job:
Data analysts are earning a reasonable income currently, and there is a wide scope of pay raises in the coming years with increasing demands.

### A Versatile career:
Apart from businesses, there is a high demand for data scientists in every field, including medical, astronautics, social, research, e-commerce, infrastructure, education, and the list goes on. Working on projects from entirely different fields helps you to grow professionally and expands your vision.

### Flexibility:
The career offers flexible options like working with a company, freelancing, or working as a consultant. There are a plethora of online resources regarding data analysis, making it easy for you to upgrade your knowledge at any stage.

### Digital Pakistan Is In the Air
Pakistan is gradually making progress in electronics and telecommunications. It would soon be impossible to perform a task without a computational medium. Companies in Pakistan need huge targeted markets with an accurate risk assessment. Data analysis offers systems to extract purposeful insights from bulks of data. Machine learning, part and parcel of data analysis develop algorithms to provide predictions.

**_In Pakistan, the field has not reached the apex yet. It is probably down to loopholes in the education system that pays less attention to hands-on training. Industries must explore and utilize technological advancements like data analysis to unravel the possibilities. _**

## Conclusion

Data analyst is indeed a good career in Pakistan. To keep pace with the global technological revolution, Pakistan needs a squad of highly skilled data analysts. So, data analysis would steal the show for taking Pakistan towards prosperity.
Top 5 Universities for Computer Science in Pakistan
Tags: career, pakistan, beginners, university
Published: 2021-12-15 19:33:22

### Introduction
Technology innovation has taken the world by storm, and Pakistan is not behind. CS is one such domain that has a place in almost every industry. The introduction of online systems, databases, cloud storage, and mobile applications has caused the rise in the scope of computer science. A degree in CS is not an easy one, but it promises you a bright future. Many prestigious institutions in Pakistan offer undergraduate and postgraduate degrees in CS, SE, AI, DS, cybersecurity, and other tech-related fields.
Are you looking for a university to study CS? Here is a list of the top institutions from which you can select.

### 1. FAST
nu.edu.pk
Fast NUCES is a highly ranked university for CS with campuses in Lahore, Islamabad, Karachi, Faisalabad, and Peshawar. This university is famous for research in IT, and its graduates are considered hot cakes in the hiring market. The studies might be tough, but FAST gives you an enjoyable journey with exciting events hosted by different societies.

### 2. COMSATS
www.comsats.edu.pk
Comsats is one of the oldest CS universities in the country. It is a public university and has campuses in different cities. The campuses in Islamabad and Lahore are more popular. COMSATS offers degrees in engineering and humanities also, but it is well-known for the CS department. The campuses are spacious and beautiful.

### 3. NUST
nust.edu.pk
NUST is an internationally recognized institution for engineering and technology. The Islamabad campus is the main campus. All the campuses are well-equipped, and the stunning landscape gives you an enjoyable campus life. This university conducts its entrance test three times a year, and the merit is usually high.

### 4. PUCIT
Punjab University's faculty of computer and information offers programs of CS, SE, IT, and Data Science. The campus was established in 1988 primarily for CS. Located in Lahore, the campus provides facilities like labs and a library. Overall, the university has a conducive environment for learning and an excellent reputation.

### 5. PIEAS
It is a public university located in Islamabad that conducts entry tests in many other cities. This institute was ranked as number one by HEC Pakistan. Like NUST, getting into this university is not that easy. It offers bachelor's and master's degrees in computer and information sciences. 

To conclude, Pakistan has many exemplary IT institutions. These universities will shape your skills and make you capable of entering into the world of revolution and automation.
Daftar Capsa ✓ Situs Capsa ✓ Agen Capsa ✓ Judi Capsa
Tags: daftarcapsa
Published: 2021-12-15 19:28:50

https://joy.gallery/daftarcapsa88	https://linktr.ee/daftarcapsaidn	https://manylink.co/@daftarcapsa	biolinky.co/daftarcapsa88	beacons.ai/daftar_capsa	https://caramellaapp.com/capsaidnplay
https://joy.link/situscapsa303	https://linktr.ee/situs_capsa	https://manylink.co/@judicapsa	biolinky.co/judicapsaidn	https://beacons.ai/situscapsa	
https://joy.link/agen-capsa88	https://linktr.ee/agen_capsa	https://manylink.co/@agencapsa	biolinky.co/situscapsaidn	https://beacons.ai/agen_capsa	
https://joy.bio/capsaidnplay	https://linktr.ee/judi_capsa	https://manylink.co/@situscapsa	biolinky.co/agencapsaidn	beacons.ai/judicapsa	
https://joy.link/judi-capsaidn	https://linktr.ee/capsaidnplay	https://manylink.co/@capsaidnplay	biolinky.co/capsaidnplay	beacons.ai/capsaidnplay
How to create a Website with Express framework and Pug engine
Tags: javascript, node, webdev, programming
Published: 2021-12-15 19:28:46

This is a silent coding video, where you can chill, have your hot/cold beverage and code along with me this awesome website using different technologies :

- Node js
- Express framework
- Pug template engine [ HTML preprocessor ]

Just coding quietly on my mechanical keyboard "Razer Ornata V2", and I invite you to join me:


{% youtube G0ocy9mkJuQ %}

Hope you enjoy, guys

Social Media  
----------------------
Facebook : https://www.facebook.com/bekbrace​​​​/ 
Twitter : https://twitter.com/BekBrace/
Instagram : https://www.instagram.com/bek_brace/
GitHub profile : https://github.com/BekBrace/​​​
Website : https://bekbrace.com/

Reach out  : info@bekbrace.com

Tools used in video:
---------------------------------
Microphone used in recording Blue Yeti
To check it out on Amazon : https://amzn.to/3lh6GdA

Coding on Razer Ornata V2 keyboard
To check it out on Amazon : https://amzn.to/3xv3cZZ

Support
--------------
Join this channel to get access to perks:
https://www.youtube.com/channel/UC7EVSn5inapL20oPSwAwEUg/join
OR
Become a Patron: https://www.patreon.com/bekbrace
[how to fix] Apache SOLR impacted by CVE-2021-4428 vulnerability
Tags: solr, cve202144228, log4j
Published: 2021-12-15 19:28:37

Apache SOLR is impacted by CVE-2021-4428
Now what?

### **UPDATE**: Solr 8.11.1 is already available!

### Here is how you can fix it:


#### **STOP SOLR**
[Windows] `solr.cmd stop -p 8983`
[Linux] `service solr stop`




#### **Edit**
 `solr.cmd `(for Windows) 
 `solr` (for Linux) 
    files from `\bin` directory

**[Windows]**
 

-  in _solr.cmd_ file, find this line: 

> set START_OPTS=-Duser.timezone=%SOLR_TIMEZONE%

 
- right after this line, add this line:

> set "START_OPTS=%START_OPTS% -Dlog4j2.formatMsgNoLookups=true" 

**[Linux]**
  

-  in _solr_ file, find this line:
  
> SOLR_START_OPTS=(
  
- inside the brackets () wherever you want add this 

>  "-Dlog4j2.formatMsgNoLookups=true"


#### **START SOLR**


---


## Let's TEST if the changes had effect
1. Open SOLR UI 
2. In Dashboard check if you see `-Dlog4j2.formatMsgNoLookups=true`

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w5juv49k1xgard6k6fyo.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xrhst5xk0e6mq7sbugt8.png)
Best Software Companies Of Pakistan
Tags: pakistan, career, companies, beginners
Published: 2021-12-15 19:26:26

## Introduction

Technology is making more and more progress and advancement in Pakistan, and that too in an innovative way. Unlike the old times when things were done manually, people now prefer to perform their tasks with the help of software. That is the primary reason why the demand for efficient and top-class software houses is increasing day by day in the country. They will help you fulfill all the needs and requirements of your business like a PRO! So, are you in search of some software companies but not able to identify the right one? No worries, here is a list for you of top software houses of Pakistan:

#### NetSol

NetSol Software Company is one of the most popular, in-demand, and successful software houses in Pakistan. Its main office is located in Lahore, and the company offers excellent IT services like Data Management, Data Analysis, Data Security Frameworks, Financial Consultancy, and Software Quality Assurance.

### 10Pearls
Another excellent software house of Pakistan, 10Pearls is located in Karachi. This company came into being in 2004 by two partners/brothers; Zeeshan Aftab and Imran Aftab. 10Pearls offers services like mobile application development, game development, and website development. Also, this company has worked for 500+ well-known businesses.

### TRG (The Resource Group)
Next on our list is this innovative, efficient, and another best software house of Pakistan – TRG! This company was founded by Mr. Zia Chishti in 2002, and since then, it has been providing excellent services like software testing, software engineering, design & development, and system automation. Also, TRG has never failed to satisfy its clients with its innovative approaches and high-quality services.

### Systems Limited
Systems Limited is one of the most long-running and the best software houses in Pakistan with excellent services and extreme efficiency. The company came into being in 1977 and is currently operated by Asif Peer, the CEO.  Not only Pakistan, but this company has provided its excellent services in the Middle East, UK, US, and Africa as well.

## Conclusion
We sum up our list of the best software houses of Pakistan, and now it's your turn to choose the right one to advance and flourish your business!
Welcome Thread - v155
Tags: welcome
Published: 2021-12-15 19:23:59

---
title: Welcome Thread - v155
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---

![Comedian waving](https://media.giphy.com/media/13zdDToM7Hi8eY/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Find duplicate in an array.
Tags: algorithms, programming, cpp
Published: 2021-12-15 19:21:03

## <u>Problem Statement</u> :-
Given an array of integers containing n + 1 integers where each integer is in the range [1, n] inclusive. Any integer can appear any number of times, find the repeated/duplicate numbers in the array.

[Link to the problem](https://leetcode.com/problems/find-the-duplicate-number/)

Approaches to the above problem or similar problem has been added below.

---

### <u>Approach 1</u> :-

Loop through all elemnts of the array. On seeing **abs(nums[i])**, make element at **ith** index negative. If the element is already negative,that means the number has been **visited**. Return this element as the repeated number.

Time Complpexity = **O(n)**
Space Complexity = **O(1)**

```cpp
int findDuplicate(vector<int>& nums) {
 for(int i:nums){
       if(nums[abs(i)] > 0){
          nums[abs(i)] *= -1;
       }else{
          return abs(i);
       }
    }
    return -1;
 }
```

---

### <u>Approach 2</u> :-

In this approach the input array is used as a hashmap.The idea is to loop through all the elements of the array and for every encountered 
**number (num)** add **n (size of nums array)** to the 
**(num % n)th** element.
Again loop through all the elements of the modified array to check if **nums[i]/n > 1**, which implies n has been added more than once.

Time Complpexity = **O(n)**
Space Complexity = **O(1)**

```cpp
void findDuplicates(vector<int> &nums){
  int n = nums.size();
  for(int num:nums){
    nums[num%n] += n;
  }
  for(int i=0 ; i < n; i++){
    if(nums[i]/n > 1)
      cout << i <<" ";
  }
}
```
---

### <u>Approach 3</u> :-

This approach makes use of [Pigeonhole Principle](https://en.wikipedia.org/wiki/Pigeonhole_principle) and binary search.

Time Complpexity = **O(nlogn)**
Space Complexity = **O(1)**

```cpp
int findDuplicate(vector<int>& nums){
    int n = nums.size();
    int low = 0, high = n-1, mid;
    while(low < high){
        int count = 0;
        mid = (low + high) / 2;
        // count numbers which are less than or equal to mid 
        for(int num:nums){
            if(num<=mid)
                count++;
        }
        // if count is greater than mid then the duplicate
        // element should be in the [low .. mid] region else 
        //duplicate element should be in the [mid+1 .. high] region
        if(count > mid)
            high = mid;
        else
            low = mid + 1;
    }
    return low;
}
```