teleren/devto huggingface dataset:
Integration of ESlint, Prettier and Husky
Tags: eslint, prettie, husky
Published: 2022-12-31 10:51:38



**To integrate ESlint, Prettier, and husky into your project, you will need to follow these steps:**

Install the necessary dependencies:

**npm install --save-dev eslint prettier husky**

Set up ESlint by creating an .eslintrc configuration file. You can do this either manually or by using the eslint --init command, which will guide you through the process of creating the configuration file.

Set up Prettier by creating a .prettierrc configuration file. This file should contain the Prettier configuration options that you want to use.

Add the following script to your package.json file:

**"scripts": {
  "precommit": "eslint --fix && prettier --write"
}**

This script will run ESlint and Prettier on your code whenever you try to commit changes using git commit.

Configure husky to run the precommit script by adding the following block to your package.json file:

**"husky": {
  "hooks": {
    "pre-commit": "npm run precommit"
  }
}**

You can now run git commit as usual and ESlint and Prettier will automatically run and fix any issues before the commit is finalized.

**Note:** If you want to run ESlint and Prettier on all files in your project, you can use the --find-related-files flag, like this:

**"scripts": {
  "precommit": "eslint --fix --find-related-files && prettier --write --find-related-files"
}**

This will scan your project for all files that match the patterns specified in your ESlint and Prettier configuration files and lint and format them.
Pros and Cons of Code Factoring
Tags: codefactoring
Published: 2022-12-31 10:45:26

Code factoring is an important part of the coding process, but it isn’t without its drawbacks. Code factoring is the process of refactoring existing code to improve its structure and organization, making it more efficient and easier to read and debug. While this can help to improve the quality of a codebase, it also can be time consuming. Here are some of the pros and cons of code factoring:
Pros:
• It can improve the readability and maintainability of the codebase, making it easier for the development team to debug and add new features.
• It can improve the performance of the codebase by making it more efficient.
• Code factoring can help to reduce the amount of duplicate code and improve the overall design of the codebase.
Cons:
• It can be time consuming, requiring developers to spend substantial time refactoring existing code.
• It requires a thorough understanding of the codebase and how it works, so it may be best left to more experienced developers.
• It can be difficult to determine the best way to refactor existing code, so there may be some trial and error involved.
Overall, code factoring can be a useful tool for improving the quality and maintainability of a codebase. However, it should be approached carefully and with a thorough understanding of the codebase and its capabilities.
Troubleshooting Code Factoring Issues
Tags: code, codefactoring, issues
Published: 2022-12-31 10:43:24

If you're having trouble factoring code, there are a few steps you can take to troubleshoot the issue. First, double-check to make sure your code is properly written and free of any typos or grammatical errors. Next, look for any syntax errors that may be causing the issue. If you can't find anything wrong with your code, you may want to look up some tutorials and examples online to help you identify where the issue may be. Additionally, make sure that the code you're using is compatible with the language you're working in. Finally, don't be afraid to reach out for help if you're stuck - there are plenty of online resources to help you get unstuck. With a little bit of detective work and perseverance, you can troubleshoot code factoring issues in no time.
How to Approach Code Factoring?
Tags: coding, coderefactoring, programming, career
Published: 2022-12-31 10:40:25


When it comes to coding, it can be daunting to think about the process of factoring. It can be a time-consuming process and can leave you feeling overwhelmed. However, it doesn't have to be that way. With the right approach, factoring your code can be a painless and even enjoyable experience.
The first step to approaching code factoring is to identify the common patterns in your code. This can help you identify areas that can be refactored and make it easier to determine what code should be extracted to a separate function. Once you have identified the patterns, break down the code into smaller, more manageable sections. This will make it easier to read and debug.
Next, you'll need to create functions to replace the code you've identified. Make sure to name the functions clearly and accurately to make your code easier to read and use. Finally, make sure to thoroughly test your code before you release it. This will help ensure that your code works as expected and that any changes you've made won't break existing code.
By following these steps, you can make code factoring an easier process. With a bit of practice, you will be able to approach code factoring with confidence and create clean and efficient code.
Know About HTTP Response Status Codes
Tags: http, beginners, webdev, requestcode
Published: 2022-12-31 10:31:45

