teleren/devto huggingface dataset:
Why you should ask for code reviews early on and review others code!
Published: 2023-04-20 20:57:29

Hey there, software developers!

Looking to improve your coding skills, learn from others, and avoid wasting hours or days on what ends up being a simple fix?

There's one tactic that you absolutely shouldn't overlook.

**CODE REVIEW.**

Code review is the practice of sharing your code with others and reviewing the code of others. It may seem a little scary at first! Trust me, it's worth it. 

Here are a few reasons why:

**1. Two heads are better than one:**

Sometimes, all it takes is a fresh pair of eyes to spot those pesky errors that you've been staring at for hours. 

I know! I spent 2 whole workdays at my first job wondering why my code wasn't working. I was missing an equal sign `=` to reassign a variable value. 🤬

When you share your code with others, they can help you catch mistakes you may have missed on your own.

**2. Learn something new:**

Collaborating with other developers can help you pick up new skills and techniques.

By reviewing someone else's code, you might discover a more efficient way of doing things or a tool you didn't even know existed.

Code review is a great place to ask questions and share your knowledge. Be curious and open to learning new things!

**3. Don't make the same mistake twice:**

By reviewing others' code, you can learn from their mistakes and avoid making the same errors yourself. This can save you a lot of time and frustration in the long run.

One of the best ways to share and review your code is through GitHub. GitHub is a platform that allows you to host your code and collaborate with other developers. By posting your code on GitHub, you can invite others to review your code and provide feedback. You can also review the code of others and learn from their techniques and approaches.

To sum it up, sharing and reviewing your code with other developers is a must if you want to become a better software developer. By being open to feedback and collaborating with others, you can catch errors, learn new techniques, and become a better coder.

So why not give it a shot? Share your code today and start collaborating with other developers. Who knows what you might learn or what problems you might solve together?

And speaking of collaboration, what are some other ways you like to work with other developers? Let us know in the comments below!

Here are some resources to get you started:

