teleren/devto huggingface dataset:
Learn Python #3 - Conditional Statements - if, if elif, and if elif else
Tags: python, webdev, programming
Published: 2022-07-17 11:30:37

Hello everyone, Today we are going to talk about the `if`, `if elif`, and `if elif else` conditional statement in Python and try to understand the different use cases and different ways of writing the same conditional statement.

## What the hell `if`, `if elif`, and `if elif else` is?
In Python to execute the statement based on certain conditions being satisfied, we use the `if` statement.
Let's look at a few of the examples:-

### Example 1:-

```
going_to_office = True #variable that stores the boolean value
if going_to_office == True: print("Work from office")
``` 
Here instead of checking the values of going_to_office against `True`, we can directly write it as
```
if going_to_office: print("Work from office")
```
So if the condition is evaluated to `True` then the `print` statement is executed else not.

### Example 2:-
Let us say we have

```
going_to_office = True
if going_to_office: 
     print("Work from office")
else:
     print("Enjoy work from home")
``` 
So if the condition on line#1 is not satisfied then the control moves to `else` and the statement under the `else` condition is executed.


### Example 3:- 

Let us say we have the `if elif else` condition

```
going_to_office = False
be_at_home = True
if going_to_office: #condition1
    print("Work from office")
elif be_at_home:    #condition2
    print("Enjoy work from home")
else:
    print("Work from Starbucks")
``` 
So if the `condition1` and `condition2` are not satisfied then the statement under the `else` condition is executed.


![Understand](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0m8cltda0thldx5ld49v.png)

## Conclusion
The basic conditional statements like `if`, `if elif` and `if elif else` is easy to understand, so do let me know what you guys think of this article💡.

Thanks in advance for reading this article...🚀