HTTP response status codes are 3-digit numbers that are used to indicate the status of a request made to a web server. They are returned by the server in response to an HTTP request and provide information about the result of the request.

Here are some common HTTP response status codes and their meanings:

**200 OK:** This status code indicates that the request was successful and the requested resource was returned.

**301 Moved Permanently:** This status code indicates that the requested resource has been permanently moved to a new URL. The server returns this code along with the new URL in the response header.

**302 Found:** This status code indicates that the requested resource has been temporarily moved to a new URL. The server returns this code along with the new URL in the response header.

**404 Not Found:** This status code indicates that the server could not find the requested resource.

**500 Internal Server Error:** This status code indicates that there was an error on the server while processing the request.

There are many other HTTP response status codes, each with its own specific meaning. Some of these codes are used more commonly than others, but it's important to be aware of all of them to understand the full range of responses that a server can send.

In addition to the standard HTTP response status codes, some servers may also return custom status codes to provide more information about the result of a request. These custom codes should be used in conjunction with the standard status codes to provide a complete picture of the request's outcome.
Make (.bat) files always open with Administrator permissions
Tags: bat, batch, windows, commandprompt
Published: 2022-12-31 10:30:00

> Many of you use, or have used _(.bat) Batch_ files, right? Well, if so, you might know that when you open a _(.bat)_ file it opens without administrator permissions. (unless you run it as administrator)
> So, I've made this script that will make all you batch files always runas administrator!



## How to run the script?

