teleren/devto huggingface dataset:
full stack training in Pune
Tags: fullstack, webdeveloper, css, javascript
Published: 2023-05-04 10:35:27

**what do you mean by full stack?**
=>Refers to the development of the front-end (client-side) and back-end (server-side) parts of a web application.
**Career as full stack web developer?**
=>As a subfield of computer programming, full-stack development often offers related career opportunities. With experience, full-stack developers can rise to senior positions such as project manager, programming consultant, and computer scientist.
**Full stack course:-**
=>Pune's full-stack course is one of the most popular stacks in development. Web developers are not just technical experts, they need to know all aspects of web development, from design (front-end) to development, databases, and testing. The resources available to learn full-stack web development are very limited. Or you can study the separate technologies and combine them. But [SevenMentor](https://www.sevenmentor.com/) Provides a complete [Full stack Course in Pune](https://www.sevenmentor.com/full-stack-training-institute-in-pune.php).
Here is your chance to get [full stack classes in pune](https://www.sevenmentor.com/full-stack-training-institute-in-pune.php) and build your career.
What is Kubernetes (K8s)
Tags: webdev, tutorial, beginners, productivity
Published: 2023-05-04 10:26:31

I know you must have heard about the almighty Kubernetes right? and you have been wondering what it is, the problem it's solving right? Don't worry, I will explain everything for you here.

**What is Kubernetes**
Kubernetes is an orchestration system that automatically enables deployment,scaling (both up and down)and management of containerized applications. Kubernetes was first announced by Google in mid 2014, this system was created by Google engineers like Joe Beda, Brendan Burns and the rest. But currently, Kubernetes is being managed by the Cloud Native Computing Foundation (CNCF).

Kubernetes helps you to manage your containerized applications automatically. What are containerized applications? Containerized applications are software applications that has been packaged in a container. This involves putting your code, runtime, system tools, libraries, settings etc in a containerization technologies like Docker.

Now image you have lots of files on your desk, and each of this files contains different important informations but you can't easily identify each of the files. What Kubernetes helps you to do is that it will serve like a file organizer for you, it helps to keep each files in the right place and make it easier for you to easily identify each file. 

In a professional settings, Kubernetes will put all of the containerized applications into what we call cluster.
If one of the node in the cluster fails, Kubernetes will automatically carryout what we call "self-healing", where it will reschedule the containers running on that node to other healthy nodes in the cluster.

Now you have seen why Kubernetes is becoming so popular these days. Now let me comprehensively list the importance of using Kubernetes.

1. Automatic deployment.

2. Self-healing.

3. Resource management.

4. Scalability.

5. Batch execution.

6. Service discovery and load 
   balancing.


Hope I have explained what Kubernetes is, it's functions and why you should use it. Hope you really understand everything I wrote in this article, drop your questions below if you have any. Happy coding 😊!
Zip upload with validations in Laravel
Tags: laravel, php, zip
Published: 2023-05-04 10:18:16

Following code is for unzipping files, then validating and lastly saving in the database.

```php
public function unzip_contents_gallery(Request $request)
    {
        try{
            $v = [];
            $allowed_exts = [
                'png',
                'jpeg',
                'jpg',
                'webp',
            ];
            $zip = new ZipArchive();
            $status = $zip->open($request->file("zip_gallery")->getRealPath());
        
            if ($status !== true) 
                throw new Exception('Un-supported zip archive');

            for($i=0; $i<$zip->count();$i++)
            {
                array_push($v, ['name' => $zip->getNameIndex($i)]);
                $ext_name_arr = explode('.', $zip->getNameIndex($i));
                if(!(in_array(end($ext_name_arr), $allowed_exts)))
                    throw new Exception('File not supprted!');
            } 
            $rules = [
                '*.name' => 'required|unique:galleries,gallery',
            ];
            $validator = Validator::make($v, $rules);
            if($validator->fails()) 
                throw new Exception(json_encode($validator->errors()->all()));
                // throw new Exception($validator->errors()->first());
            
            $storageDestinationPath = public_path('uploads/gallery_images');
            if (!\File::exists( $storageDestinationPath)) {
                \File::makeDirectory($storageDestinationPath, 0755, true);
            }
            $zip->extractTo($storageDestinationPath);
            $zip->close();
            for($i=0; $i<count($v);$i++)
            {
                Gallery::create([
                    'gallery' =>  $v[$i]
                ]);
            } 
            
            $msg = "File Upload Successfully";
            return redirect()->back()->withSuccess($msg);
        }
        catch(Exception $e)
        {
            return redirect()->back()->withErrors($e->getMessage());
        }
    }
```
Using GPT to Analyze Cloud Security Issues for GCP
Tags: gpt3, policyasco, devops, selefra
Published: 2023-05-04 10:18:09

![Banner](https://superblog.supercdn.cloud/site_cuid_cldhcpt7a1506291jkdhe6vl2sc/images/banner-1683182488103-compressed.png)

### Intro

Cloud security has become a crucial task in today's digital age. With countless cloud security issues emerging every day, it's challenging to manually analyze and resolve them quickly. This is where Selefra comes in - a Policy-as-code product that incorporates GPT functionality to help users perform cloud security analysis, cost analysis, and architecture analysis efficiently on Google Cloud Platform (GCP).

The GPT feature in Selefra allows users to analyze GCP products for security issues similarly to how ChatGPT works. In this article, we will use GCP storage bucket issues as an example to demonstrate how to use Selefra.

## Running Selefra

### Install

First, installing Selefra is very simple. You just need to execute the following command:

```bash

brew tap selera/tap
brew install selefra/tap/selefra
mkdir selefra-demo & cd selefra-demo & selefra init
```

### Choose provider

Then, you need to choose the provider you need in the shell, such as GCP:

```bash

[Use arrows to move, Space to select, and enter to complete the selection]

[ ] AWS 
[ ] azure
[✔] GCP # We choose GCP installation
[ ] k8s

```

### Configuration

**configure GCP:**

You can configure your GCP information in advance by referring to our detailed configuration document available at [Document](https://www.selefra.io/docs/providers-connector/gcp).

**configure Selefra:**
After initialization, you will get a selefra.yaml file. Next, you need to configure this file to use the GPT functionality:

```yaml

selefra:
  name: selefra-demo
  cli_version: latest
  openai_api_key: <Your Openai Api Key>
  openai_mode: gpt-3.5
  openai_limit: 10
  providers:
    - name: gcp
      source: gcp
      version: latest

```

### Running

You can use environment variables to store the openai_api_key, openai_mode, and openai_limit parameters. Then, you can start the GPT analysis by executing the following command:

```bash

selefra gpt "Help me search for GCP users who do not have MFA activated"
```

Finally, you will get results similar to the animated image below:

![gpt](https://superblog.supercdn.cloud/site_cuid_cldhcpt7a1506291jkdhe6vl2sc/images/3-1683182597550-original.gif)

## Thanks for reading

We highly recommend trying Selefra to experience a faster and more efficient cloud security analysis and resolution.

For more information on Selefra：

Website: **[https://www.selefra.io/](https://www.selefra.io/)**

GitHub: **[https://github.com/selefra/selefra](https://github.com/selefra/selefra)**

Twitter: **[https://twitter.com/SelefraCorp](https://twitter.com/SelefraCorp)**
My favourite Bash feature
Tags: tip, bash, productivity, discuss
Published: 2023-05-04 10:15:43

Just a quick one here, but I used this a lot today and realised after chatting to some other devs that a lot of people don't know about this trick.

That trick is: [History Expansion](https://www.oreilly.com/library/view/learning-the-bash/1565923472/ch02s06.html)

Let's say you are SSH'd (or SSM'd on AWS if you want to be more secure) onto a Linux box and you want check the status of a service with

```
systemctl status cassandra.service
```

You see that the service is exited for some reason, and you want to restart it after determining that's all that is needed.

Do you now go and type out

```
systemctl restart cassandra.service
```

or do you want to be 1337 and impress all your friends with

```
^status^restart
```

We all know you prefer the latter.

There are some variations on this, I recommend you check out the docs (or `man` pages for the really 1337 among you).

What are some of your favourite Bash tricks?
How to Use VSCode with Raspberry Pi Pico W and MicroPython
Tags: vscode, raspberrypi, micropython, iot
Published: 2023-05-04 09:34:35

{% embed https://www.youtube.com/watch?v=O6lkYTfcMEg %}

** The extension is now called MicroPico **

This tutorial demonstrates how to start coding on the Raspberry Pi Pico or Pico W using Visual Studio Code. Connecting to the Raspberry Pi Pico W in VScode can help you write and debug code more efficiently, and improve your development workflow for embedded systems projects. This integration can help you streamline your development workflow and reduce the time it takes to get your code up and running on the Raspberry Pi Pico W.

**Step 1-) Install MicroPython on Pico**

Plugin the device into the computer while holding the bootsel button.

Go to https://micropython.org/download/ and download the latest version for the Pico or Pico W

Drag the UF2 file onto your Pico once it is done downloading. *It should show up on your Desktop as RP1-RP2.

Once it is done, the RP1-RP2 will disappear. 

Unplug and replug the Pico (without holding the bootsel). You need to do this so VSCode can find the device. 

**Step 2-) Download Pico-W-Go Extension**

Make sure you have Python 3.9 installed on your computer. It is one of the requirements for the extension.

Go to extensions in VSCode and install the extension. Search “Pico”. Note that it was previously called Pico-Go.

**Step 3-) Write Code**

Create a directory on your local computer, and open the empty directory on VSCode

Configure the Pico-W-Go environment. Run Pico-W-Go > Configure Project command via Ctrl+Shift+P (or the equivalent on your platform) VS Code command palette. This will import stubs for autocompletion and the settings into your project folder. For the auto-completion to work, the extension prompts you (after project configuration) to install recommended extensions mentioned.

Create a Python file in the directory and add the following code:

```
from machine import Pin
from time import sleep

pin = Pin("LED", Pin.OUT)

while True:
    pin.toggle()
    sleep(1)
```

Make sure the Pico is connected (shown on the bottom of the screen)

Run the current file (by right-clicking the file name and selecting Run current file)

You should see the LED start blinking! If you did, congrats. 

You can use other operations in the library, such as deleting all code on your device or downloading files from the Pico, which will help you develop your projects faster. Overall, developing on VSCode has several advantages over Thonny and may be your preferred IDE for developing on the Raspberry Pi Pico. 

**Conclusion**
Hope I saved you some time, if I did please subscribe to the channel for more useful tips that will help you in your coding endeavors.
Redux - Hidden Dependencies
Tags: javascript, react, redux, architecture
Published: 2023-05-04 09:20:19

Let's talk about using Redux. The downsides of Redux can be listed for a long time. As long as you use Redux as a state-manager, it's tolerable. But as soon as you start using Redux as a **“cache”** for data you received from the backend, the situation worsens significantly.

Let's see what this is all about.

![Redux hidden dependency - components schema](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ywdzvi9ddn1vt854xunb.png)

This diagram shows that component D requests user data and puts it in the Redux store. Component B consumes user data - it retrieves it from the Redux store using selectors.

This is all good. The code is written and it's better not to mess with it. Because as soon as you want to remove component D, your application will break.


![Redux hidden dependency - problem](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19r7kadmro3mmy70hmqi.png)

It turns out that an unknown number of components depend on component D. But most importantly, **this dependency is not expressed in the code.** That is, as soon as you plan to refactor some component, you need to make sure it doesn't request any data, and if it does, find all the places that consume this data. After that, you will have to think about where to request this data now and put it in the Redux store.

What to do? How to get rid of heavy brainstorming associated with refactoring? The solution has long existed, but many people do not use it - using tools that truly cache your backend requests: **Apollo Client, RTK Query, React Query, SWR.**


![Redux hidden dependency - solution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j3hn5id6xtgdofg8u8ca.png)

If you use a cache instead of Redux, then we can not worry about where and how to request data. And "not worrying" is very important, because you can concentrate on more important things - thus, we can mindlessly refactor components, without thinking about such hidden dependencies.
Deploying Strapi on Render free plan
Tags: strapi, render, headlesscms, javascript
Published: 2023-05-04 09:09:51

This post assumes that you have already installed the Strapi backend on your local machine. If you have not, you can do that by following the instructions on the link below.
 [Install strapi and create new project](https://docs.strapi.io/dev-docs/quick-start#_1-install-strapi-and-create-a-new-project)
After installation, create a new user and create your collections.
In your command line navigate to the root folder and initialize git and push to remote origin. If you do not know how to go about it, you can do so following the instruction below.
[Adding locally hosted code to GitHub](https://docs.github.com/en/migrations/importing-source-code/using-the-command-line-to-import-source-code/adding-locally-hosted-code-to-github)
login to render and click on the new button


![installing a new app on render](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/uvtoxpmk4u4ja5q4dgxi.png)
Select Web Service.
Connect to your GitHub or GitLab Account. and click on the connect button beside the repo you selected

![connect to github](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sb6ppus7rux133y4nyvq.png)

Enter a unique name for your web service


![web service name](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5fs32q3ek57e1rwz7v38.png)

Change the start command from `yarn start` to `yarn develop`. this is to enable you create collection on the production environment


![start command](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6w1bvliug4m77m4k6g7.png)
Leave every other thing as is and click on create Web Service.

![create web service](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtwmqfy48zmenxazzrh3.png)
The deployment starts


![start deployment](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wearkrp7jynloyn4461l.png)
Select Environment from the left navigation pane and click on the Add Secret File button

![Add Secret File](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/js4ortou02vjrppx1vkp.png)

enter the file name as .env, click on the eye icon 


![create secret file](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v9cz80kkimwxush1bvcw.png)


copy the content of the .env file in your root folder on local and paste it in the textarea.
change the value of DATABASE_FILENAME to /data/strapi.db from .tmp/data.db
 click on done


![.env content](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ckf3e65skvt67t6ss10.png)

Click on the save changes button.
Click on Events on the left navigation pane to monitor your deployment.

![deploy text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yo40w77csfh16n84eapf.png)


Select the deployment by clicking on the **deploy** text.
the log should display like this when the deployment is done.

![deploy complete](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jpqf0575eooeo3hla8eo.png)
visit your url/admin to access the strapi backend deployed
Dependency Inversion Principle
Tags: programming, oop, csharp, dotnet
Published: 2023-05-04 09:00:39

The Dependency Inversion Principle (DIP) states that:

> _High-level modules should not depend on low-level modules.
Both should depend on abstractions. Abstractions should not depend on details. Details should depend on abstractions._

In other words, this principle encourages the use of abstractions to decouple high-level and low-level modules, making the code more modular and easier to maintain, test, and extend.

## Violation of the principle

Imagine having an application for logging messages, where a high-level `Logger` class is directly dependent on a low-level `FileLogger` class:

```csharp
public class FileLogger
{
    public void LogMessage(string message)
    {
        // Write the message to a file
    }
}

public class Logger
{
    private readonly FileLogger _fileLogger;

    public Logger()
    {
        _fileLogger = new FileLogger();
    }

    public void Log(string message)
    {
        _fileLogger.LogMessage(message);
    }
}
```

In this example, the DIP is violated because the high-level `Logger` class is directly dependent on the low-level `FileLogger` class. This design can make the code less flexible and harder to maintain, as changes in the `FileLogger` class could affect the `Logger` class, and it would be difficult to switch to a different logging mechanism.

## Application of the principle

To resolve the violation of the DIP, we can introduce an abstraction for logging and use dependency injection to decouple the high-level and low-level modules:

```csharp
public interface ILogger
{
    void LogMessage(string message);
}

public class FileLogger : ILogger
{
    public void LogMessage(string message)
    {
        // Write the message to a file
    }
}

public class Logger
{
    private readonly ILogger _logger;

    public Logger(ILogger logger)
    {
        _logger = logger;
    }

    public void Log(string message)
    {
        _logger.LogMessage(message);
    }
}
```

Now, the high-level `Logger` class depends on the `ILogger` abstraction instead of the low-level `FileLogger` class, and the Dependency Inversion Principle is respected. This decoupling makes the code more modular, easier to maintain, and allows for easy substitution of different logging mechanisms.

## Conclusion

In this article, we have summarized the Dependency Inversion Principle, which teaches us to design high-level modules to depend on abstractions, not low-level modules, to decouple high-level and low-level modules using abstractions and dependency injection, and to make the code more maintainable and flexible by minimizing the impact of changes in low-level modules on high-level modules.

## References

- [Clean Code: A Handbook of Agile Software Craftsmanship](https://www.pearson.com/en-us/subject-catalog/p/clean-code-a-handbook-of-agile-software-craftsmanship/P200000009044/9780132350884)
- [Adaptive Code: Agile coding with design patterns and SOLID principles](https://www.microsoftpressstore.com/store/adaptive-code-agile-coding-with-design-patterns-and-9781509302581)
A stock market analysis web application (1/n)
Published: 2023-05-04 08:52:16

I want to create a  web application as a practice for my skills in front-end web development, data scraping, cleaning, visualization, and back-end database management.

**But, I know nothing about stock!!**

So, in this blog, I am just gonna get myself familiar with some of the terminologies. If anyone happens to read this blog, and find any errors please let me know with a comment, thank you very much.

<hr>

Refer to the U.S Securities and Exchange Commission (SEC)'s official website to details: [click me](https://www.investor.gov/introduction-investing/investing-basics/investment-products/stocks#:~:text=Stocks%20are%20a%20type%20of,also%20are%20called%20%E2%80%9Cequities.%E2%80%9D)

## What is a stock?
Stocks are a type of investment product that represent ownership in a company and a claim on a portion of the company's assets and earnings. They also are called 'equities'

## Why do people stocks?
Also according to SEC, for the following reasons:
- Capital appreciation, which occurs when a stock rises in price
- Dividend payments, which come when the company distributes some of its earnings to stockholders
- Ability to vote shares and influence the company

## Why do companies issue stock?
Company needs money!

## How to buy and sell stocks?
There are various ways available:
- A direct stock plan
- A dividend reinvestment plan
- A discount or full-service broker
- A stock fund

## What stock to buy?
This will be the key purpose of this study, I don't have a broker who does research and give me investment advice, hence, I wonder if I can do some research myself and then make purchase.

:memo: Note, do not expect to much from stock market, the sole purpose of doing this is to practice building an web application while learning a little bit more about stocks~
Recovergoroutine prevents panic from occurring within goroutines
Tags: go, programming, opensource
Published: 2023-05-04 08:46:32

https://github.com/Buzzvil/recovergoroutine

If a panic occurs during server operation, the server is down. While servers typically employ a Recover middleware to address this, if a panic occurs within a goroutine, a middleware does not cover it as it executes in a separate context. I believe that such mistakes can easily be made by humans, so I devised a linter that checks whether the Recover process has been implemented in a goroutine without fail, and I created the linter.
JavaScript Array Unshift, Push , Shift, Pop
Tags: javascript, beginners
Published: 2023-05-04 08:33:55

Unshift, Push , Shift, Pop 

**Unshift** is _adding_ the first one of the array.
**Push** is _adding_ the last one of the array. 
**Shift** is _deleting_ the first one of the array.
**Pop** is _deleting_ the last one of the array.

Example 

```
let customers = ['Eelyn', 'Ken', 'Mike']; 
```

```
//Unshift 
customers.unshift('Winnie');
console.log(customers)
```
Result :
`['Winnie', 'Eelyn', 'Ken', 'Mike']`

----------------------------------
```
//Push
customers.push('Melissa');
console.log(customers)
```
Result :
`['Winnie', 'Eelyn', 'Ken', 'Mike', 'Melissa']`

----------------------------------

```
//Shift
customers.shift();
console.log(customers)
```
Result :
`['Eelyn', 'Ken', 'Mike', 'Melissa']`

----------------------------------

```
//Pop
customers.pop();
console.log(customers)
```
Result :
`['Eelyn', 'Ken', 'Mike']`

----------------------------------