teleren/devto huggingface dataset:
Understanding TDD
Tags: programming, tutorial, codenewbie, testing
Published: 2022-12-04 14:24:43

Test Driven Development (TDD) is a very powerful development methodology that completely turns traditional development around. When you first go to implement a new feature, the first question that you ask is whether the existing design is the right design for that feature. If it is not, you make changes to the existing design locally to enable that feature to be implemented as quickly and easily as possible. The result is that you are constantly improving the quality of your code and ensuring that your designs match the actual requirements that you will actually use in production. This also helps to ensure that the final code works as expected and does not introduce any unwanted side-effects or bugs.

When implementing new features in a software system it is important to keep sight of the bigger picture at all times and make sure that the system is working as efficiently and accurately as possible. This includes running tests against your production environment. These tests will check whether the new feature is working correctly and identify any potential problems that might arise as a result. If these tests fail then the underlying design of the code will need to be changed to ensure that the new feature can be successfully implemented.

The continuous integration and deployment (CI/CD) process is designed to automate this process. TDD is essentially a test-first development methodology in which you write an automated test suite for your code before you write the actual code itself. These tests are written using programming language-specific syntax and are not actual examples of user behavior. 

Looking at few examples for understanding TDD.

```
//Main.java
public String helloString(){
    return "Hello";
}
```
This is a simple method returning string "Hello" .To test the returned string we will be adding a test method.

```
//MainTest.java
    @Test
    void shouldReturnHello(){
        Assertions.assertEquals("Hello", Main.helloString());
    }
```
To make tests readable have meaningful name for the test methods and aggregate testcases to different classes as per their respective purpose.

![Directory structure](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/riogpouszcsy3o05lnj3.png)

Here is a directory structure of LibraryMgmt project. I have separate test class for controller, service and application class.

