teleren/devto huggingface dataset:
Laravel 8 Create Custom Helper Function Example
Tags: laravel, laravel8, helper, custom
Published: 2022-01-17 03:38:23

In this tutorial we will see laravel 8 create custom helper function example. As we all know laravel provides many in-built function in their framework, but many times we need to require our own customised function to use in our project at that time we need to create custom helper function. So, here I am show you custom helper function example in laravel 8.

You can create own custom helper function in laravel 6, laravel 7 and larvel 8. Laravel includes a variety of global "helper" PHP functions.

Arrays & Objects

    Arr::first
    Arr::get
    Arr::pluck
    Arr::prepend
    Arr::sort

 
Paths

    config_path
    public_path
    storage_path

 
Strings

    Str::replace
    Str::slug
    Str::before
    Str::limit

 
Fluent Strings

    isEmpty
    trim
    dirname
    explode

 
URLs

    asset
    route
    url

 
Miscellaneous

    config
    dd
    env
    with
    collect
    csrf_token

 

So, let's see how to create custom helper in laravel 8.

> Step 1 : Create helpers.php File

In this step, we will create app/helpers.php file in our laravel project and adding the below code.

app/helpers.php

```
<?php
  
function change_Date_Format($date,$format){
    return \Carbon\Carbon::createFromFormat('Y-m-d', $date)->format($format);    
}

?>
```
 
> Step 2: Add Helper File Path In composer.json File

Add below code in composer.json file.

```
"autoload": {
        "psr-4": {
            "App\\": "app/",
            "Database\\Factories\\": "database/factories/",
            "Database\\Seeders\\": "database/seeders/"
        },
         "files": [
            "app/helpers.php"
        ]
    },
```
 
> Step 3: Run Command

Now, run below command in your terminal

```
composer dump-autoload
```

So, we are done with custom helper function in laravel 8, as of now we can use this function any where.

Here i am using this function in blade file.

```
<html>
 <head>
     <meta charset="utf-8">
     <meta http-equiv="X-UA-Compatible" content="IE=edge">
     <title>Laravel 8 Create Custom Helper Functions Example - Techsolutionstuff</title>
     <link rel="stylesheet" href="">
 </head>
 <body>
    <h3>Laravel 8 Create Custom Helper Functions Example - Techsolutionstuff</h3>
     <h3>New Date Format: {{ change_Date_Format(date('Y-m-d'),'m/d/Y')  }}</h3>
 </body>
</html>
```

--- 

You might also like :