More than happy to connect with you on [@twitter](https://twitter.com/_nitinreddy3), [LinkedIn](https://www.linkedin.com/in/nitinreddy3/)
Machine Learning and Its Uses
Tags: wordpress, challenge, ai
Published: 2022-07-17 11:14:41

The different types of Image Annotation would include bounding box, polygon masks, 3D cuboid, semantic segmentation, polyline, and keypoint/landmark annotations.

[AIW](https://www.ai-workspace.com/) helps you leverage expert image annotation services to help you train your Machine Learning models with more accuracy and more humanized decision-making capabilities.

For More Information Please Visit Our Site: [https://www.ai-workspace.com/](http://ai-workspace.com/)

#aiworkspace
#globsynaiworkspace
#3rdlife
#annotationservices
#dataannotationjobs
#dataannotationservice
#dataannotationservices
#dataannotators
#datasourcingcompanies
#globsynbuilding
How I got my first job as a programmer (no CS degree)
Published: 2022-07-17 11:03:38

In this video I share how I found my first job as a software engineer without a Computer Science degree or attending a bootcamp:

{% embed https://youtu.be/j47m3pO6x8k %}

📖 Check out my book if you want to learn how I became a software engineer without a CS degree and how you can do the same: https://beetlehope.gumroad.com/l/fhIFH
hugo new site
Tags: hugo, terraform, precommit, editorconfig
Published: 2022-07-17 11:00:12

## `git init`

I started by dogfooding[^1] my [template repository](https://github.com/imomaliev/library-template). It allows me to use [`terraform`](http://terraform.io) to manage GitHub repository declaratively. If you're not familiar with "Infrastructure as Code" I highly recommend giving it a try, the declarative approach to configuration management and resource provisioning makes repetitive tasks so much easier. Also, it already has [`editorconfig`](https://editorconfig.org) and [`pre-commit`](https://pre-commit.com) configuration.

After I initialized my blog with terraform and configured git to use created repo as a `remote`. I am ready to create new Hugo site.

## `hugo new site`

1. Create empty Hugo site
    ```console
    $ hugo new site blog
    ```
1. Add [`.gitignore` for `Hugo`](https://github.com/github/gitignore/blob/main/community/Golang/Hugo.gitignore)
1. Configure `pre-commit` to validate and format `toml` and `json` files.
1. Configure `editorconfig` for `toml` and `json` files.

[^1]: https://en.wikipedia.org/wiki/Eating_your_own_dog_food
Kubet Online
Tags: kubet, kubetonline, kubetcasino, kucasino
Published: 2022-07-17 10:55:08

Kubet Online✔️ là trang chủ đăng ký, đăng nhập chính thức cho hội viên. ✔️ Nhà cái Kubet uy tín hàng đầu Châu Á với nhiều khuyến mại lớn.
TỈ LỆ TRÚNG VÀ HOÀN TRẢ CAO
KU có tỉ lệ trúng và hoa hồng hoàn trả lại cho người chơi cao nhất. Tỉ lệ Xổ Số cao, mức hoàn tiền lớn, kèo bóng có tỷ lệ cao nhất hiện nay.
ĐĂNG KÝ DỄ DÀNG VÀ BẢO MẬT
Đăng ký tài khoản KU BET cực kỳ dễ dàng trên mọi điện thoại di động, máy tính bảng, và máy tính. Thao tác nhanh chóng, chỉ trong 1 phút và hoàn toàn bảo mật tài khoản người chơi.
NẠP VÀ RÚT TIỀN NHANH CHÓNG
Chúng tôi có đội ngũ nhân viên chuyên nghiệp luôn sẵn sàng hỗ trợ 24/7. Bạn chỉ mất 5 phút để nạp tiền và rút tiền từ tài khoản người chơi về ngân hàng của mình...
Địa chỉ: 920 Lạc Long Quân, Phường 8, Tân Bình, Thành phố Hồ Chí Minh
Email: Kubetonline7979@gmail.com
Website: https://kubetonline.net/
Facebook: https://www.facebook.com/kubetonlinenet/
Map: https://goo.gl/maps/fE4ECTAENn8Fmafe9
Pinterest: https://www.pinterest.com/kkubetonline/
Flickr: https://www.flickr.com/people/kubetonlinenet/
Twitch: https://www.twitch.tv/kubetonlinenet
Linkedin: https://www.linkedin.com/in/kubetonlinenet/
Youtube: https://www.youtube.com/channel/UCKiDNBku6Afz-yvgjjORojw
Twitter: https://twitter.com/kubetonlinenet
Building the plane while flying it
Tags: hugo, terraform, precommit, editorconfig
Published: 2022-07-17 10:53:00

> _Build the plane while you’re flying it_[^1]

## New beginnings

In the February 2022 I finally decided to create my personal blog. I've chosen the [`Hugo`](https://gohugo.io) as a framework for building it. On the landing page, it bravely declares:

> The world’s fastest framework for building websites.
> With its amazing speed and flexibility, Hugo makes building websites fun again.

and after using it, I can confidently say it really lives up to what it promises. It was a little confusing at the start, but after I got the hang of it, it was a breeze. But for some reason, after I've ported all may personal [`TILs`](https://github.com/imomaliev/til) to it, I stopped using it at all. It wasn't the framework's fault, the problem was that my life got out of control, and I was so overwhelmed with personal issues, this lead to me always putting blogging off to a letter date. But may be this time it will be easier sticking to it, because to help myself to keep blogging, I decided to blog about blogging. I know this may sound redundant, but I think it will be interesting because I want to share and document how this blog project is being developed. This partly because of my annoying habit of always starting a new instead of continuing an existing project, and partly because I want to journal my journey.

## Building the plane while flying it

I will start from the very beginning and create this blog from the scratch. This series is called "Building the blog while flying it". In the spirit of famous startup quote/approach, "Building the plane while flying it"[^2]. I think I will have a lot of fun. I am going to start by posting to my [`dev.to`](https://dev.to/imomaliev) page and host [blog repository](https://github.com/imomaliev/blog) on the GitHub. My first version of this blog is living in the [`blog-v1`](https://github.com/imomaliev/blog-v1) repo.

[^1]:
    https://www.csmonitor.com/The-Culture/The-Home-Forum/2016/0324/Build-the-plane-while-you-re-flying-it
    https://aydencreative.com/the-art-of-building-the-plane-while-you-fly-it/
    https://thedisruptionlab.com/building-the-plane-while-flying/
[^2]:
    https://www.youtube.com/watch?v=L2zqTYgcpfg
Entanglement isn't thaaat spooky - The shoe-box analogy
Tags: quantumcomputing, todayilearned, quantummechanics
Published: 2022-07-17 10:36:14

I had to do a bit of research in basic Quantum Computing, when reading about "spooky action at a distance" or entanglement I was intrigued, I though this could be used to transfer information over distances, this seems to be a common misconception, you can read [this Forbes article](https://www.forbes.com/sites/startswithabang/2020/01/02/no-we-still-cant-use-quantum-entanglement-to-communicate-faster-than-light/?sh=7807b71b4d5d) by a Ph.D. astrophysicist to understand why it doesn't work in detail, but I found a helpful analogy. It goes like this.
## The Entanglement shoe-box analogy
Assume you have a shoe-box, one of the shoes has been taken and placed at the end of the universe. When you open the shoe-box you observe you have the right shoe, that means the shoe at the other end of the universe is the left one(assuming a normal shoe box). This is how entanglement works. Changing the shoe in the shoe-box in any way has no effect on the shoe that's on the end of the universe, you see the shoe you get the information and that is it. In the article it's said that forcing a state (changing the shoe) would break the entanglement. It is also stated on entanglement that "You know something important about the sum of both states together", or in the shoe-box you know that it should contain both a left and right shoe(normally). :)
Number countdown with html css & javascript
Tags: html, csharp, beginners, tutorial
Published: 2022-07-17 10:30:06

Hello dear folks 👋

I'm [Atul](https://atulcodex.com) (Fulltime Webdeveloper)Nowadays I am working on a embroidery website on core languages like HTML, CSS and Js.

In that website we want to add countdown number section to showcase achievements like numbers of year in business, numbers of professionals in workshop, etc.

### To full fill that requirement I have designed this countdown number card.

To help our community I thought, I have to share with you. 

![radhe radhe](https://media.giphy.com/media/3d2raMt66IwhG1s7V3/giphy.gif)

### So please use it as per your requirement, codepen 👇🏻


{% codepen https://codepen.io/atulcodex/pen/mdxRBvY %}

## also read

{% link https://dev.to/atulcodex/scroll-to-top-button-with-just-html-css-1c2 %}
Scope in JavaScript
Tags: javascript, webdev, beginners
Published: 2022-07-17 10:22:18

Scope refers to the current context of javascript code execution.

This is where values and expressions are available or "visible" and can be referenced by the running program.

Values not visible or not available in the current execution context will **_NOT_** be available for use by your currently executing code.

Although scope can seem an easy concept to understand, in practice it sometimes trips even seasoned developers.

**NOTE**: Scope is normally hierarchically nested such that the child scope can reference the parent scope but the parent **_CANNOT_** reference the child scope.

In JavaScript, there are three types of scope and these include:

- The Global scope
  This is the default scope for any code that runs in script mode i.e everything runs line by line without any strict execution contexts
- The Module scope
  This scope occurs when code runs in module mode
- The Function scope
  As it suggests, this scope is created inside a function.

## Variables and Scope

In addition to the 3 scopes above, when variables are declared with ES6 syntax, `let` and `const`, a different scope is created:

- The Block scope
  This is the scope created within the body of a pair of curly brackets.

Note that the `var` keyword does not implement the block scope.

## Function Scope Example

```js
function functionScopeExample() {
  var name = "Anjette"; //=> available only within functioScopeExample() body

  console.log(name); //=> Anjette
}

functionScopeExample();

console.log(name); //=> ReferenceError: name is not defined
```

In the above snippet, we are not able to reference the `name` because its scope is limited to the `functionScopeExample` body i.e function scope.

The variable `name` is however successfully referenced within the function scope.

## Global Scope Example

Let us move the variable to a global scope:

```js
var name = "Anjette"; //=> available throughout the script i.e global scope
function globalScopeExample() {
  console.log(name); //=> Anjette
}

globalScopeExample();

console.log(name); //=> Anjette
```

In the above example, the variable has been declared in a global scope and thus it is available both inside the function and outside the function scope.

## Block Scope Example

A block is defined by a pair of curly brackets.

```js
{
  const name = "Anjette";
  // let name = "Anjette";
}
console.log(name); //=> ReferenceError: name is not defined
```

By using `const` or `let`, as shown in the snippet above, the variable `name` cannot be accessed outside the block. It is only accessible inside the block where it has been declared.

With the `var` keyword, the behavior is different.

```js
{
  var name = "Anjette";
}
console.log(name); //=> Anjette
```

Although the variable in the above snippet is declared in a block, the `var` keyword makes still available outside the block.

## Key Takeaways

- Scope defeines the extent to which variables are visible in a program
- There are 4 types of scopes in JS: global, function, module and, block.
How to trigger a fail2ban action to t6 ?
Tags: javascript, beginners, t6, tutorial
Published: 2022-07-17 10:17:28

This recipe get you introduced to [t6-iot](https://www.internetcollaboratif.info) and a fail2ban custom script that collect t6 datapoints from fail2ban jail.

> Considering t6 and fail2ban are already installed and running ; all you need to do is to create the flow container on t6 and then customize the fail2ban jail & action.

## Create a specific Flow on t6
Edit the following file:
> vi /home/user/fail2ban2t6.sh
And add the content from the [template](https://github.com/mathcoll/t6/blob/master/etc/fail2ban/action.d/fail2ban2t6.sh).

Please note you might need to edit line 13 of this file according to the directory containing the file.

Then, you’d need to create the config file from the [template](https://github.com/mathcoll/t6/blob/master/etc/fail2ban/action.d/fail2ban2t6.secret.conf).
And finally, edit this secret file according to your own settings:
> vi /home/user/fail2ban2t6.secret.conf

## Set the fail2ban jail
Edit the file so that action contains fail2ban2t6 e.g.:
> vi /etc/fail2ban/jail.local

`[apache-404]
enabled = true
filter = apache-404
logpath = /var/log/t6-error.log
          /var/log/t6-access.log
maxretry = 4
findtime = 300
bantime = 86400
banaction = iptables-allports
action=iptables-allports
       fail2ban2t6
port = smtp,465,submission,imap,imaps,pop3,pop3s,http,https`

## Create the action script
Create the file on your server from the [template](https://github.com/mathcoll/t6/blob/master/etc/fail2ban/action.d/fail2ban2t6.conf)
> /etc/fail2ban/action.d/fail2ban2t6.conf

## Check all and restart fail2ban
Usually, this can be done using the following root command:
> sudo systemctl restart fail2ban

And then, each time an IP address is found on apache-404 jail, it will be sent as a datapoint into t6 Flow.
What is the Spanning tree protocol (STP)? How do STP works?
Tags: stp, s3, network
Published: 2022-07-17 10:10:29

The spanner tree protocol (STP) prevents network loops on layer 2 network switches. Monitor the network to shut down redundant links and track all links. In addition to providing redundancy, redundant links between switches can also cause loops during broadcasts.

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

When you have redundant links between switches, span trees prevent loops. We can also avoid the broadcast storm, frame copies, and instability databases with the spamming tree. Spamming is an open standard (IEEE 802.1D). All Cisco Catalyst switches come with spanning trees enabled by default.

Spanning-tree terms

The root bridge is the one with the lowest best bridge ID. The bridge ID is the priority + MAC address of the switch. All the switches in an STP network elect a root bridge, which becomes a central point in the network, and all the remaining switches become non-root bridges.

Non-root bridges are bridges that are not Root Bridges. In each LAN, there is only one Root Bridge, and all the other bridges are Non-Root Bridges. The non-root bridge exchanges BPDUs with all the other bridges and updates the Spanning tree topology database.


All switches exchange information called bridge protocol data units (BPDUs) to be used for subsequently configuring the network. A BPDU is sent every two seconds and has a maximum age of 20 seconds. Within the BPDU is the bridge ID. The BPDU contains information about ports, switches, port priority, and addresses.

On all Cisco switches, bridge ID is a combination of bridge priority 32,768 and the MAC address. The root bridge in the LAN is the bridge with the lowest bridge ID.

When there are multiple links between two switches, the port cost determines the most efficient route. Each bridge finds the most efficient path to the root bridge.

For each unique path, the path cost is calculated by adding the port costs encountered along the way to the root bridge.

Port of bridge

The root port is the link with the lowest path cost to the root bridge.


The cheapest way to get on a network segment is by designating a port. Designating port is a forwarding port, and we can only have one forwarding port per network segment.

Non-designating ports are more expensive than designating ports. They are blocked or discarded.

The forwarding port is either a root port or a designating port. This port forwards frames.

Blocking ports don't forward frames, but they listen to BPDU frames from their neighbors.

The spanning-tree Port States.

Administrators can manually disable the disabled state.

The blocking state is used to prevent loops. Upon switching on, all ports are blocked for 20 seconds.

 Listening state: During this state, the port listens to the BPDU to ensure no network loops are occurring before passing data frames. This takes 15 seconds.


In this state, BPDU is listened to and all paths in the switch network are learned in 15 seconds.

All data frames on the bridge port are sent and received by the forwarding state.
Kadane's Algorithm
Tags: java, algorithms, datastructure
Published: 2022-07-17 09:22:54

**Kadane's Algorithm** is one of the algorithms to efficiently find maximum sum of continuous subarray.

Given an array Arr[] of N integers. Find the contiguous sub-array(containing at least one number) which has the maximum sum and return its sum.


**Example 1**:

```
Input:
N = 5
Arr[] = {1,2,3,-2,5}
Output:
9
Explanation:
Max subarray sum is 9
of elements (1, 2, 3, -2, 5) which 
is a contiguous subarray.
```

```java
class Solution{

    // arr: input array
    // n: size of array
    //Function to find the sum of contiguous subarray with maximum sum.
    int maxSubarraySum(int arr[], int n){
        
        int maxSoFar=0,maxTillHere=0;
        for(int i=0;i<n;i++){
            maxTillHere+=arr[i];
            if(maxTillHere>maxSoFar){
                maxSoFar=maxTillHere;
            }
            if(maxTillHere<0){
                maxTillHere=0;
            }
        }
        return maxSoFar;
        
    }
    
}

```
Github Design Philosophy
Published: 2022-07-17 09:14:39

Every Hitech company has a set of guiding principles for creating its goods, but sometimes it might be hard to find these philosophies if you don't work for that company. Github is really different because you can be able to quickly become comfortable with the GitHub design philosophy through an API request.

`curl https://api.github.com/zen  
`
If you use the aforementioned curl command repeatedly, you will receive one philosophy. for instance:

- Non-blocking is better than blocking.
- Half measures are as bad as nothing at all.
- It's not fully shipped until it's fast.
- Keep it logically awesome.

Let's explore other philosophies just by API calls...
Find Weather Path Exists GeeksForGeeks
Tags: java, algorithms, matrix, datastructure
Published: 2022-07-17 09:14:20

Given a grid of size n*n filled with 0, 1, 2, 3. Check whether there is a path possible from the source to destination. You can traverse up, down, right and left.
The description of cells is as follows:

1. A value of cell 1 means Source.
2. A value of cell 2 means Destination.
3. A value of cell 3 means Blank cell.
4. A value of cell 0 means Wall.
**Note**: There are only a single source and a single destination.

**Example 1**:

```
Input: grid = {{3,0,3,0,0},{3,0,0,0,3}
,{3,3,3,3,3},{0,2,3,0,0},{3,0,0,1,3}}
Output: 0
Explanation: The grid is-
3 0 3 0 0 
3 0 0 0 3 
3 3 3 3 3 
0 2 3 0 0 
3 0 0 1 3 
There is no path to reach at (3,1) i,e at 
destination from (4,3) i,e source.
```
**Solution**:
```java
class Solution
{
    //Function to find whether a path exists from the source to destination.
    public boolean is_Possible(int[][] grid)
    {
        // Code here
        for(int i =0;i<grid.length;i++){
            for(int j =0;j<grid[0].length;j++){
                if(grid[i][j]==1) {
                    return isDestinationPossible(grid,i,j);
                }
            }
        }
        return false;
    }
    public boolean isDestinationPossible(int[][] grid, int i, int j){
        if(i<0 || i>=grid.length || j<0 || j>= grid[0].length ||
         grid[i][j]==0 || grid[i][j] ==-1) return false;
         if(grid[i][j] ==2) return true;
         int temp = grid[i][j];
         grid[i][j] = -1; //means this has been visited;
                 // up move
        return  isDestinationPossible(grid,i-1,j)||
                // down move
         isDestinationPossible(grid,i+1,j) ||
                // left move
         isDestinationPossible(grid,i,j-1) ||
                // right move
         isDestinationPossible(grid,i,j+1);
         
    }
}
```
Python's Netmiko template
Tags: netmiko, python
Published: 2022-07-17 09:14:05

The following is a ready to go netlike template , you just need to choose your way of authentication and the device type , you can find the supported devices on both the documentation and the Git for the Netmiko library :

**Netmiko Source Code :** [Netmiko Github](https://github.com/ktbyers/netmiko)
**API reference** _(must check for more functionality)_ : [Netmiko Doc](https://ktbyers.github.io/netmiko/docs/netmiko/index.html)

```python
# netmiko_starter.py 
from netmiko import ConnectHandler

device_dictionary = {
                    'device_type': 'DEVICE_TYPE',  
                    'host': 'DEVICE_IP_ADDRESS',
                    'username': 'USERNAME',
                    'password' : 'PASSWORD',
                    # 'verbose': False ,
                    # 'session_log': 'log.txt', 
                    # 'global_delay_factor': 2, 
                }
net_connect = ConnectHandler(**device_dictionary)
output = net_connect.send_command("show version")
net_connect.disconnect()
```

## Comments on the code : 
  * uncomment _verbose_ if you want to disable Netmiko's Logs .
  * uncomment _session_log_ to debug the connection failures .
  * uncomment _ global_delay_factor_ to add delay when waiting for commands output , very useful if the devices are slow , note that this is not in seconds but in multiple , so "2" mean multiply the default delay by 2 and so on 

For more functionality , like the types of devices supported ,  please check the API docs .

Also check the textfsm templates part of the guide , this helps a lot with parsing the output instead of using the normal Regex way , it supports a lot of well known devices outputs .

good luck