teleren/devto huggingface dataset:
Selection and Iteration in C
Tags: c, beginners, tutorial, programming
Published: 2022-03-28 22:44:44

## Selection Statements

Selection statements are used to choose among alternative actions.

### if

```C
if( Condition )
{
    Action;
}
```

```C
if(grade >= 60)
{
    puts("Passed");
}
```

### if .. else

```C
if(Condition)
{
    Action_1;
}
else
{
    Action_2;
}
```

```C
if(grade >= 60)
{
    puts("Passed");
}
else
{
    puts("Failed");
}
```

### if .. elseif

```c
if(Condition_1)
{
    Action_1;
}
else if(Condition_2)
{
    Action_2;
}
else if(Condition_3)
{
    Action_3;
}
else
{
    Action_4;
}
```

```c
if(grade >= 90)
{
    puts("A");
}
else if(grade >= 80)
{
    puts("B");
}
else if(grade >= 70)
{
    puts("C");
}
else if(grade >= 60)
{
    puts("D");
}
else
{
    puts("F");
}
```

### switch

```c
switch(Condition)
{
case 1:
    Action_1;
    break;

case 2:
    Action_2;
    break;

case 3:
    Action_3;
    break;

default:
    Action_4;
    break;
}
```

```c
switch(mark)
{
case 'A':
    puts("Student got excellent grade");
    break;

case 'B':
    puts("Student got very good grade");
    break;

case 'C':
    puts("Student got good degree grade");
    break;

case 'D':
    puts("Student got fair grade");
    break;

default:
    puts("Student should retake the exam");
    break;
}
```

### Conditional Operator

This is the only C ternary operator. It is used in place where `if .. else` can't.

```c
Condition ? True Action : False Action;
```

```c
grade >= 60 ? puts("Pass") : puts("Fail");
//or
puts(grade >= 60 ? "Pass" : "Fail");
```

---

## Iteration Statements

An iteration statement (repetition statement or loop) allows you to specify that an action is to be repeated while some condition remains true.

### while

```C
while(Continuation_Condition)
{
    Action;
}
```

```c
while(grade < 60)
{
    puts("Retake the exam");
}
```

### do .. while

```c
do{

    Action;

}while(Continuation_Condition);
```

```C
do{
    //do the action once at least before check the condition
    puts("Start the Exam");

}while(grade < 60>);
```

### for

```c
for(Initialization; Continuation_Condition; Increment)
{
    Action;
}
```

```c
for(int i = 1; i <= 10; i++)
{
    printf("%d ", i);
}
```

### Iteration Types

1. Counter-Controlled
1. Sentinel-Controlled

#### Counter-Controlled Iteration

We know in advance exactly how many times the loop will be executed.

#### Sentinel-Controlled Iteration

We don't know in advance how many times the loop will be executed. We use sentinel value (flag value) to indicated "End of Data" entry.
The 2022 CodeLand CFP Closes on March 29 @ 11:59 PM UTC ⏰
Tags: codeland, codeland2022, announcements
Published: 2022-03-28 22:43:01

---
title: The 2022 CodeLand CFP Closes on March 29 @ 11:59 PM UTC ⏰  
published: true
description: 
tags: codeland, codeland2022, announcements
cover_image: https://community.codenewbie.org/remoteimages/uploads/articles/6y2rtusrt3su0oxr1awa.png
---

Hey everyone!