[Awesome Code Review](https://github.com/joho/awesome-code-review#readme)

[Why Code Reviews Matter - Atlassian](https://www.atlassian.com/agile/software-development/code-reviews)

cover image credit: Photo by <a href="https://unsplash.com/@disruptxn?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Desola Lanre-Ologun</a> on <a href="https://unsplash.com/photos/IgUR1iX0mqM?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
'useEffect' in depth
Tags: react, webdev, beginners, javascript
Published: 2023-04-20 09:51:44

## What is useEffect for?
useEffect was introduced in react 16.8, before this was released react developers would use componentDidMount and componentWillUnmount.
The useEffect hook is a built-in React hook that allows you to run side effects in functional components. This side effects are actions that do not directly affect the UI but it can include things like fetching data, adding event listeners, etc.

## Why useEffect accept two arguments?
It takes two arguments, the first argument being a function that contains the code for the side effect you want to perform and the second argument which is optional being how many times we want it to be perform.

## First Example

```js
import React, { useState, useEffect } from 'react';

function Timer() {
  const [time, setTime] = useState(0);

  useEffect(() => {
    const intervalId = setInterval(() => {
      setTime(prevTime => prevTime + 1);
    }, 1000);
  }, []);

  return <div>{time} seconds have passed.</div>;
}
```

In the example above it will run just once after the component in mounted.

## Second Example

```js
import React, { useState, useEffect } from 'react';

function Timer() {
  const [time, setTime] = useState(0);

  useEffect(() => {
    const intervalId = setInterval(() => {
      setTime(prevTime => prevTime + 1);
    }, 1000);
  }, [time]); 

  return <div>{time} seconds have passed.</div>;
}
```

In the example above we can see how i passed the second argument so it just renders every time 'time' changes.

## Cleanup in useEffect?
This is something not always is being used or even taught, but is indeed really important for time efficient and memory leaks.
We should run cleanup in useEffect to we avoid having memory leaks in our application which can cause our app to be slower.

## Example with cleanup

```js
import React, { useState, useEffect } from 'react';

function Timer() {
  const [time, setTime] = useState(0);

  useEffect(() => {
    const intervalId = setInterval(() => {
      setTime(prevTime => prevTime + 1);
    }, 1000);

    return () => {
      clearInterval(intervalId);
    };
  }, [time]);

  return <div>{time} seconds have passed.</div>;
}
```

In the example above we can see that i added a return which will return a clearInterval that will do a cleanup with the intervalId and we will avoid memory leaks in our application.

Hope someone found this useFul and if you have any questions and would be happy to answer them.

Lautaro.
`zod` Function Definitions in JavaScript Classes
Tags: javascript, typescript, webdev
Published: 2023-04-20 20:25:47

### Overview

Wasn't able to find this clearly stated on the internet. Here's how you use the zod.function() system in a JavaScript class.

*I work for [Akkio](https://akkio.com), where I'm building out a no-code predictive AI platform. If you're looking to harness the power of AI without needing a data scientist, give us a try!*

### The Working Solution

```typescript
class ClassName {
  request = z
    .function()
    .args(
      z.string(),
      z.object({
        temperature: z.number().default(0),
        model: z.nativeEnum(MODELS).default(MODELS.STANDARD),
        schema: z.instanceof(ZodSchema),
      })
    )
    .returns(z.promise(z.string()))
    .implement(async (prompt, options) => {
      // ...
    })
```

Enjoy!
3 Easy Commands to Install Postman in Kali Linux
Tags: kali, debian, postman, software
Published: 2023-04-20 19:50:56

##Introduction 
For an effective development environment especially back-end, you will require postman to test your endpoints. It has been constantly said that Debian environments are ideal for Software development/engineering processes. Having said this, I will take 3 simple steps to install Postman in Kali Linux.
##Requirements
- Internet
- Proficiency with Command utility
- x64 Linux architecture 

![Download Postman](https://dl.pstmn.io/download/latest/linux_64) 

1.Extract the folder using the following command and a Postman folder will be created:
```cmd
sudo tar -xvz -f postman-linux-x64.tar.gz
``` 
2.Move the folder to the root opt  folder
```cmd
sudo mv Postman /opt/
```
3.Navigate to this folder /usr/share/applications/ and create a file Postman.desktop and open the nano editor
```cmd
touch Postman.desktop && nano Postman.desktop
```
write the following content
```
[Desktop Entry]
Encoding=UTF-8
Name=Postman
Exec=/opt/Postman/app/Postman %U
Icon=/opt/Postman/app/resources/app/assets/icon.png
Terminal=false
Type=Application
Categories=Development;
```
##You have successfully installed Postman!
I created a website for my school
Published: 2023-04-20 20:11:07

I noticed my school website to be outdated and not responsible with mobile devices. I made a website for my school and i showed it to school principal. He Send it to IHRD Head office and I received a call from their, that they will host the website that I made in the official domain. You can visit my website here at http://thssputhuppally.ihrd.ac.in
 Here is my portfolio link : https://godlykmathews.github.io
oh my zsh
Published: 2023-04-20 19:32:46

Oh My Zsh is a popular zsh configuration manager, offering tons of themes, functions, helpers, plugins, and other handy features for command line users. 

It’s used heavily by many who spend a lot of time in the command line, whether for development, administration, or just geeking around, so if you’re in those categories you may find it worth checking out.

While zsh is now the default shell in Terminal app for modern macOS releases, Oh My Zsh is separate, and therefore must be installed and configured separately.

**Install oh-my-zsh now**

Oh My Zsh is installed by running one of the following commands in your terminal. You can install this via the command-line with either curl or wget.

- Wget

```
sh -c "$(wget https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
```
- Curl

```
sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
```

[Plugins To Install with oh my zsh](https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins)

**How to install plugins**

Go to terminal and type 

```
vi ~/.zshrc
```
Now you can write the plugin names needed like zsh auto-suggestions so on


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


Restart your terminal and there you go, hope this helps!
Understanding highWaterMark in Node.js Streams
Tags: webdev, javascript, node, learning
Published: 2023-04-20 19:27:47

If you're working with Node.js streams, you've probably come across the `highWaterMark` parameter. But what is it, and why is it important? In this post, we'll explore the basics of `highWaterMark` and how it affects your stream pipelines.

---

## What is `highWaterMark`?

Simply put, `highWaterMark` is a parameter that sets a limit on the amount of data that can be stored in the internal stream buffer. When the buffer reaches this limit, Node.js stops asking for more data until the buffer is emptied. This helps prevent your program from consuming too much memory and crashing.

However, it's important to remember that `highWaterMark` is a threshold, **not a strict limit**. You can keep manipulating data even when the buffer size exceeds `highWaterMark`. But be aware that the data will still be buffered in memory, which could cause your memory to fill up and you to lose all the benefits of Node.js streams.


![graphical description of highWaterMarkParameter](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/f7sfzebm9xkvabsuaoxz.png)

If you're using the `writable.write()` method, it returns a `boolean` value that indicates whether it's safe to continue writing data to the stream. Specifically, if the internal stream buffer size is bigger than `highWaterMark`, it'll return `false`. In this case, you need to wait for the `'drain'` event to be emitted before you can resume writing data to the stream. If the buffer size is smaller than `highWaterMark`, then it'll return `true`, and you can continue writing data without waiting.

---

## Important things to keep in mind:

- `highWaterMark` is a parameter that sets a limit on the amount of data that can be stored in the internal stream buffer.

- This limit is a threshold, not a strict limit, so you can keep manipulating data beyond it if you need to.

- However, exceeding the threshold could cause your memory to fill up, so it's important to be mindful of your memory usage.

- If you're using the `writable.write()` method, check the boolean value it returns before keep writing data to the stream.

By understanding `highWaterMark` and how it works, you can write more efficient and robust code that takes advantage of Node.js streams. Happy streaming! 🌊

---

If you want to stay up to date with more Node.js tips and tricks, follow me on [Twitter](https://twitter.com/hateablestream), And don't forget to check out the [Twitter thread version](https://twitter.com/hateablestream/status/1649128483140825094) of this post for a quick summary.
How to Set Up SSH Keys for GitHub on Ubuntu EC2 Instance
Published: 2023-04-20 18:57:03

**In this tutorial, you learn how to generate SSH key for GitHub and clone your GitHub repository in AWS ubuntu server with SSH command.**

* Generate SSH key and add the SSH key

```
~ ssh-keygen -t ed25519 -C "your_email@example.com"

~ eval "$(ssh-agent -s)"

~ ssh-add ~/.ssh/id_ed25519

```

* Copy the newly generated SSH Key and add the SSH key to your GitHub account.

```
~ cat ~/.ssh/id_ed25519.pub

```

---

_Now you can initialize git in your project directory and add GitHub repository with SSH command. And you can manage the code with git command._
Self-Taught College Dropout Makes a Personal Portfolio
Tags: webdev, beginners, portfolio, review
Published: 2023-04-20 18:42:09

Hey there everybody, I've been working on this website on and off for quite some time now, I think 3 months to be exact. 

I made it using HTML, CSS, Javascript, and Vite. No frameworks and I self hosted all of this. 

This will not be my main portfolio website, but rather a cool little project I can showcase to potential clients. 

Every single image asset you see has been designed in Penpot and Inkscape. UX/UI part of the website is also mine, didn't copy anything.

If you could take a look at it, provide some feedback about your experience, I would be very grateful! 

https://www.leotg.com/

This project was a huge step outside of my comfort zone, and I am really happy I can share it with everyone after a long time.
Installing MongoDB in WSL2 with Ubuntu-22.04
Tags: webdev, wsl, mongodb, ubuntu
Published: 2023-04-20 18:40:18

These last days I've been with no time to practice coding, and one thing stopping me was that I didn't have my dev environment as I would like to.
So this week I decided to write this article on how I did to install MongoDB (latest) on my WSL setup.

Head to root folder 
```
cd /
```
Install GNUPG
```
sudo apt-get install gnupg
```

Issue following command to import GPG keys
```
curl -fsSL https://pgp.mongodb.com/server-6.0.asc | \
   sudo gpg -o /usr/share/keyrings/mongodb-server-6.0.gpg \
   --dearmor
```
Create List file

```
echo "deb [ arch=amd64,arm64 signed-by=/usr/share/keyrings/mongodb-server-6.0.gpg ] https://repo.mongodb.org/apt/ubuntu jammy/mongodb-org/6.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-6.0.list
```
Reload Packages

```
sudo apt-get update
```
Install Mongo db Packages

```
sudo apt-get install -y mongodb-org
```
Create DB Folder

```
mkdir -p data/db
```
Apply permissions

```
sudo chown -R `id -un` data/db
```
Run MongoD

```
mongod
```
Verify

You should be able to see something like ` Waiting for connections","attr":{"port":27017,"ssl":"off" ` on the terminal.


Hope it helps"
Fix : TokenService Error: ChainId 0x539 is not supported :(
Tags: hardhat, metamask, blockchain, web3
Published: 2023-04-20 18:33:00

I wrote a smart contract to mint some custom tokens using Solidity over **Hardhat (Localhost)** development environment. The contract compiled successfully but while importing the new minted tokens in my Metamask wallet I got this error message.

![Metamask error image !](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s411j1rmcpjk0jozt68a.JPG)

I figured out the problem, which was causing the error. The new update for Metamask was not accepting the old RPC for Hardhat(Localhost) = [ **http://localhost:8545/** ] and Chain ID = **1337** as shown below > 

![Metamask error image !](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3g4jm0dbtt2odi5apca.JPG)

**Error fix :**

Go to Metamask > Settings > Networks > Press "**Add a network**" button > Add these details as shown below > 

Network name > **Hardhat**
New RPC URL > **http://127.0.0.1:8545/**
Chain ID > **31337** [[ Reference Document ](https://hardhat.org/hardhat-network/docs/reference)]
Currency symbol > **HHETH** [ Give any symbol you want ! ]
Block explorer URL > [ Optional, so I skipped ! ] 

![New network setup !](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8fewumxjjwxjpaaaoigo.png)

Click on save. 

Now open your "**hardhat.config.js**" in your code editor and update the **chainID** and **network-name** according to this snapshot shown below >  

![hardhat.config.js](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/od7hle4dmvm8i5axl313.png)

Save the "**hardhat.config.js**" file. 

Re-run **npx hardhat node** in a separate terminal and then run **npx hardhat run scripts/deploy.js --network hardhat** > shift your Metamask network to the newly created network : **Hardhat** as shown below >

![Network change !](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/29x2c2w3oj3dmpb547ed.png)

Now **Import Tokens** again and you'll see the tokens minted on your wallet. 

**Happy building :)**
Learnings from Google UX Professional Design Certificate: Part 1
Tags: uiux, design, webdev, mobile
Published: 2023-04-20 18:29:18

Interested to know about the Google UX Design Certificate from Coursera? Check out my article on Hashnode! I wrote about how things work while working on UIUX of a product.

Also this is my first post on Dev community. Like and comment if you find it useful.

[Link to article](https://belohith.hashnode.dev/learnings-from-the-google-ux-design-professional-certificate-part-1)

PS: I'm looking for jobs related to Computer Science anywhere in the US. Hiring? Hit me up!
Building a CLI Weather Checker App with Python and OpenWeatherMap API
Tags: python, beginners, programming, tutorial
Published: 2023-04-20 18:18:26

Hey what's going on friends, my name is Amir from Bek Brace channel, and in this tutorial I am going to show you how to build a Weather checker CLI application using only Python language and openWeatherMap API.

Now, I know what you're thinking. "But isn't Python just for data analysis and machine learning?" Sure, those are some of its main use cases, but Python is also incredibly versatile and can be used for a wide range of applications, including building a weather checker CLI app [ I'm a Ms-Dos generation - 40 Y.O. - so CLI apps warm my heart :D ].

{%youtube Vja6RmlOrfc%}

Ok. Let's dive into the code. 

We start by importing the necessary libraries - requests, argparse, chalk, and pyfiglet. Don't worry if you're not familiar with these libraries, we'll explain them as we go along. We also define our API key and base URL for the OpenWeatherMap API, which we'll be using to get the weather information.

Next, we use the argparse library to parse the command-line arguments. This allows the user to specify the country or city they want to check the weather for. We construct the API URL with the query parameters, using the country argument provided by the user.

We then make the API request using the requests library and check the response status code. If the status code is not 200, we print an error message and exit the program. Assuming we get a successful response, we parse the JSON data and extract the weather information we're interested in, including the temperature, feels like temperature, description, icon, city, and country.

Finally, we construct the output string with the weather icon and print it to the console using the chalk library for some added color.

Overall, building a weather checker CLI app with Python is a fun and practical way to explore the language and as I always say in my videos and write in my blogs: Invest more time and effort in learning the core concepts of the language itself, do not jump too soon to Django, Express or Next.js.

Keep learning, keep coding and I will see you in the next post.
GitLab Runners
Published: 2023-04-20 18:16:19

GitLab runners are the components of the GitLab CI/CD pipeline that are responsible for running jobs and executing the tasks defined in the pipeline configuration. They are typically used to build, test, and deploy code changes.

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


**Terminology**

- GitLab Job
The tasks in the CI/CD pipeline such as running tests, building an image, deploying to a server etc. are configured as what’s called jobs.

- GitLab Instance
Gitlab instance or also called Gitlab server that hosts your application code and your pipelines and basically the whole configuration. So it knows what needs to be done.

- GitLab Runners
This is an agent installed on a different server from the GitLab server. The GitLab Runner receives instructions from the GitLab server in regards to which jobs to run. Each runner must be registered with the GitLab server.

- Runner Executor
Each Runner will define at least one executor. An executor is essentially the environment where the job will be executed.

**Types Of Executors**

1. Shell executor
2. Virtual Machine executor (VirtualBox / Parallels)
3. Docker executor
4. Docker Machine executor
5. Kubernetes executor
6. SSH executor
7. Custom executor
AI and the Future of Work: Why Machines Will Not Replace Human Employees Completely
Tags: ai, programming, chatgpt
Published: 2023-04-20 17:57:36

Artificial intelligence (AI) and machine learning are revolutionizing the way we work, and there is much speculation about what this means for human work. Although AI is expected to affect several industries, there is evidence that machines will not completely take over the jobs currently performed by humans.

AI's greatest impact is seen in repetitive and data-intensive tasks such as data entry, data analysis, and customer service. Automating such tasks can improve accuracy and consistency, allow businesses to save time, reduce costs, and allow employees to focus on more difficult tasks.

For example, Deloitte financial services research shows that AI can increase productivity by 22% and reduce costs by 14%. Similarly, the McKinsey Global Institute found that AI can reduce costs by 20-50% in supply chain management.

However, machines are not capable of creativity, sensitivity, and emotional intelligence that humans have. Some tasks, such as creating campaigns, providing emotional support and developing relationships with customers, are beyond the capabilities of machines.

Research supports this argument. For example, MIT Sloan's Management Review found that businesses that rely heavily on AI for customer service experience lower customer satisfaction. This means that machines can handle some aspects of customer service, but cannot replace human interaction.

According to a recent report by the McKinsey Global Institute, less than 5% of jobs can be automated using existing technology. However, up to 30% of jobs in all industries can be automated, which means some jobs could change significantly as automation increases.

While some jobs may be at risk of automation, new jobs will emerge in areas such as AI development, data analytics and cyber security. Therefore, employees must continue to improve their skills and be aware of the latest technological developments in their field.

Research supports this idea. The World Economic Forum found that the most in-demand skills in 2020 are complex problem solving, critical thinking and creativity, all of which are difficult for machines to improve.

Ultimately, research shows that while AI and machine learning will continue to influence the future of work, machines will never completely replace human employees. The future of work will involve collaboration between humans and machines, each contributing their strengths. This collaboration will increase efficiency, productivity and innovation, which will benefit businesses and individuals.

By keeping up with the latest trends and developments in AI, workers can be prepared for future changes and thrive in the new economy.