Well, easy! the script is in [this GitHub page](https://github.com/TabbySL/Make-all-.bat-files-start-in-Elevated-mode) and all you have to do is download the script. After downloading, the file could be blocked by  your antivirus, because the file contains code that involves editing registry values. if a screen called 'Windows Smartscreen protected your PC', click more info and then click run anyway. Make sure to open the file _as administrator_ that says **Make batch files run with elevated permissions**. Now, when you click that it should give 2 options on the screen; 

![Selecting the fist option after running the script](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4wczi0im73n8ag6bq73w.png)
1. Add 
2. Remove 

As by now, you might have guessed already, you have to select the 'Add' option, and click 'YES' on the MSGBOX.

That's it! Now you have added the script to your computer! try opening a (.bat) file and it will start in Administrator mode automatically! 

## Note!

When You run this script, this makes all batch files to be run in administrator mode, instead of normal mode. This could mean that, even a batch script containing malicious code could easily get unwanted permission and probably will wreck your PC. **So make sure to Remove the script when you don't use it anymore!**

Thanks for Reading ~!
Numpy Indexing and Selection
Tags: python, ds, beginners, programming
Published: 2022-12-31 10:29:04

# NumPy Indexing and Selection

In this lecture we will discuss how to select elements or groups of elements from an array.

```
import numpy as np

```

```
#Creating sample array
arr = np.arange(0,11)

#Show
arr

```

## Bracket Indexing and Selection
The simplest way to pick one or some elements of an array looks very similar to python lists:

```
#Get values in a range
arr[1:5]

#Get values in a range
arr[0:5]
```

## Broadcasting

Numpy arrays differ from a normal Python list because of their ability to broadcast:

```
#Setting a value with index range (Broadcasting)
arr[0:5]=100

#Show
arr

```

```
# Reset array, we'll see why I had to reset in  a moment
arr = np.arange(0,11)

#Show
arr
```

```
#Important notes on Slices
slice_of_arr = arr[0:6]

#Show slice
slice_of_arr


```

```
#Change Slice
slice_of_arr[:]=99

#Show Slice again
slice_of_arr
```

Now notice that the changes also occur in our original array!

```
arr
```

The Data is not copied, it's a view of the original array! This avoids memory problems!

```
#To get a copy, need to be explicit
arr_copy = arr.copy()

arr_copy
```

## Indexing a 2D array (matrices)

The general format is **arr_2d[row][col]** or **arr_2d[row,col]**. I recommend usually using the comma notation for clarity.

```
arr_2d = np.array(([5,10,15],[20,25,30],[35,40,45]))

#Show
arr_2d
```

```
#Indexing row
arr_2d[1]

```

```
# Format is arr_2d[row][col] or arr_2d[row,col]

# Getting individual element value
arr_2d[1][0]
```

```
# Getting individual element value
arr_2d[1,0]
```

```
# 2D array slicing

#Shape (2,2) from top right corner
arr_2d[:2,1:]
```

```
#Shape bottom row
arr_2d[2]
```

```
#Shape bottom row
arr_2d[2,:]
```
### Fancy Indexing

Fancy indexing allows one to select entire rows or columns out of order. To show this, let's quickly build out a NumPy Array:

```
#Set up matrix
arr2d = np.zeros((10,10))
```

```
#Length of array
arr_length = arr2d.shape[1]
```

```
#Set up array

for i in range(arr_length):
    arr2d[i] = i
    
arr2d
```

Fancy indexing allows the following

```
arr2d[[2,4,6,8]]
```

```
#Allows in any order
arr2d[[6,4,2,7]]
```
## More Indexing

Indexing a 2D Matrix can be a bit confusing at first, especially when you start to add in step size.

## Selection

Let's briefly go over how to use brackets for selection based off of comparison operators.

```
arr = np.arange(1,11)
arr
```

```
arr > 4
```

```
bool_arr = arr>4
```

```
bool_arr
```

```
arr[bool_arr]
```

```
arr[arr>2]
```

```
x = 2
arr[arr>x]
```

```

```
The Best SvelteKit 1.0 YouTube Tutorials – January 2023 🤓 🎓
Tags: sveltekit, svelte, tutorial
Published: 2022-12-31 10:28:21

SvelteKit 1.0 has been [released](https://svelte.dev/blog/announcing-sveltekit-1.0).

So besides older tutorials as listed in my previous post ([The Best SvelteKit YouTube Tutorials – UPDATED on October 2022](https://dev.to/kvetoslavnovak/the-best-sveltekit-youtube-tutorials-updated-on-september-2022-542)) here goes the list of brand new ones. 

Some of the tutorials are work in progress with new episodes being released still. 

&nbsp;

## [Joy of Code](https://www.youtube.com/watch?v=obmiLi3bhkQ&list=PLA9WiRZ-IS_zfHpxmztJQLeBISsQkh9-M&ab_channel=JoyofCode)

{% youtube obmiLi3bhkQ %}
[Full Playlist](https://www.youtube.com/playlist?list=PLA9WiRZ-IS_zfHpxmztJQLeBISsQkh9-M)

&nbsp;

## [Huntabyte](https://www.youtube.com/watch?v=EQy-AYhZIlE&list=PLq30BP0TIcqXP149TyFMfRhnMT6T5--e5&index=2&ab_channel=Huntabyte)

{% youtube EQy-AYhZIlE %}
[Full Playlist](https://www.youtube.com/playlist?list=PLq30BP0TIcqXP149TyFMfRhnMT6T5--e5)

&nbsp;

## [WebJeda](https://www.youtube.com/watch?v=ygtbuexDHxE&list=PLm_Qt4aKpfKjf77S8UD79Ockhwp_699Ms&ab_channel=WebJeda)

{% youtube ygtbuexDHxE %}
[Full Playlist](https://www.youtube.com/playlist?list=PLm_Qt4aKpfKjf77S8UD79Ockhwp_699Ms)

&nbsp;

## [LevelUpTuts](https://levelup.video/tutorials/sveltekit)

{% youtube ew8a1W-o6dk %}

&nbsp;

## [Fireship](https://www.youtube.com/watch?v=uEJ-Rnm2yOE&ab_channel=Fireship)

{% youtube uEJ-Rnm2yOE %}
Laravel package api-response
Published: 2022-12-31 10:13:29

I mentioned a method [before](https://dev.to/mesak/laravel-controller-use-callaction-to-meke-apicontroller-122l), which is to use the unified processing of the controller return value to output the API response. For this reason, I wrote my method into a package to make it more convenient to use.

package in :
[https://github.com/mesak/laravel-api-response](https://github.com/mesak/laravel-api-response)

in Laravel 8 or 9

use command : 
```
composer require mesak/laravel-api-response
```
your can install this package 

then use two step 

change Controller and change Exception\Handler

## Exception\Handler

change your `app/Exceptions/Handler.php` file to extend `Mesak\LaravelApiResponse\Exceptions\Handler`

```php
namespace App\Exceptions;

use Mesak\LaravelApiResponse\Exceptions\Handler  as ExceptionHandler;

```


## Controller

change your api controller, to extend  `Mesak\LaravelApiResponse\Http\Controllers\Controller`

```php
namespace App\Http\Controllers;

use Mesak\LaravelApiResponse\Http\Controllers\ApiController as BaseController;

class MainController extends BaseController
{

}
```

then enjoy this
Comparing Class and Functional Components in React: Understanding the Differences Between Stateful and Stateless Components
Tags: react, webdev
Published: 2022-12-31 09:55:09

In React, there are two main types of components: class components and functional components. Both types of components are used to define the UI of a React application, but they have some key differences that you should be aware of.

Class components are defined using a class that extends the React.Component base class. They have state, which is an object that stores data that can be used to render the UI. They also have a render method, which defines the JSX that is rendered to the screen. Class components are used when you need to store or modify state, or when you need to use lifecycle methods such as componentDidMount or shouldComponentUpdate.

Functional components, on the other hand, are simple functions that take in props and return JSX. They do not have state or lifecycle methods, and they are typically used for presentational components that do not need to store or modify data.

Here is an example of a class component:
```
class MyComponent extends React.Component {
  state = {
    count: 0
  };

  incrementCount = () => {
    this.setState({ count: this.state.count + 1 });
  }

  render() {
    return (
      <div>
        <h1>Count: {this.state.count}</h1>
        <button onClick={this.incrementCount}>Increment</button>
      </div>
    );
  }
}
```

And here is an example of a functional component:

```
const MyComponent = (props) => {
  return (
    <div>
      <h1>{props.title}</h1>
      <p>{props.description}</p>
    </div>
  );
}
```
In general, you should use functional components whenever possible, as they are simpler and easier to write. However, there are cases where you will need to use class components, such as when you need to store or modify state or use lifecycle methods. It's important to understand the differences between the two types of components so that you can choose the right one for your specific use case.
Code Push Integration And Benefits.
Tags: codepush
Published: 2022-12-31 09:49:51

**Introduction:**

Code push is a feature in React Native that allows developers to push code updates directly to users without requiring them to go through the app store update process. This can be especially useful for fixing bugs and making small updates to an app without the need for a lengthy review process.

**Integration steps:**

**Install the code push CLI:** You can install the code push CLI by running the following command: npm install -g code-push-cli

**Add the code push SDK to your app:** You can add the code push SDK to your app by running the following command: npm install --save react-native-code-push

**Link the code push library to your app:** You will need to link the code push library to your app using the react-native link command.

**Set up code push keys for your app:** You will need to set up code push keys for your app by running the following command: code-push register. This will generate a deployment key for your app, which you will use to release updates to your app.

**Initialize code push in your app:** You will need to initialize code push in your app by adding the following code to your app's entry point:

import codePush from "react-native-code-push";

const codePushOptions = {
  checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
  installMode: codePush.InstallMode.ON_NEXT_RESUME
};

const App = codePush(codePushOptions)(MyApp);

**Benefits of code push:**

**Quick bug fixes:** Code push allows developers to quickly fix bugs and release updates without the need for a lengthy review process. This can save a lot of time and effort, especially if the bug is critical and needs to be fixed as soon as possible.

**Improved user experience:** By releasing updates quickly, code push helps to improve the user experience by ensuring that users have access to the latest version of the app. This can also help to reduce the number of negative reviews and uninstalls, as users are less likely to encounter bugs and issues with the app.

**No need for app store updates:** With code push, developers can release updates directly to users without going through the app store update process. This can save a lot of time and effort, as the app store review process can take several days or even weeks to complete.

**Easy to use:** Code push is easy to use and integrates seamlessly with React Native apps. Developers can use the code push CLI to release updates with just a few simple commands.
Learning Kubernetes From Scratch Overview
Tags: kubernetes, devops, beginners, tutorial
Published: 2022-12-31 08:28:39

Kubernetes is an open-source container orchestration platform that helps you automate the deployment, scaling, and management of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF).

Here are some steps one can follow to learn Kubernetes from scratch:

Install a Kubernetes environment: You can either install Kubernetes on your local machine using tools like minikube or Docker for Desktop, or you can create a cluster in the cloud using a managed service like Google Kubernetes Engine (GKE), Amazon Elastic Kubernetes Service (EKS), or Azure Kubernetes Service (AKS).

Familiarize yourself with the Kubernetes concepts and architecture: Kubernetes has a number of key concepts that you should understand, such as nodes, pods, services, and deployment. You can learn about these concepts by reading the Kubernetes documentation or watching online tutorials.

Deploy your first application: Once you have a Kubernetes environment set up, you can start deploying applications to it. You can use the kubectl command-line tool to deploy applications in the form of Docker containers.

Explore advanced features: Once you have a basic understanding of how to deploy and manage applications on Kubernetes, you can start exploring more advanced features such as rolling updates, self-healing, and horizontal scaling.

There are many resources available online to help you learn Kubernetes, including the Kubernetes documentation, online courses, and interactive tutorials. It's also a good idea to join the Kubernetes community and participate in online forums and meetups to learn from other users and experts.
Create your Chess AI game in Python [VIM/NEOVIM]
Tags: python, vim, gamedev, tutorial
Published: 2022-12-31 09:07:28

Hey friends👋!
This is the last blog post I'll write this year, and it is going to be short cause everything you want you will find in the video below.
This is relatively a long video, coding quietly but leaving indications on what I'm doing throughout the video.
Chess has been always my favorite game, although I loose very often - that's one common thing between Gilfoyle and myself !
Here's the video:
{% youtube v13q6OG-0AU %}

Hope you enjoy it.
Happy New Year 2023 to you, your families and loved ones.
See you next year 😀
Cheers - Amir
Advantages of Rails over Sinatra
Tags: rails, sinatra
Published: 2022-12-31 08:56:55

Ruby on Rails is a powerful web application framework that is built on the Ruby programming language. It is designed to make it easy for developers to create web applications quickly and efficiently, and it has become a popular choice for many developers due to its simplicity and ease of use.

One of the main advantages of Ruby on Rails over other web application frameworks, such as Sinatra, is that it provides a full-stack framework. This means that it includes everything you need to build a complete web application, including the back-end server, the database, and the front-end user interface. This makes it much easier to develop and maintain web applications, as you don't have to worry about integrating multiple different tools and libraries.

Another advantage of Ruby on Rails is its convention over configuration approach. This means that it provides a set of default conventions for organizing code and structure, which can save a lot of time and effort for developers. This is particularly useful for projects with large teams, as it ensures that everyone is working in a consistent manner.

Ruby on Rails also has a large and active community, which means that there is a wealth of resources and support available for developers. This includes a wide range of libraries and plug-ins, as well as a large number of online forums and resources where you can find help and advice.

Overall, Ruby on Rails is a powerful and flexible web application framework that is well-suited for a wide range of projects. It offers many advantages over other frameworks, such as Sinatra, including a full-stack framework, a convention over configuration approach, and a large and active community. If you are considering building a web application, Ruby on Rails is definitely worth considering.