teleren/devto huggingface dataset:
How To Make Laravel Pusher Work In Production
Tags: laravel, laravelevents, pushercontest, php
Published: 2022-02-12 12:28:12

If you have ever deployed your laravel code to production environment and then you realized that for some reasons Pusher does not work in your production environment , then you are not alone. I will show you how to make Pusher work in your production environment from the server side. 

To make Pusher work in production, we need to ensure that Pusher has been set up correctly in our application. Let's set up Pusher on our existing Laravel application. If you have already installed Pusher, then skip to the next step. 

> If you don't know how to create a fresh Laravel application click [here](https://laravel.com/docs/8.x/installation)

**Step 1: Install Pusher**

```
composer require pusher/pusher-php-server
```
Once installation is complete, we'll make sure that Laravel broadcasting is registered in **config/app.php**. Go to config/app.php and uncomment the line below in the **providers** array.

`// App\Providers\BroadcastServiceProvider`

> If you need to know more about creating and defining events then take a look at [this](https://laravel.com/docs/8.x/events#defining-events)

**Step 2: Configure Pusher**

We will configure our pusher app credentials in config/broadcasting.php. We will create and get our Pusher credentials from here. And now. we'll supply our credentials in the .env file as thus:

```
PUSHER_APP_ID=xxxxxx
PUSHER_APP_KEY=xxxxxxxxxxxxxxxxxxxx
PUSHER_APP_SECRET=xxxxxxxxxxxxxxxxxxxx
PUSHER_APP_CLUSTER=xx
```

> Replace the xs with the actual pusher credentials

Now, we need to modify the pusher array in **config/broadcasting.php** so that it looks like this:

```
'pusher' => [
    'driver' => 'pusher',
    'key' => env('PUSHER_APP_KEY'),
    'secret' => env('PUSHER_APP_SECRET'),
    'app_id' => env('PUSHER_APP_ID'),
    'options' => [
        'cluster' => env('PUSHER_APP_CLUSTER'),
        'useTLS' => true,
        'encrypted' => true,
    ],
],
```

**Step 3: Update .env and Run Artisan Command**

We will now change the value of our broadcast driver in the .env from **log** to **pusher**. This tells Laravel what broadcast driver to use when implementing **ShouldBroadcast**  interface in our event class.

`BROADCAST_DRIVER=pusher`

And finally, run this command in your production environment

`php artisan config:clear`

You might want to run the following command;

`php artisan tinker`

and then check that your broadcasting configuration is correct - particularly the default connection which should be `pusher` - with the following line of code.

`config('broadcasting');`

If you have followed the steps above, then your events should work fine now.

**Conclusion**
You have learned how to make Pusher work in a production environment.

> **Please note:** there could be a number of reasons why your Pusher events do not work in your production environment. This is just one of them.
Basic React.
Published: 2022-02-12 12:28:00

PropTypes:
propType or props is basically used for passing read-only attributes between react components. By this property, we send data from one react component to another component. Props are stand for properties.

State: 
React state is another react build-in object by this state we can make and use their data. The state is also helpful for passing data by props.

JSX:
JSX is stand for javascript XML. By this JSX we can use our HTML code directly in our react project. It’s basically a syntax extension of javascript. It’s very helpful for a react developer.

Component Lifecycle:
every component in react has a lifecycle that can monitor and manipulate during its three main phases. 
Three phases are Mounting, updating, unmounting.

Hooks:
Hooks allow us to use state and other React features, like lifecycle methods, without writing a class. Hooks let you always use functions instead of having to constantly switch between functions, classes, higher-order components, and render props.

useEffect:
In useEffect we can leverage our component lifecycle hook which was in the past only supported for the class component. On the other hand, useState makes our functional component stateful which is normally stateless. 
Custom hook:
The custom hook allows you to perform tasks that are outside the scope of Data Hub. Custom hook modules can run immediately before or immediately after the step's core processes.

Context API:
Context API is a kind of data passing process by this react project people can wrap their component or element and what kind of data he wants by context API and then can use them from anywhere.

Components:
Components are used for building blocks for react application. They serve the same things as a javascript function it works on isolation return HTML. There have two types of components one is functional and the other is class component. 

Arrow function: 
arrow function is a new feature from ES6. If you use the arrow function you don’t need to bind any event ‘this’. Here the bind ‘this’ is global and not limited to any calling function. 

React Router:
React Router is a standard library it’s basically used for routing. With this router, we can navigate from one page to another and also from one component to another. This keeps the URL in sync with the data that’s being displayed on the web page.
Part 0: Prerequisites and summary of the project
Tags: vue, github, showdev, tutorial
Published: 2022-02-12 12:24:40

---
series: "Lightning fast build VueJS 3 project and deploy it free of charge to GitHub pages"
---

## Table Of Contents
* [Prerequisites](#chapter-1)
* [Why I created this project?](#chapter-2)
* [What I will build?](#chapter-3)
* [Next step] (#chapter-4)

<a name="chapter-1"></a>
### Prerequisites
To feel comfortable to follow along with the implementation of this project you should have at least basic knowledge of [Javascript](https://en.wikipedia.org/wiki/JavaScript), [VueJS](https://v3.vuejs.org/), [CSS](https://www.w3.org/) (I will be using CSS framework [Bulma](www.bulma.io)), [GitHub](www.github.com) and how to use `Terminal` on your computer.

<a name="chapter-2"></a>
### Why I created this project?
In one of my job interviews for the frontend developer role I have been asked to write a code with Vue 3 and provide it for review together with a link to the deployed (live) version.
I have decided to write detailed tutorial how I have solved this task, because **I like to learn. And I learn a lot when explain to others how I approached to solve tasks.** 

I have chosen to store my code on public GitHub repository to make it available for review. Once a code is ready on GitHub repo, then it is really easy to deploy it free of charge to GitHub Pages to make it available online.

<a name="chapter-3"></a>
### What I will build?
Hence, I have been asked to code a demo website with a list of products. Following conditions should have been met: 
- Loaded page should have several demo `products` stored.
- It should be available to `add`, `edit` and `delete` a product.
- Backend or database shouldn't be used, but products should be `stored` for each particular user who uses demo website.
- Product `code`, `name` and `price` should be available to `add` manually by the user.
- When a `price` of the product is added by the user, then `subtotal price` should be displayed immediately with a `tax` of `21%` added.
- Values should be reactive.
- Input fields should have validation rules, so that invalid values wouldn't be accepted.
- Demo website should have only `2 pages`. Main (index) page to `display`, `add`, `delete`, `edit` products and billing page to `display` a `list` of products and `subtotal price` of all the products.

<a name="chapter-4"></a>
### Next step
So, let's get started on the action!
127. Word Ladder
Tags: cpp, algorithms
Published: 2022-02-12 12:19:28

# **127. Word Ladder**

# Description

A **transformation sequence** from word `beginWord` to word `endWord` using a dictionary `wordList` is a sequence of words `beginWord -> s1 -> s2 -> ... -> sk` such that:

- Every adjacent pair of words differs by a single letter.
- Every `si` for `1 <= i <= k` is in `wordList`. Note that `beginWord` does not need to be in `wordList`.
- `sk == endWord`

Given two words, `beginWord` and `endWord`, and a dictionary `wordList`, return *the **number of words** in the **shortest transformation sequence** from* `beginWord` *to* `endWord`*, or* `0` *if no such sequence exists.*

## Example 1:

```
Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log","cog"]
Output: 5
Explanation: One shortest transformation sequence is "hit" -> "hot" -> "dot" -> "dog" -> cog", which is 5 words long.
```

## Example 2:

```
Input: beginWord = "hit", endWord = "cog", wordList = ["hot","dot","dog","lot","log"]
Output: 0
Explanation: The endWord "cog" is not in wordList, therefore there is no valid transformation sequence.
```

## Constraints:

- `1 <= beginWord.length <= 10`
- `endWord.length == beginWord.length`
- `1 <= wordList.length <= 5000`
- `wordList[i].length == beginWord.length`
- `beginWord`, `endWord`, and `wordList[i]` consist of lowercase English letters.
- `beginWord != endWord`
- All the words in `wordList` are **unique**.

---

# Solutions

## Solution 1

### Intuition

BFS

### Code

```cpp
class Solution
{
    public:
        int ladderLength(string beginWord, string endWord, vector<string> &wordList)
        {
            unordered_set<string> set;
            for (string &word: wordList) set.insert(word);
            unordered_map<string, int> dist;
            dist[beginWord] = 0;
            queue<string> q;
            q.push(beginWord);

            while (!q.empty())
            {
                string word = q.front(), next = word;
                q.pop();

                for (int i = 0; i < next.size(); i++)
                {
                    next = word;
                    for (char c = 'a'; c <= 'z'; c++)
                    {
                       	// change one char in next from a to z
                        next[i] = c;
                        if (set.count(next) && !dist.count(next))
                        {
                            dist[next] = dist[word] + 1;
                            if (next == endWord)
                            {
                                return dist[next] + 1;
                            }
                            q.push(next);
                        }
                    }
                }
            }

            return 0;
        }
};
```

### Complexity

- Time: BigO(M^2 * N), where M is size of dequeued word & N is size of our word list
- Space: BigO(M * N) where M is no. of character that we had in our string & N is the size of our wordList.

---
Find all colors and types in website
Tags: javascript, webdev
Published: 2022-02-12 12:06:10

Hey there! I am making an extension that is supposed to change all bright colors to more dark colors and have an issue on how to target or find all colors of any type (hex, hsl, rgb, rgba) in an html page when loaded and then for each color input them into my function `darkify(color_type, color` and specify the color type somehow. I have not found any tutorials online regarding this!
Execution Context , Hoisting and Access by Value and Access by Referencce 
Tags: javascript, webdev, programming, beginners
Published: 2022-02-12 11:37:59

**Execution Context **

//📌execution context - a environment , where javascript code is executed and evaluated

//global execution context - by default an execution provided by js ,i.e known as global execution context 
//this is the place where the whole code resides.

//eg. consider a example of nesting a loop , then the first loop is global exec context and the rest are
// sub exec context 


var a =3;
var b =5;

function sum(a,b)
{
    return a+b;
}

var sum1 =sum(5,6);
var sum2=sum(a,b);
console.log(sum1);
console.log(sum2);


**Hoisting **

console.log(a);

greet();

var a =2

function greet()
{
    console.log("Hello")
}


**Access by Value and Access by reference** 


// 📌Primitive and Non Primitive data type


//📌 PRIMITIVE DATA TYPE
let a =2.5
console.log(a,typeof(a))

//👉 ans -->2.5 number


let b ="hello"
console.log(b,typeof(b));

//👉ans -->hello string

let c =true
console.log(c,typeof(c));

//👉ans -->true boolean

let d =undefined
console.log(d,typeof(d));

//👉 ans -->undefined undefined

let e =null
console.log(e,typeof(e));

// 👉ans-->null object

//📌Even though null is a primitive data type , it is given object in js (in  js - it is treated as missing object)(it is considered as a bug in js till date)


//📌 NON PRIMITIVE DATA TYPE


let firstperson ="hitesh"

let secondperson =firstperson

console.log(firstperson);
console.log(secondperson);

// 👉ans-->
// hitesh
// hitesh

let firstperson1 ="hitesh"

let secondperson1 =firstperson

firstperson1="arshad"

console.log(firstperson1);
console.log(secondperson1);

//👉 ans -->
// arshad
// hitesh

https://github.com/pushanverma/notes/tree/main/webd
Import Excel File into Laravel 8
Tags: laravel, php, tutorial, programming
Published: 2022-02-12 10:56:31


![Import Laravel Excel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bd4a4oxd7v7b0j8qer17.png)

##Import CSV Files into Laravel 8

Today I am Going To Explain you about how you can import Excel / CSV Files into Laravel.

I am going to use [Tech-Admin Panel](https://dev.to/techtoolindia/how-to-create-admin-panel-in-laravel-8-in-10-min-43ni) for this.

For importing excel file i am using [Laravel Excel](https://laravel-excel.com/).

##Step 1 - Installation
To Install the [Laravel Excel](https://laravel-excel.com/) Package via composer run command below.
```php
composer require maatwebsite/excel
```

Next to export config file you need run command below.
```php
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
```

##Step 2 - Create an Import Class inside `app/Imports`

Create Import Class by using artisan command

```php
php artisan make:import UsersImport --model=User
```

##Step 3 - Update UsersImport Class

In order use CSV/Excel Files with heading we have to implement `WithHeadingRow`, UsersImport Class will look like.

```php
<?php

namespace App\Imports;

use App\Models\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class UsersImport implements ToModel, WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        return new User([
            "first_name" => $row['first_name'],
            "last_name" => $row['last_name'],
            "email" => $row['email'],
            "mobile_number" => $row['mobile_number'],
            "role_id" => 2, // User Type User
            "status" => 1,
            "password" => Hash::make('password')
        ]);
    }
}

```

##Step 4 - Handle Uploaded Excel/CSV File
```php
public function uploadUsers(Request $request)
{
        Excel::import(new UsersImport, $request->file);
        
        return redirect()->route('users.index')->with('success', 'User Imported Successfully');
}
```

You can watch the explanation video for more clarity.

{% youtube -h2wpwATsXw %}

In Next part i will explain about Export Users.

Thank You for Reading!

Reach Out To me.
[Twitter](https://twitter.com/techtoolindia)
[Instagram](https://www.instagram.com/techtoolindia/)
[YouTube](https://www.youtube.com/channel/UCOy6o08Yn9DtXMKqxhD9ivA)
How to import excel CSV file into Laravel
Tags: laravel, php, tutorial, webdev
Published: 2022-02-12 10:52:57


![Import Laravel Excel](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bd4a4oxd7v7b0j8qer17.png)

##Import Excel CSV Files into Laravel 8

Today I am Going To Explain you about how you can import Excel / CSV Files into Laravel.

I am going to use [Tech-Admin Panel](https://dev.to/shanisingh03/free-laravel-8-admin-starter-kit-1b5i) for this.

For importing excel file i am using [Laravel Excel](https://laravel-excel.com/).

##Step 1 - Installation
To Install the [Laravel Excel](https://laravel-excel.com/) Package via composer run command below.
```php
composer require maatwebsite/excel
```

Next to export config file you need run command below.
```php
php artisan vendor:publish --provider="Maatwebsite\Excel\ExcelServiceProvider" --tag=config
```

##Step 2 - Create an Import Class inside `app/Imports`

Create Import Class by using artisan command

```php
php artisan make:import UsersImport --model=User
```

##Step 3 - Update UsersImport Class

In order use CSV/Excel Files with heading we have to implement `WithHeadingRow`, UsersImport Class will look like.

```php
<?php

namespace App\Imports;

use App\Models\User;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Hash;
use Maatwebsite\Excel\Concerns\ToModel;
use Maatwebsite\Excel\Concerns\WithHeadingRow;

class UsersImport implements ToModel, WithHeadingRow
{
    /**
    * @param array $row
    *
    * @return \Illuminate\Database\Eloquent\Model|null
    */
    public function model(array $row)
    {
        return new User([
            "first_name" => $row['first_name'],
            "last_name" => $row['last_name'],
            "email" => $row['email'],
            "mobile_number" => $row['mobile_number'],
            "role_id" => 2, // User Type User
            "status" => 1,
            "password" => Hash::make('password')
        ]);
    }
}

```

##Step 4 - Handle Uploaded Excel/CSV File
```php
public function uploadUsers(Request $request)
{
        Excel::import(new UsersImport, $request->file);
        
        return redirect()->route('users.index')->with('success', 'User Imported Successfully');
}
```

You can watch the explanation video for more clarity.

{% youtube -h2wpwATsXw %}

In Next part i will explain about Export Users.

Thank You for Reading

In case of any query related to LARAVEL.
Reach Out To me.
[Twitter](https://twitter.com/shanisingh03)
[Instagram](https://www.instagram.com/shanisingh03/)
Top 5 vscode themes
Tags: vscode, theme, looks, codenewbie
Published: 2022-02-12 10:36:58

# 1 : Ayu theme

![](https://github.com/ayu-theme/vscode-ayu/raw/HEAD/assets/dark.png)

[Download](https://marketplace.visualstudio.com/items?itemName=teabyii.ayu)

--- 

# 2 : Material darker

![](https://raw.githubusercontent.com/divyanshu013/vscode-material-darker/master/screenshot.png)

[Download](https://marketplace.visualstudio.com/items?itemName=jantto.theme-material-darker)

--- 

# 3 : deepdark material

![](https://ph-files.imgix.net/b3b56d37-c196-41ee-9632-4a450ecae7e5.png?auto=format&auto=compress&codec=mozjpeg&cs=strip)

[Download](https://marketplace.visualstudio.com/items?itemName=Nimda.deepdark-material)


--- 

# 4 : Andromeda theme

![](https://res.cloudinary.com/practicaldev/image/fetch/s--UsLZEFvp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://github.com/EliverLara/Andromeda/raw/master/images/andromeda.png)

[Download](https://marketplace.visualstudio.com/items?itemName=EliverLara.andromeda)


--- 

# 5 : Atom one dark 

![](https://raw.githubusercontent.com/emroussel/atomize/main/images/screenshot.png)

[Download](https://marketplace.visualstudio.com/items?itemName=akamud.vscode-theme-onedark)

--- 

## follow me 

[Github](https://github.com/MassiiNechiche)
lwder.js - Lightweight Loading Animation
Tags: javascript, vanillajs, webdev
Published: 2022-02-12 10:35:56

Hi,

This time I created the simplest of all the simple projects.

Why did I do this? because even though it's a simple "task" and can be done with a few lines of CSS (but much more limited), I actually use it a lot in my projects.

I thought of making a simple library that would allow me to use it much faster and whenever I wanted in the project with just a few lines.

Have a look: 
https://github.com/BMSVieira/lwder.js
Any idea for valentines day?
Published: 2022-02-12 10:29:19

Hey guys, im just new in coding. Almost 1 month. I am 31 y.o personal trainer and living with my girlfriend. She's fully supports me for changing career into coding. And i wanna make a little tiny suprise with some coding stuff. 😅 I am currently learning html and css. Do you know like a little tutorial about it or do you suggest me some way?  

Thank you for your reply.🙏🏼
Como dividir páginas PDF online?
Published: 2022-02-12 10:26:59

Dividir páginas PDF online

Baixe o aplicativo PDF Champ para Split PDF Pages Online. O aplicativo funciona muito bem e divide seus arquivos pdf de forma confiável. Com a visualização adequada, bem como a digitalização dos arquivos, o processo de divisão é feito e os usuários podem dividir páginas PDF online sem problemas. Siga o procedimento abaixo para Dividir Páginas PDF Online:

1. passo 1- Adicione os arquivos pdf que você deseja dividir
2. passo 2- Agora, selecione as páginas
3. passo 3- Em seguida, escolha o caminho para salvar os arquivos divididos
4. passo 4- Por fim, pressione o botão "dividir agora"

Referir :[http://www.splitpdf.pdfchamp.com/](http://www.splitpdf.pdfchamp.com/)
Devops Course: Best classes for distance learning
Tags: devops
Published: 2022-02-12 09:57:08

Learning devops will help you master all the skills needed in order to successfully build, operate, monitor, measure and improve the various processes in IT enterprises by better integrating development and operations. We are offering the top devops tutorial that can be watched by anybody to learn devops. Our devops tutorial has been created with extensive inputs from the industry so that you can learn devops easily.
.
Watch Now:  [https://www.youtube.com/watch?v=JHoy3lDZOfY](https://www.youtube.com/watch?v=JHoy3lDZOfY)
Watch Now!! Here is the best video to learn AWS Course by top Experts.
Tags: aws
Published: 2022-02-12 09:56:06

In this video on AWS Course, you will learn AWS from scratch along with the hands-on demo and job interview preparation. This is a must-watch session for everyone who wishes to learn AWS and make a career in the cloud domain. After watching this video you have skills of an AWS Solution Architect and you will clear AWS Certified Solutions Architect certification in one go.
.
Watch Now- [https://www.youtube.com/watch?v=iOiCWWhA0Cs](https://www.youtube.com/watch?v=iOiCWWhA0Cs)
Looking Ahead: The Future of Data Science Course in 2022
Published: 2022-02-12 09:55:14

This data science tutorial video will teach you everything you need to know about becoming a data scientist. It covers topics such as what is data science, what data scientists do every day, what their salary is, and major statistics and probability concepts.
.
Watch now : [https://www.youtube.com/watch?v=QtYOI-9R1vo](https://www.youtube.com/watch?v=QtYOI-9R1vo)