I just wanted to stop by with a quick reminder that the 2022 [CodeLand](https://codelandconf.com) Call-For-Proposals (CFP) closes tomorrow, March 29 @ 11:59 PM UTC. If you'd like to share a talk directly with a global audience of early-career software developers and their champions, this is your chance! The conference will be taking place remotely on June 16 & 17 and we couldn't be more excited.


### [>> Jump straight to the CFP form here](https://cfp.codelandconf.com/events/codeland-2022)

### [>> Read more about CodeLand and the CFP here](https://community.codenewbie.org/codenewbie/codeland-2022-is-coming-in-june-submit-your-talk-today-2gnc)



#### Our program committee is looking forward to reading about the talk you'd like to deliver ❤️ 

---

_[CodeLand](https://codelandconf.com) is the tech industry’s friendliest conference for early-career programmers and their mentors. Stay tuned for details on how to register._
Writing Redirects in Kubernetes' Nginx Ingress
Published: 2022-03-28 22:39:52



**Are you using Kubernetes and want to redirect a www website to its non-www counterpart, or vice versa?** Hey, me too! 😃

I recently re-launched the website for dictate.life and in the midst of planning the deployment I realized that there were a couple of simple requirements that I hadn’t been fully aware of at first:

- I want people to be able to access the site via https://www.dictate.life or https://dictate.life (or even http://dictate.life, for that matter!)
- While you’re browsing the website, I want the address bar to always show that you’re on the www. version of the site.

I’m familiar with performing this sort of task using a 301 redirect in a traditional Apache or Nginx environment, but I was unfamiliar with how to do this in a Kubernetes environment. Here’s how I ended up accomplishing it:

```yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  namespace: default
  name: my-nginx-ingress
  annotations:
    ...other annotations...
    kubernetes.io/ingress.class: "nginx"
    nginx.ingress.kubernetes.io/configuration-snippet: |
      if ($host = 'myhost.com') {
        return 301 https://www.myhost.com$request_uri;
      }
```

The neat thing about this redirect is that it not only redirects requests to the root path, /, but also to any other path. So if someone visits http://dictate.life/about, they’ll be taken to the correct HTTPS-enabled, www-toting version of the url 🎉

This isn’t the only way to use the **configuration-snippet** option of Kubernetes’ nginx ingress. I’ve found that the above snippet best suits my needs, but let’s say that regardless of the URL input by the user, you always wanted to redirect them to the root. This would be a useful situation if you were moving to a new website where the URLs didn’t match. In that case, you’d simply leave off the **$request_uri** portion, e.g.

```yaml
nginx.ingress.kubernetes.io/configuration-snippet: |
  if ($host = 'myhost.com') {
    return 301 https://www.myhost.com;
  }
```

This is the best way I’ve found to apply configuration changes to one ingress, assuming that you have only one. Nginx ingress also supports altering the default configuration of multiple ingresses at once, using **ConfigMaps**. More info on that can be found here: https://kubernetes.github.io/ingress-nginx/examples/customization/custom-headers/

Want to learn more? Here's a shameless plug:  come watch me code or ask me a question on my Twitch stream! https://www.twitch.tv/malgasm/

_original article: https://malgasm.com/blog/32/write-redirects-in-kubernetes-nginx-ingress-how-to_
How to find exactly what you search for on LinkedIn
Published: 2022-03-28 22:34:36

I'm sure that a lot of us have used the LinkedIn job search functionality a few times. But have you felt frustrated that a lot of the times, even with specific filters, you still get undesired results?

Say, you're looking for GoLang jobs, but end up with mixed results containing other languages like PHP, Python, etc.

This is time-consuming and effort-wasting. But not anymore, with LinkedIn's Boolean Search feature.

It applies the same logical operators used in programming: AND, OR, NOT in addition to the quotes for exact matches.

If you were like me, a nodejs developer interested in full stack(backend-heavy) opportunities, then your query might look something like this(as shown in the photo):

> (node OR nodejs OR "node js" OR "Node.js" OR nestjs OR expressjs) AND (remote OR remotely) NOT (ruby OR php OR go OR rust OR asp OR asp.net OR c# OR rails OR Selenium OR WebDriver OR "Java" OR "java")

Don't forget to adjust the rest of the filters from the menu; such as
`Sort by: Recent 
Date Posted: Past Week `

or whatever you prefer.

In the end, I leave you with the official LinkedIn document explaining all possible modifiers: https://business.linkedin.com/content/dam/business/talent-solutions/global/en_us/ms/Campaigns/ber/pdf/linkedin-recruit-boolean.pdf

And the help page for Boolean Search on LinkedIn Help: https://www.linkedin.com/help/linkedin/answer/a507571

You're welcome :)


![Boolean Search Example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9p463sftj52jukii480b.jpeg)
AWS IoT - Securing Your Connected Devices, Connections, and Data
Tags: aws, awscommunity, security, automation
Published: 2022-03-28 22:09:49

**AWS IoT**

Audit | Detect | Alert | Mitigate

[Defend](https://us-east-1.console.aws.amazon.com/iot/home?region=us-east-1#/dd/intro)

- 
Device Defender
AWS IoT Device Defender is a fully managed service that helps you secure your fleet of IoT devices.

[Secure](https://docs.aws.amazon.com/iot/latest/developerguide/iot-security.html)

- 
Certificates - attached to AWS IoT thing/device.
	Device certificates that are used by devices and clients to connect to AWS IoT.

_Audit_

- Results

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

- Schedules
You schedule the frequency of the audit and what checks are to be performed during each scan. For this lab and test IoT device, I have selected the recurrence of Monthly and covering medium, high, and critical checks I wish to have run. 

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

- Action Tasks
Based on audits performed, there may be various audit action tasks.

- Finding Suppressions
Allow you to turn off findings related to a resource for a defined period of time until the resource is fixed, or indefinitely due to some exception.


_[Detect](https://docs.aws.amazon.com/iot/latest/developerguide/device-defender-detect.html)_

- **Alarms**
When a device behavior anomaly is detected. 

- **Security Profiles:**
 Security Profiles define how your devices should behave and specify an alert mechanism for anomalies. Security Profiles are attached to one or more things. 

For this example, I am going to create a new ML anomaly detection profile. 

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


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


- **Mitigation Actions**

**Automation, automation, automation!!**

	Below is an example where we can create a rule or action to be taken to help mitigate the issue(s) found during an audit or some other ongoing detection/monitoring. 


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

[_Alerting_ ](https://us-east-1.console.aws.amazon.com/iot/home?region=us-east-1#/dd/securityProfile)

(AWS IoT | Device Defender | Detect | Security Profiles [ThingName] )

- **Alarms (Active / History)**

- **Defender Metrics**

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

- **Behavior and ML Training**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3864z9btpj4rgc2iioux.png)
Looking for Feedback
Tags: beginners, webdev, react, javascript
Published: 2022-03-28 22:07:25

Hello Everyone, I'm a Software Engineer currently looking for a Job, [this ](https://biccs.dev/)is my portfolio, would love to read some feedback from you guys! 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pz5frrovw1giqlc4fs9b.JPG)
#Web #Scrapping #Data #Python
Published: 2022-03-28 22:05:24

## https://github.com/maximC137/web-scrapper
Web scrapping is about getting the data in the web in a form of a HTML code.It's legal depending  on what are doing with this tool .It's  a tool in which data scientists use it.The goal is to extract specific information in a programming method.We can use to find tags like <h1></h1> or certain images ,plus we can extract data tables to use as datasets for pandas project or even Excel.
For simplicity I'm going to use BeautifulSoup library ,we can use soup functionality  instead of strings.To check the result of your code ,you can simply right click the webpage and select inspect, and that you inspect the HTML code of the page and compare it to your results in the python IDE you use.We can use class keyword in the HTML code of a page also ,and not forget to see other tags such as ('tr') or ('td') and so on.
Note :I used this site in my code ,you can try it on any site you like.
This is my GitHub profile and follow me to see more projects and browse codes of different projects.
https://github.com/maximC137/
follow me on Facebook and LinkedIn  
https://www.linkedin.com/in/maxim-kurdi-5a4b62226[](url)
Where all DEVs fail in Security
Tags: infosec, webdev, programming, backend
Published: 2022-03-28 21:34:49

**Intro**
I have been in security for several years. My work is to test an application or an infrastructure and try to break in.
If you are a developer the following is probably one of the vulnerabilities you may find in your applications. If you are elite in security and dev, then stop and close this thread.

Most developers lack of the proper knowledge of Information Security. In this post I am talking about the access control issues.

**Access Controls**
When one designs an application, roles and permissions may be given to users. At most of the time, i find vulnerabilities in user elevation of privileges. This is a particular type of an access control issue, where a low-priv user can escalate to an higher-privilege user. Make sure ALL of the functions are protected so low-priv users, even if they can load the UI, do not have the permissions to execute any endpoint which requires higher privileges. You may think, that this may sound too dump. But most of the applications suffer from such vulnerabilities. Moreover, such vulnerabilities can lead to account takeover!

**IDORS**
Another type of an access control issue is an IDOR one. Many endpoints support numerical parameters. An example is a "pageId", in a GET request. Most of the time, the endpoints have all sort of checks, like for XSS or SQL-Injections, but the developers often forget to check if the ID can be used to access information that doesn't belong to user. Due to the incremental number of ID, most of the time this kind of vulnerability is easy to exploit. Make sure the users can access to information belongs to them by properly enforcing access control rules.

**Summary**
A great number of developers takes such vulnerabilities as low-risk, but the reality is that such issues are of a high-risk or of critical risk. Imagine the ID to be an order ID, or the low-priv users to be able to set the password of the admin, or even become admin their-self. Such issues happen and I can confirm are happening more than often. 

Thanks for reading, take care, and follow me for more tips.
Creating an SQLite Database From Excel Workbook.
Tags: database, beginners, dataanalytics, pandas
Published: 2022-03-28 20:49:27

A database is an organized collection of rows and columns with data that are related to each other. Sometimes you have an excel worksheet and would like to query it using SQL. This post  takes you through using Pandas to create an SQLite database from an excel sheet. So let's jump into it .

##Step 1:Load the dataset to Pandas##
To load the dataset from excel to pandas use the following commands:
       ```python 
          import pandas as pd 
          import sqlite3
          df=pd.read_excel('path to file')```
_Import pandas as pd_ tells python to bring the pandas data analysis library into your current environment. _pd_ portion of the code tells python to give pandas the alias pd. This means you can use pandas by typing pd. _Import sqlite3_ provides an SQL-like interface to read,query and write SQL databases from python._df=pd.read_excel('path to file')_ tells pandas to read the excel document in a specific location.

##Step 2: Create SQLite database using sqlite3.connect()
The following sample code creates an empty database file called _Day.db_ and assigns it to a variable _db_conn_
       ```db_conn=sqlite3.connect('Day.db')```
 This provides an interface for working with the SQLite database.
##Step 3:Create a cursor object to run the SQL code that will create the data tables.
_Cursor_ is an instance using which you can invoke methods that execute SQLite statements from the result sets of the queries i.e makes the connection for executing SQL queries on the SQLite database.
    ```cur=db_conn.cursor()```

##Step 4:Create a table
This is a command used to create a table called DayofWeeek with new columns Day and Sum.The data type for each column is specified to the right of the column name.
    ```create_table="CREATE TABLE DayofWeek(Day TEXT,Sum INT)```
 The column names must match those stored in the dataframe.
##Step 6:Moving from pandas dataframe to SQL table
.to_sql command is used to write records stored in a dataframe to a SQL database._DayofWeek_ specifies the the name of SQL table created.
_if_exists='append'_ inserts new values into the existing table DayofWeek._index=False_ to avoid bringing the dataframe index as a column.
    ```df.to_sql('DayofWeek',db_conn,if_exists='append', index=False)```
You can run your sql commands on pandas for example:
     ```pd.read_sql("SELECT * FROM DayofWeek",db_conn)
Coder offers up to $30k referral bonus for engineers
Tags: discuss, career, go, hiring
Published: 2022-03-28 20:39:09

Going through my inbox this morning, I almost spit out my coffee when I read the headline.  [Coder](https://coder.com/), which is an [alternative to Github's Codespaces](https://dev.to/theaccordance/coder-is-github-codespaces-but-for-the-enterprise-41nb), is offering [up to $30,000 to refer Staff and Principal level engineers](https://coder.com/blog/get-up-to-30-000-to-refer-great-engineers-to-work-at-coder?utm_campaign=Newsletter&utm_medium=email&_hsmi=208194729&_hsenc=p2ANqtz-8Zv1o9QRulLfmCD6usup8dwTlkVZZ-U5Vgms1Ojwx4U331irHEPgla_RElmnf2hioX51jcdD8eHUFx0renXRuScUCV9Ngz9aGMhr3DDxHmjxznejE&utm_content=208194729&utm_source=hs_email) to join their company.  Sorry, Juniors.  

Specifically, Coder is willing to pay a referral of:
- $15,000 for Staff Level Engineers 
- $20,000 for Principal Level Engineers
- Up to 50% additional if the hired candidate is from an under represented group

Take a look at Coder's [careers page](https://coder.com/careers#openings) for a full list of openings. My sample review of roles implied that Coder is looking for skills in C/C++, Rust, Golang, and Typescript.  Personally, I have never worked for Coder, but I have been a customer of theirs for a year.  Their product has delivered a lot of value to our engineering team of 50, and I would recommend them to any other enterprise-grade team striving for continuous integration and delivery.  

If you happen to know someone, feel free to share them this link.  But if you decide to apply yourself, I humbly ask that you reach out to me so I can provide you with my referral info when you apply.
BEST BLOCKCHAIN 101 VIDEO ON YOUTUBE
Tags: blockchain, web3, solidity
Published: 2022-03-28 20:38:59

This video is easily the best introduction to block chain you can find anywhere. When people ask about blockchain technology, I always refer this video. Explained in the language of a 5 year old, the underlying concepts are easy to grasp, and forms for a beginner, a mental framework and guideline as they dive deeper. Many thanks to Anders Brownworth for making this ultimate beginners guide. Oh, You can thank me later.

{% youtube _160oMzblY8 %}
Graph Implementation Example in Java
Tags: java, datastructures, tutorial, career
Published: 2022-03-28 20:34:59

In this article you will see a **graph implementation example in Java from scratch**. You will learn how to create and use a graph data structure in Java, practicing with a real exercise that I have seen in **many interview processes**.

The example is an exciting and challenging problem to solve. Firstly I will introduce the problem itself and a possible way to solve it in Java.

## The problem

A **delivery service company** creates a system that will plan a route for a delivery truck to deliver customer orders. The planner will create a delivery area for each order, which is abstracted as a grid. The challenge is to write an algorithm to find a path for the truck to deliver the order.

The delivery area is represented as a **two-dimensional grid** of integers where:

- 1 represents an accessible area
- 0 represents a non-accessible area
- 2 represents the order destination

This exercise is an excellent example in Java of how using the correct data structure can turn a seemingly complex problem into something much more straightforward. The problem becomes simpler when you **use a graph implementation**.

Some stuff you should consider before starting. The truck can’t leave the grid and should get to the order destination through the accessible areas. And the truck can move one cell up, down, left, or right at a time.

Here are some examples of different cases with the inputs and the corresponding outputs:

```
  Example 1
  grid = [[1,1,0],[0,1,2][0,1,1]]
  Output: [0,0][0,1][1,1][2,1][2,2][1,2]
  
  Example 2
  grid = [[1,1,1,1],[0,1,0,1],[0,1,0,1],[0,1,1,0],[0,1,2,1]]
  Output: [0,0][0,1][1,1][2,1][3,1][3,2]
```

## Solution

The best solution to this problem is using a java graph implementation. In general, a **graph** is the right solution for **any situation where you need to navigate a grid**.

This solution will have two classes: `Cell` class representing each matrix cell, and `DeliveryArea` representing the area the truck should navigate. See the skeleton below, just the class and the method signatures. We will complete the implementation in the next section.

{% youtube Z0qdLDwO2ns %}

```
public class Cell {
    public int row;
    public int col;

    public Cell(int row, int col){
        this.row = row;
        this.col = col;
    }

    public String hashKey(){
        return String.valueOf(this.row)+String.valueOf(this.col);
    }
}
```
```
import java.util.List;
import java.util.Map;

public class DeliveryArea {

    private final static int ACCESSIBLE_CELL = 1;
    private final static int NON_ACCESSIBLE_CELL = 0;
    private final static int DESTINATION = 2;

    public int[][] matrix;

    public DeliveryArea(int[][] matrix){
        this.matrix = matrix;
    }
    private Map<String, List<Cell>> buildGraph(){
        return null;
    }
    public List<Cell> findRoute(){
        return null;
    }
}
```
[Check out the full solution](https://www.hellocodeclub.com/graph-implementation-example-in-java/#Write_Graph_Implementation_in_Java)