- [Read Also : Laravel 8 Form Validation Example](https://techsolutionstuff.com/post/laravel-8-form-validation-example)

- [Read Also : Laravel REST API CRUD Tutorial](https://techsolutionstuff.com/post/laravel-rest-api-crud-tutorial)

- [Read Also : Jquery Input Mask Phone Number Validation](https://techsolutionstuff.com/post/jquery-input-mask-phone-number-validation)
Basic Web Components with Open-wc, npm, node.js, and VScode
Tags: webcomponents, npm, node, vscode
Published: 2022-01-17 03:20:43

In order to start talking about web components and using open-wc, we have to introduce the building blocks that allow us to make that possible. To use open-wc, we have to install a few different dependencies that make it function. Before we install, let's talk about a few of them. First is npm, which is a JavaScript Node package manager. It offers the largest selection of code packages in their software registry. This is typically concurrently used with Node.js. Node.js is a open-source JavaScript runtime environment where code can be executed outside of the web. 

Both of these JavaScript add-ins make developers lives much easier. They are free to use and open-source that make it possible to share software with others and do things that were not possible before their development. They are very commonly used in web development with back-end tools to allow for runtime processes that can occur quicker and more efficient in the web. Now, let's look at installing these JavaScript helpers.

### Node.js
Go to this [webpage](https://nodejs.org/en/download/) and download the LTS version of nodejs for your device. Open the package in your downloads file folder and follow the directions to install.

### npm
For npm, this can be done in the command line / terminal. Directions can be found [here](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) to download and install. After running that command, the commands `node -v` and `npm -v` can be used to check that the most current version is installed.

### Yarn
Another software component we use for web develop is Yarn. We can install this in the command line with npm with the command `npm install --global yarn`. To check the version, use command `yarn --version`.

### Visual Studio Code
VSCode can be downloaded and installed [here](https://code.visualstudio.com/docs/setup/mac). VSCode is a coding text editor for many different programming languages.

## Build a Web Component
Now that we have installed those dependencies, we can make a web component with open-wc. Create a new folder/directory to house this project using either your file explorer or in the terminal with command `mkdir`. In your terminal, run the command `npm init @open-wc`. If this command was successful, you have installed everything correctly and you should see this! 

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

When setting up the web component, the parameters I used were:
* Scaffold a new project
* Web component
* Linting, Testing, and Demoing
* No typescript
* Install with npm

From this, open-wc should open a new tab in your web browser showing this:

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

Congratulations you have successfully made a web component/element!

The github repository containing the code for the web element is [here](https://github.com/zjohnson10/zjohnson-lab1.git).
Using HestiaCP to manage a Virtual Private Server (VPS)
Tags: vps, hestiacp, admin, server
Published: 2022-01-17 02:54:00

Howdy! 👋

It has been a while since I posted for the last time! But, yeah, it's 2022, a new year has just begun and it's time for a new post. 🙌

Many years ago, I was used to have [Virtualmin](https://www.virtualmin.com/)/[Webmin](https://www.webmin.com/) installed as the control panel for the VPSs I do maintain, so I could manage them through a User Interface (UI) instead of making everything in the command line. 

Despite the fact that these were powerful solutions to manage servers, I got bored because they also are quite complicated to operate, so I started looking for simpler options and came across another an option called [VestaCP](https://vestacp.com/). 

VestaCP was an outstanding open-source solution, built with PHP and very intuitive to be used. Well, it's true that the simplicity comes with a price: unlike Virtualmin/Webmin, some tasks would need to be performed in the command line if using VestaCP, but, that was a good trade-off considering my profile and needs.

> If you already run a VestaCP and are looking for putting your VPS behind [CloudFlare](https://www.cloudflare.com/), I've [posted here](https://dev.to/rogeriotaques/vestacp-and-cloudflare-changing-the-default-port-of-the-admin-panel-5ej2) about how to change the VestaCP Admin Panel default port to work with CloudFlare, check it out.

For some reason, since I started using VestaCP, it looks like its team has not been able to release any major updates to the product, which gives me the impression that the product is not in active maintenance and, therefore, is degrading with the time! 🤔

Then, about 5 months ago, I (accidentally) found [HestiaCP](https://hestiacp.com/), another open-source Control Panel (CP) that seems to be an outstanding option to be considered! 

In fact, HestiaCP is a fork from VestaCP, improved in so many different ways that it looks a completely different solution, even though keeping the simplicity and intuitiveness. `Kudos to the HestiaCP Team`! 🍾

Also, it looks like HestiaCP maintainers community is much more active and supportive when it comes to helping users out.

So, I decided to give it a try and taking the opportunity that I would need to setup a new VPS for a new product I'm working on, I went with HestiaCP at this time and ... everything has been working greatly since then. No complaints at all! 🍾 🙌

And, because it's based on VestaCP, to make it working behind CloudFlare requires the exact same steps as written in my [previous article](https://dev.to/rogeriotaques/vestacp-and-cloudflare-changing-the-default-port-of-the-admin-panel-5ej2). The only difference is that you'll need to replace all `vesta` occurrences with `hestia`. 🤗

Have you ever used HestiaCP? 

Please, share your experience in the comments bellow 👇🙇‍♂️
在 Windows 平台使用 e 格式代碼時讓指數顯示 2 位
Tags: c, printf, format, io
Published: 2022-01-17 02:42:20

根據 [C99 的規格書](http://www.open-std.org/jtc1/sc22/WG14/www/docs/n1256.pdf#page=290), 使用格式化輸出入時格式代碼 e/E 的指數部分至少是 2 位數, 而且只有必要時才會增加位數, 也就是說, 預設就是 2 位數, 例如：

```C
#include <stdio.h>
#include <math.h>

int main(){
  printf("%010.4E\n", 1.13145);

  return 0;
}
```

結果如下：

```
1.1315E+00

```

但是在 Windows 平台上, 你會發現指數至少會有 3 位數, 同樣的程式執行結果會不同：

```
1.1315E+000

```

如果你的程式需要跨平台, 可以在格式化輸出前使用 [`_set_output_format`](https://docs.microsoft.com/en-us/cpp/c-runtime-library/set-output-format?view=msvc-170) 函式設定指數的位數, 例如：

```C
#include <stdio.h>
#include <math.h>

int main(){
  _set_output_format(_TWO_DIGIT_EXPONENT);
  printf("%010.4E\n", 1.13145);

  return 0;
}
```
其中參數 `_TWO_DIGIT_EXPONENT` 表示要和規格書一樣使用 2 位數, 如果傳入 0, 就恢復為 3 位數。
What makes Notion such a great startup?
Tags: webdev, productivity, design, startup
Published: 2022-01-17 01:33:51

There are two ways to invent something. One is to **make a new iteration of an existing product.** Like Google Docs: made a reiteration of a Microsoft Word.

And then there is **real invention:** when someone tries to go into the fundamentals, changing things from there and branching it to the current times.

**_[Notion](https://www.notion.so/) is one such invention._**

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

## Notion is an all-in-one workspace.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nwdz9rqo3lyy3yzkbqu0.jpg)

It's brings everything we would like in an online workspace together and empowered with the ability to mold it according to our needs.

## So, how does Notion make money?

Notion is an **enterprise software.** Their real customers are teams who buy the team software version. but who do they give it for free to most people?

Because universal adoption triumphs anything. 80% of the people use products for free. 20% pay for it. The free users contribute through the network effect.

**80% of the people make sure that the 20% can be monetized.**

These kinds of products want to become your **"standard" platforms.** they aim for widespread adoption to become industry standards.

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

**[Notion](https://www.notion.so/) is the standard workspace in almost every startup nowadays.
**
Notion was an **instant hit in the productivity community,** and people who like to jolt down quick thoughts.

Notion has a very **unique bragworthy proposition.** The people who use it, make their **own templates** and then can't stop talking about it everywhere.

Notion does 2 things right: **Community and influencer marketing.** People tend to **try the templates made by their favorite creators,** leading to the start of their habit formation. 

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

Design is **Everything to Notion.** It's like a pen, that when you use, **you should feel great.** It's a tool and **your experience** on that tool has to be very nice.

> _By [Daksh Joshi](https://dakshjoshi.com)_
Leetcode diary: 22. Generate Parentheses [DFS]
Tags: javascript, algorithms, devjournal, motivation
Published: 2022-01-17 01:31:49

This is a new series where I document my struggles of leetcode questions hoping seeing however small of an audience I get gives me the motivation to continue.  

[link](https://leetcode.com/problems/generate-parentheses/)  

This is definitely easy of medium question, could be marked easy honestly.

I am having major depression and confidence fell into abyss from trying to do a hard problem. Wanted to do a trilogy of it, since there are 3 of the similar premise problem. Alas I was only able to do the medium questions and come to nothing close to the solution for the hard level problem. Woe is me, fuck it I'll just do something that I know would be easy just from reading the title of the problem.

This is a simple "generate all" type of question. Whenever you see a problem like this the go-to strategy is DFS. The question asks to generate all valid parenthesis. If you aren't familiar with parenthesis questions, just know that the only restriction is that you always have to have at least 1 more left parenthesis than right before you add a right parenthesis. 

Therefore the thought process for this question is:
1.) use DFS somehow
2.) keep track of left and right parenthesis number via ints
3.) as you use DFS to generate the "tree", just check for left > right before calling recursion adding the right parenthesis
4.) another condition to stop adding left parenthesis once left === 0;
5.) the end condition is when both left and right === 0, at this point you add the parenthesis permutation to the answer array.

code: 

```
var generateParenthesis = function(n) {
    const answer = [];
    const left = n;
    const right = n;
    
    function recur (left, right, current) {
        if(left === 0 && right ===0) {
            answer.push(current.join(""));
            return;
        }
        
        if(left > 0) {
            recur(left-1, right, current.concat(["("]))
        }
        if(right > left) {
            recur(left, right-1, current.concat([")"]))
        }
    }
    
    recur(n,n,[])
    return answer;
};
```
slight optimization is to use strings to for the current variable instead of array then current.join; no major difference in the algorithm from the fastest solution.  

I don't know how much difference does it make, but at interviews it'll probably be a bonus when you mention that you recognize this as a tree-generating problem. 

Next time I'll be back with the trilogy after I fought off my crippling depression from trying to solve it ;( ... don't call the cops on me thanks :D ... 

Let me know anything on your mind after reading through this, THANKS!
Intro to Working With Web Components
Tags: javascript, webdev, beginners, programming
Published: 2022-01-17 01:13:16

If you have ever been on the internet or used a google, safari, or any kind of web browser, you have been exposed to JavaScript. I have been exposed to JavaScript for a long time and I am now finally learning how to start using it. I am excited to learn about what can be done in this area because it can lead to some incredible things being done and made. This post will be about how I started getting what I needed to create a web component.


## Installing an IDE

The first thing I did was install an IDE to write JavaScript code in. There are many good options out there for IDE's such as Eclipse and Netbeans, but I chose VSCode because I have worked with all 3 and found it to be the easiest for me. [Link for install](https://code.visualstudio.com/download)


## Installing NodeJS

Next, you will need to install NodeJS. Here is the [Link](https://nodejs.org/en/) to install. To check that NodeJS is installed properly as well as check what version you are using, just type in "node -v" into the command line.

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


## Installing npm

After installing NodeJS, it will automatically install npm with it. Npm stands for Node Package Manager and is used globally to allow programmers to use different packages, share code, and many other useful things. To check that it is installed and see what version you have, type "npm -v" into the command line.

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


## Creating an Open Web Components Project

Now that you have installed all of the required tools, create a folder where you will keep all of your files for the project. When you finish this, create a repository in Github then clone it into that folder you created earlier. To create the open-wc project, go to the command line and type in "npm init @open-wc", which should bring you to something that looks like this:

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

Once you get here, use the arrow and enter keys to select options that you are given. For this web component, I selected:

1. Scaffold a new project
2. Web Component
3. Select all 3 bubbles
4. No
5. Name of web component
6. Yes
7. Yes, with npm

When all of that is done, you will type "cd (name of project)" and "npm run start" then you should be redirected to a web page that looks like this

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

Finally! After all of that you are ready to start working with web components. If there is anything in there that was unclear, I recommend watching this [video](https://www.youtube.com/watch?v=r_mio0e6v1g) that helped me get through this.
How to sort stories alphabetically in Storybook (6.2)
Tags: storybook, react, javascript
Published: 2022-01-17 01:07:35

file:`.storybook/preview.js`

```js
export const parameters = {
  options: {
    storySort: (a, b) => {
      const aId = getStoryId(a[1]);
      const bId = getStoryId(b[1]);
      return aId === bId
        ? 0
        : aId.localeCompare(bId, undefined, { numeric: true });
    }
  },
};
```
Implement Cryptocurrency with Kotlin
Tags: kotlin, cryptocurrency, blockchain
Published: 2022-01-17 00:32:07

## Theory ##

Blockchain is made of a list of blocks where each block has its own hash, previous or parent block hash and an auxiliary data like timestamp and, for example, a list of transactions included in that block. Essentially one block captures system’s state at particular moment.


![Blockchain](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xsvsccl3vio2wgwp91bs.png)

## Hash utils ##
Blockhains use special types of hashes which are called cryptographic hashes. Bitcoin uses SHA-256 and we’re going to use the same. The actual implementation is done as Extension Function to the existing String class.

## Blocks ##
It’s easy to model blocks using Data Classes. They generate all java boilerplate and enforce immutability during compile time. mentioned before hash includes previousHash, data, which is empty in our case and the timestamp. Bitcoin has a very similar structure with some other extra fields, which we can ignore for now.

## Blockhain ##
So far we only created blocks, let’s add a container to store them — Blockchain.

## Mining ##
Right now there’s no limit on how many and how fast we can add blocks to Blockchain. In a centralized system the central authority controls that process, but since we’re dealing with a distributed system we can’t afford that.
As it turned out to be the problem isn’t new and your Inbox is dealing with it every day in the form of spam: a lot of spammers want to write (send) to you.

## Conclusion ##
Now, finish all the process we can understand a little about blockchaing and implement one cryptocurrency

[Viewed this code here](https://github.com/lucasnscr/Kotlin-Coin)
Dimensions of specialization
Tags: specialization
Published: 2022-06-09 13:03:15

---
title: Dimensions of specialization
published: true
date: 2022-01-17 00:00:00 UTC
tags: specialization
canonical_url: https://jhall.io/archive/2022/01/17/dimensions-of-specialization/
---

[Yesterday](https://jhall.io/archive/2022/01/16/should-you-call-yourself-fullstack/) I suggested that adopting the label of “fullstack” can limit your earning potential, and that specialization is usually a better approach. But how should you choose a specialty?

That’s naturally a really big topic, that I can’t address fully today, but I want to suggest a few dimensions to consider to get your mental gears turning. This is by no means a _complete_ list. Specialization can take many forms. And likely, as your career advances, you’ll want to niche down further and further, likely specializing across two or more of the following dimensions.

- **Tech stack.** You could become a specialist in a specific language (Python, Rust, Kotlin), framework (React, Spring Boot), platform (Salesforce, WordPress) or tool (Kubernetes, PostgreSQL)
- **Industry.** Some like to specialize on an industry, such as FinTech, retail eCommerce, Blockchain, or Peer-to-Peer applications.
- **Problem domain.** You may choose to specialize along a problem domain, such as secure shopping carts, offline-first mobile apps, or big data analysis.
- **Company size.** This one is often overlooked, but shouldn’t be. Some prefer to work for large companies, some small. Different sizes of companies often face different types of problems, so becoming familiar with one size of company in some cases can give you a leg up on the competition when looking for a new job.
- **Business model.** Different business models sometimes have special needs. Do you like to work for companies in retail sales? SaaS? Travel booking? B2B, B2C? Two-sided-market places? Social non-profits?
- **Customer demographics.** If you like working on products used by end users, do you care who your end users are? Do you want to build tools for creatives? For children? Investors? Students?

Have you chosen a specialization, even just as an experiment? I’d love to hear from you. What dimension(s) do you specialize on?

* * *
_If you enjoyed this message, [subscribe](https://jhall.io/daily) to <u>The Daily Commit</u> to get future messages to your inbox._
FastAPI error
Published: 2022-01-16 23:55:06

Hey there guys, I was following along with FreeCodeCamp's API for beginners and somewhere along the line I must have missed something.  I double checked my code against the instructor's but still can't seem to solve my issue.  When I test my API in Postman, I get the following error message.  Appreciate the help in advance!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3opxusw3xfudgfweat20.PNG)