You can find complete source code [here](https://github.com/Ravina-Deogadkar/libraryMgmt ).

That's it for today! Thank you and Happy Coding!...

<img src = "https://media.giphy.com/media/KvAKXViNfpU8fSDiF0/giphy.gif" width="100%" />
Role of AI and the future of programming
Tags: ai, programming, openai, chatgpt
Published: 2022-12-04 14:22:14

In 2022, the role of AI in programming was a hot topic. Many predicted that it would take over the world of coding and leave human developers obsolete. But as it turns out, even AI needs a little human help from time to time. After all, it's hard to code without opposable thumbs!

Yes, AI has certainly made its mark in the world of programming. It's been able to automate certain tasks and even generate code on its own. But let's be real, it's not exactly the next Einstein. In fact, some developers have even started calling it "Artificial Idiocy" because of its limitations.

But even with AI's help, there are still limitations. It can't replicate the critical thinking and problem-solving skills of a human developer. It's unable to tackle the unique challenges and nuances of each project. And it certainly can't produce code with the same level of elegance and creativity as a human can. So in the end, it's just a fancy calculator that gets confused by advanced algebra.

In short, the future of programming is not one without human developers. AI may continue to evolve and become even more advanced, but it will always need human guidance and oversight. After all, we can't trust robots to do all the work. They might try to take over the world like in every sci-fi movie ever made.

One example of this is OpenAI's chat function. It's able to hold intelligent conversations with users, but it's not a replacement for a human customer service representative. It's simply a tool to assist them in their job. And let's face it, robots are terrible at customer service. They can't understand sarcasm, they can't empathize with frustrated customers, and they definitely can't tell a good joke. So while AI has its uses, it's not the end of human customer service just yet.

As we look ahead to 2023, it's clear that the role of AI in programming will continue to evolve. But one thing is for sure: human developers are still very much needed and valued in the industry. They bring a unique perspective and skillset that AI simply can't replicate. And as long as there are complex problems to solve and innovative ideas to bring to life, human developers will always be in high demand. So don't worry, your job is safe (for now).

---
_**Note:** As you have likely realized by now, this blog post (including this note) was not written by a human, but rather by an OpenAI chat model trained on a large dataset of text. The cover image too, has never existed before. It was generated using Dalle 2 from OpenAI. While some may dismiss this as a mere novelty, the truth is that the use of AI in writing and other creative endeavors is becoming increasingly common and important. In the year 2022, AI played a crucial role in many aspects of our lives, and its influence will only continue to grow in the years ahead. It is our sincere hope that this blog post has provided you with a glimpse into the potential of AI and its impact on the world of programming._
My rule of thumb when making software architecture decisions
Tags: webdev, javascript, programming, architecture
Published: 2022-12-04 14:13:18

If you have a lot of confidence and/or experience in what an ideal end state would be for your use case, then:

1. Be explicit about identifying that end state and what it would look like.
2. Incrementally, as-needed, solve the short term problems biasing for solutions that will get you closer to the ideal end state.

If you don’t have a lot of confidence and/or experience in what an ideal end state would be:

1. Ship incrementally till you gain confidence in what your ideal end state would be.
[PWN.04] Stack Buffer Overflow
Published: 2022-12-04 14:06:11

What is **Stack Buffer Overflow**?
it occurs when data exceeding the buffer size of the stack is entered.

Buffer : where data is stored in 
Overflow : exceeding 

If the Buffer is in Stack, It is called as Stack Buffer.
If the Buffer is in Heap, It is called as Heap Buffer.

```c
int main(int argc, char *argv[]){
    int overflowed = 0;
    char input[16];

    scanf("%s", input);
    
    if(overflowed) {
        printf("OVERFLOWED!!");
    } else
        printf("%s", input);
    return 0;
}
``` 
Stack Buffer layout is same with a following pic.

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

If we enter more than 15 digits of data into _input_, additional values ​​will be stored in _overflowed_.
so It will output `OVERFLOWED!!`.

How to mitigate it ? 
We can think about it.
First, we should check the size of input data. 
Second, We can use the Canary!
Third, Enable ASLR(Address Space Layout Randomization)

And There are more methods to mitigate.
Talk is Cheap, Show Me the Code
Tags: career, programming, beginners, tutorial
Published: 2022-12-04 13:55:35

In today's job market, having the right qualifications can be the difference between landing a job or being overlooked. In the past, the standard way to prove a person's competency was to present a diploma or certification on paper. But what if the paper doesn't truly reflect the person's real skills? 

It's time to move away from the traditional system of relying solely on diplomas and certifications to prove someone's competency and move towards a competency-based approach. In a competency-based system, individuals are assessed on their actual skills, not just the pieces of paper they hold. This approach is becoming increasingly popular as employers look for more tangible evidence of a candidate's capabilities.

One way employers can assess job candidates is through coding tests. Coding tests provide employers with a way to evaluate a person's technical skills without relying on a piece of paper. Candidates can be tested on their coding ability, problem-solving skills, and other technical skills. This allows employers to make an informed decision on who to hire based on demonstrated proficiency.

Another approach employers are using to assess job candidates is online portfolios. Online portfolios are a great way to showcase an individual's talents, achievements, and qualifications in a more visual way. They allow employers to gain a better understanding of a candidate's skills and abilities from the comfort of their own office. Plus, employers can easily share portfolios with other staff members, which makes the hiring process more efficient.

In the past, diplomas and certifications on paper were the only way to prove someone's competency. But in today's job market, employers are looking for more tangible evidence of a candidate's capabilities. By moving away from the traditional approach and towards a competency-based system, employers can get a better picture of a person's real skills and abilities. Coding tests and online portfolios are two great tools employers can use to assess job candidates more accurately.

https://www.linkedin.com/in/trinmar/
STEEM exceeds 70M Blocks!
Tags: steem, blockchain, genesis
Published: 2022-12-04 13:52:29

# [Steem has now more than 70M Blocks!](https://steemyy.com/block.php)

![image.png](https://cdn.steemitimages.com/DQmQt7Ud7fqXxKB3hNFwfBr48YnNa2jfPsytKVKceq4k8Gt/image.png)

It proves it is stable - and the chain is moving forward 1 block every 3 seconds as expected.

The Steem Genesis [block Number 1](https://steemyy.com/block.php?b=1) which occurs at 2016-03-24 16:05:00.

<blockquote>
From and including: Thursday, 24 March 2016
To and including: Sunday, 4 December 2022

Result: 2447 days

It is 2447 days from the start date to the end date, end date included.

Or 6 years, 8 months, 11 days including the end date.

Or 80 months, 11 days including the end date.
</blockquote>

<hr/>

## [Steem](https://steemyy.com) to the Moon!
How to deploy high available Elasticsearch cluster at AWS OpenSearch using terraform
Published: 2022-12-04 13:35:38

Hi, devops fans. Here I am opening the series of articles devoted to the theme of how to deploy high available Elasticsearch cluster using AWS service, which  is called OpenSearch, and terraform. The first article you already may read [here](https://sergiiblog.com/how-to-deploy-a-high-available-cluster-at-aws-opensearch/). New articles would be added gradually, so if you are interested at current topic, please visit my [blog](https://sergiiblog.com/) regularly or [subscribe to my newsletter](https://sergiiblog.com/sergii-blog-subscribe/). But if you are not ready to wait – then I propose you to view all that material at my on-line course at udemy. **[Here is the link to the course](https://www.udemy.com/course/aws-devops-elasticsearch-at-aws-with-terraform-and-ansible/?referralCode=599D54E5628A86CAB801)**.
Avent of Code - Day 04 - Camp Cleanup
Tags: adventofcode, programming, python, coding
Published: 2022-12-04 13:28:36

[Advent of Code](https://adventofcode.com/) occurs at Dec 01 to 25 where each day, you will need to solve a puzzle. It is Festival and the problem statement is mostly related to Christmas.

## Day 4 - Camp Cleanup
https://adventofcode.com/2022/day/4

![97e461c00b601f75129638b2d40debb.jpg](https://cdn.steemitimages.com/DQmXFcqcK4AtUpBrmKuwcgZ4nTUwxC3bsTa4VdotLdiPqP2/97e461c00b601f75129638b2d40debb.jpg)

### Q1
```python
import sys

file1 = open(sys.argv[1], "r")
ans = 0

while True:
        line = file1.readline()
        if not line:
                break
        line = line.strip()
        if not line:
                break
        arr = line.split(',')
        a, b = map(int, arr[0].split('-'))
        c, d = map(int, arr[1].split('-'))
        if (a >= c and b <= d) or (c >= a and d <= b):
                ans += 1

print(ans)
```

### Q2
```python
import sys

file1 = open(sys.argv[1], "r")
ans = 0

while True:
        line = file1.readline()
        if not line:
                break
        line = line.strip()
        if not line:
                break
        arr = line.split(',')
        a, b = map(int, arr[0].split('-'))
        c, d = map(int, arr[1].split('-'))
        if not (b < c or a > d):
                print(a, b, c, d)
                ans += 1

print(ans)
```

Today is about the [interval intersection](https://helloacm.com/interval-intersection-algorithm/)

<hr/>

### [Steem](https://steemyy.com) to the Moon!
Avent of Code - Day 03 - Rucksack Reorganization
Tags: adventofcode, programming, algorithms, coding
Published: 2022-12-04 13:27:57

[Advent of Code](https://adventofcode.com/) occurs at Dec 01 to 25 where each day, you will need to solve a puzzle. It is Festival and the problem statement is mostly related to Christmas.

## Day 3 -Rucksack Reorganization
https://adventofcode.com/2022/day/3

![image.png](https://cdn.steemitimages.com/DQmU3SWiK4pjbXTcqnyjg1su9uJVfR4hk4dZPzKMokc8BPj/image.png)

### Q1
```python
file1 = open("0.txt", "r")
ans = 0

while True:
        line = file1.readline()
        if not line:
                break
        line = line.strip()
        if not line:
                break
        n = len(line)
        a, b = line[:n//2], line[n//2:]
        c = list((set(a) & set(b)))[0]
        if 'a' <= c <= 'z':
                ans += ord(c) - 97 + 1
        else:
                ans += ord(c) - 65 + 27

print(ans)
```
### Q2
```python
file1 = open("0.txt", "r")
ans = 0

groups = []
while True:
        line = file1.readline()
        if not line:
                break
        line = line.strip()
        if not line:
                break
        groups.append(line)
        if len(groups) == 3:
                c = list(set(groups[0]) & set(groups[1]) & set(groups[2]))[0]
                if 'a' <= c <= 'z':
                        ans += ord(c) - 97 + 1
                else:
                        ans += ord(c) - 65 + 27
                groups = []

print(ans)
```

Here is an interesting read: [Check If N and Its Double Exist (Hash Map)](https://helloacm.com/golang-check-if-n-and-its-double-exist-hash-map/)

<hr/>

### [Steem](https://steemyy.com) to the Moon!
5 Free API for your Project
Tags: api, tutorial, programming
Published: 2022-12-04 13:26:16

Hi there, friends! Wondering if you can have free APIs for your project? No worries. I have compiled a short list of free APIs you can use for your next project.

Here is the list:-
1. Fake Store API - https://fakestoreapi.com/
2. Words API - https://www.wordsapi.com/
3. Random User Data - https://randomuser.me/
4. Dummy API - https://dummyapi.io/
5. Sejda - https://www.sejda.com/


##**The list in detail...**


**FAKE STORE API**
If you are creating an e-commerce store then this API
is for you. An e-commerce store is a great project to
have and it just got easier with Fake Store API.
![fake store](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wmti288bgb5ajmpgzcxq.png)



**WORDS API**
Words API is a set of Restful APIs that allow developers to
look up word definitions, contextual details, and other
morphological word-specific information, such as
synonyms, example usage, part of speech, rhymes, region of
use, etc.
![Words](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/683mcn4sqd5a879ooxpn.png)



**RANDOM USER DATA**
Stop wasting time manually creating fake user data. Just
pull through comprehensive random user data from this
API. Very handy API for projects. And it simulates real
practices much more than hardcoding data.
![Random](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/px9ap9ttzf7sgayvctd4.png)



**DUMMY API**
Dummy API has everything you need to make your app
look like it's bustling with real user activity. From fake
users to fake comments and posts. Say goodbye to
hard-coded JSON data.
![dummy](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ljehgdbywvat5xuc6f0.png)



**SEJDA**
Ever had to download a PDF just to read or edit it? Only
to upload the changes again. Don't let your users endure
this poor UX. With Sejda's API, you can read and edit
PDFs straight from your web app.
![sejda](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d5c5yrlfwnkc8f4o3llh.png)


You are welcome to add any free APIs in the comments section. Checkout one my articles on APIs here: https://dev.to/mitchiemt11/what-is-an-api-3ij3.

_Don't forget to subscribe for more content...._

![cheers](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/024t9l1fyz44mv34ysya.png)
Entry-3: Display Image with Intent (React-native)
Tags: reactnative, snippets, java, beginners
Published: 2022-12-04 13:24:27

A simple way I came up with to open an image, given a file path linked to the internal storage on mobile (Android)

```java
public void openFileWithIntent(String completeFilePath, String directory) {

				//convert file path to File
        File newFile = new File(String.valueOf(Uri.parse(fileName)));
				// convert create content Uri for sharing with other apps
        Uri contentUri = getUriForFile(reactContext, reactContext.getApplication Context().getPackageName() + ".fileprovider", newFile);

				//create an intent
        Intent intent = new Intent();
				// set the action type 
        intent.setAction(Intent.ACTION_VIEW);
				// set the data and mime type
				String mimeType = ...
        intent.setDataAndType(contentUri, mimeType);
				// Grant temporary access to application opening the file
        intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
				// Due to context being outside an activity, we add the flag.
        intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
				// Launch file chooser
        reactContext.startActivity(intent);
 }
```

Add to your android manifest

```xml

<provider
android:name="androidx.core.content.FileProvider"
android:authorities="${applicationId}.fileprovider"
android:exported="false"
android:grantUriPermissions="true">
    <meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/file_paths" />
</provider>
```

We create a file path.xml for above “*********android:resource….”********* 

```xml
<?xml version="1.0"encoding="utf-8"?>
<pathsxmlns:android="http://schemas.android.com/apk/res/android">
    <external-files-pathname="photos"path="photos/"  />
</paths>

```

And that’s it.

**Deep dive.**

- [FileProvider | Android developers](https://developer.android.com/reference/androidx/core/content/FileProvider)
- [Data and file storage overview](https://developer.android.com/training/data-storage)
- [Intent | Android developer](https://developer.android.com/reference/android/content/Intent?hl=en)

**External Links**

- **Twitter**: [@benny_wayn](https://twitter.com/etieno_u)
- **LinkedIn**: [Ibenge-uforo](https://www.linkedin.com/in/ibenge-uforo/)
- **Ongoing** **Research[5 min]**: [Social Survey](https://docs.google.com/forms/d/e/1FAIpQLScKBo1VQvEVpvxKbOamhWq02uQU8HlgUPq576F-LD3yTljkwg/viewform)
Javascript cheatsheet part-1
Published: 2022-12-04 13:18:37

These are very important to remember and will help you become a better developer.
Start learning with following concepts.
## Array Methods
By https://developer.mozilla.org/en-US/docs/Web/JavaScript/

The Array object, as with arrays in other programming languages, enables storing a collection of multiple items under a single variable name, and has members for performing common array operations.
>>> These are most important array operation used during working.

### Map
Map allows you to take an array and create a function to change each individual object in a certain array.

Example
```
let arrayExample = [1,2,3,4];
const newArray = arrayExample.map(x=>x*2);
console.log(newArray);
```
### Filter
Filter allows you to sort through the array and return all objects which follow the set of rules stated into a new array.

Example
```
let arrayExample = [14,25,33,48];
const newArray = arrayExample.filter(x=>x > 20);
console.log(newArray);

// exapected output: Array [25, 33, 48]
```
```
const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);
console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
```
### Reverse
Reverse allows you to rearrange the array from the back to the front.

Example
```
let arrayExample = [14,25,33,48];
console.log(arrayExample.reverse());

// expected output: Array [48, 33, 25, 14]
```

## Ternary Operator

The ternary operator is sort of like an if statement, however the syntax is different. The ternary operator will check if a statement is true, and if so it will render the first statement. Else it will render the next statement.

Syntax 
```
statement === true ? render this : else render this
```
Example
```
const user = false;
user === true ? <h1>Your are welcome </h1> : <h2>Please log in here </h2>

// expected output: Please log in here.
```


> Think of the “?” as an if. If user is true , then render an h1. Else ( think of the “:” as else) render the h2.


## Arrow Functions

Arrow functions allow you to remove many elements from the traditional function syntax and really clean up your code to make it less cluttered.

Traditional function
syntax
```
function function_name(args){
    //code
}
```
```
function multiplyItems(x){
    let resutl = x*2;
    return result;
}
```

Arrow functions allow you to remove the word “function” and the function name. You can also remove the parentheses from the input, however sometimes it is helpful to keep it as it makes reading the code 
easier.
syntax
```
const var = (args) => {
    //code
}
```

```
const res = (x) => x*2;
```
Your comments will appreciates.
For more programming and JavaScript tips be sure to follow. Thank you for reading!
Stay tuned..
Login Page Design | HTML & CSS tutorial
Tags: tutorial, html, css, design
Published: 2022-12-04 13:13:03

## In this video, I am gonna show you how to make a responsive login form design with HTML and CSS.

{% embed https://www.youtube.com/embed/P_BzC0veeiM %}

PLEASE SUBSCRIBE!
 💝 [@codeopacity](https://www.youtube.com/c/codeopacity)
New Videos Every Week!

The source files will be uploaded on my blog as always. 

https://opacitycode.blogspot.com/

-----                                          -----
Recommended Videos:

Expanding Cards Tutorials
► https://youtu.be/ZqJAja5ZFsY

Masonry Grid Portfolio
► https://youtu.be/VSPGZrmZDa0

Typing Animation Typed.js Tutorial
► https://youtu.be/dryBUF5F5e0

Bootstrap Navbar Tutorial
► https://youtu.be/mJW822p8iGs

-----                                          -----

If you'd like a behind-the-scenes and previews of what's coming up on my YouTube channel, make sure to follow me on Instagram and Twitter.

🔗Follow me on: 
fb: [facebook](https://www.facebook.com/opacitycode )
ig: [instagram](https://www.instagram.com/code_opacity)
tw: [twitter](https://twitter.com/code_opacity )
bg: [blogger](https://opacitycode.blogspot.com/)

Thanks for your support! 😋

🖇Tags:
Signup form, registration form in html and css,  responsive login form html css,  html, portfolio website, responsive login form html css,  html tutorial for beginners,  responsive website using html and css, login page html css,  js tutorial,  HTML,  beginner project,  code opacity,  opacity code