teleren/devto huggingface dataset:
Trendiest Admin Template for React & Chakra UI!
Tags: webdev, react, showdev, javascript
Published: 2022-06-10 07:28:17

Save hundreds of hours trying to create and develop a dashboard from scratch. The fastest & responsive admin template is here. Seriously.

Get started and build your dream web app updated to the latest UI trends with Horizon UI PRO! Now available with discounts up to **-34% off**!
**(Limited time)** ⏳

Learn more: https://horizon-ui.com/pro

![Horizon UI PRO - Trendiest Admin Template for React](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b64zxngdr3dtslg0xm3e.png)
<br>
#### 400+ Components | 42+ Example Pages | Dark & Light Modes

Designed for those who like modern UI elements and beautiful websites. Made of hundred of elements, designed blocks and fully coded pages, Horizon UI PRO is ready to help you create stunning websites and webapps.

In this beautiful admin dashboard you will find many examples with pages like NFTs Pages, Authentication Pages, Profile and so on. Just choose between a Basic Design or a cover and you are good to go!

**See all pages live here:** https://horizon-ui.com/chakra-pro/
<br>

![News Feed - Horizon UI PRO - Trendiest Admin Template for React](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ibek4a9ifltgdacqoh10.png)
Horizon UI PRO is built with over 400+ frontend individual elements, like buttons, inputs, navbars, nav tabs, cards, or alerts, giving you the freedom of choosing and combining.
<br>

If you didn't already upgrade to Horizon PRO, now is your great chance! **Discounts up to -34% off! 🔥**

Grab your limited discount now: https://bit.ly/horizon-discount

See it live: https://horizon-ui.com/chakra-pro/
Hugo.io - Multiline cells in a table
Tags: hugo, markdown, formatting, blogging
Published: 2022-06-10 07:22:26

---
title: "Hugo.io - Multiline cells in a table"
published: true
description:  "With the right info, building a multiline cell in a table with Hugo becomes straightforward."
tags: ["hugo", "markdown", "formatting", "blogging"]
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

## A problem 
Building table in `markdown` is super easy and [well-documented](https://sourceforge.net/p/hugo-generator/wiki/markdown_syntax/#md_ex_tables).  
However, having a bit of formatting within it, like carriage return within a cell as below is not possible by default.   
![multiline-cell](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/914yisjzcxhivhqry9bn.png)
[Hugo](https://github.com/gohugoio/hugo/issues/6581) uses [Goldmark](https://github.com/yuin/goldmark/) (a [CommonMark](https://spec.commonmark.org/0.29/) implementation in `Go`) to process the markdown. Apparently it's extremely fast, with this implementation we choose to block any HTML processing d'HTML by default. 

## A solution
Once you know this, solving this is pretty straightforward.

You can customize plenty of Goldmark options in the configuration file (`config.toml/yaml/json`). 
So what we want to do is autorising Goldmark to render `HTML` content :  
```toml
[markup.goldmark]
    [markup.goldmark.renderer]
    unsafe = true 
```
From now, within the table, we just need to add `<br>` tag as below : 
```
|Adresse | Parking de La Poste<br> Le Bourg <br>97122 Baie-Mahault |
``` 

That's it ! 

## Free tips 
If you don't want to bother with `|` when building tables, someone very nice has built a [table generator](https://www.tablesgenerator.com/markdown_tables).  
We thank this person, from the bottom of our heart 💜.
New way to Use Strings in Java 17
Tags: java, java15, java17, coding
Published: 2022-06-10 07:11:52

Before Java 15, Writing SQL, HTML, JSON or any Polyglot scripts in String were difficult. It was ugly and difficult to read.
For example : 
Following HTML in Java :

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

OR 

Following SQL in Java : 

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

lot's of concatenation and escapes, It's difficult to read and write.

With "JEP 378: Text Blocks"  introduced in Java 15 ( Java 17 LTS), We can use two dimensional block of text.

for example, above code can be rewritten in following way: 

Following HTML in Java 17 : 


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

Following SQL in Java 17 : 


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


This way ,It's easy to read and write strings in Java.

More Details on :[JEP-378](https://openjdk.java.net/jeps/378)

Happy Codding !!
masonite orm 关于表需要新增字段的问题
Tags: masonite, python
Published: 2022-06-10 07:04:44


## 背景


比如我们之前有一个api_keys的表，现在需要新增一个字段exchange_id，不要再去修改已经执行过的迁移文件，应该在此基础上新增一个文件。


## 处理

```bash
python craft migration  update_api_keys_table --table api_keys
```


```python
"""UpdateApiKeysTable Migration."""

from masoniteorm.migrations import Migration


class UpdateApiKeysTable(Migration):
    def up(self):
        """
        Run the migrations.
        """
        with self.schema.table('api_keys') as table:
            table.integer('exchange_id').unsigned()

    def down(self):
        """
        Revert the migrations.
        """
        self.schema.drop("api_keys")
```


## 改动


我们表的字段定义忘了添加注释，还有部分字段需要指定默认值，也就是不是加字段而是要修改，处理方案如下

```bash
python craft migration  update_api_keys_table --table  api_keys 
```

写入内容

```python
"""UpdateApiKeysTable Migration."""

from masoniteorm.migrations import Migration


class UpdateApiKeysTable(Migration):
    def up(self):
        """
        Run the migrations.
        """
        with self.schema.table("api_keys") as table:
            table.string('api_key').comment("api key").change()
            table.string('api_secret').comment('api私钥').change()
            table.integer('exchange_id').unsigned().comment('交易所id').default(1).change()
            table.integer('uid').comment('用户id').change()

    def down(self):
        """
        Revert the migrations.
        """
        pass
```

执行迁移

```bash
python craft migrate
```


![修改效果](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77mlvh04fp4cht4c5wdb.png)

最后关于migrate这块

1. 定义的时候尽量思考全面
2. 生成了迁移文件，就尽量不要移除
3. 后续有改动继续定义新的迁移文件修改，不要删除后重来
The types of feasibility study
Tags: management
Published: 2022-06-10 07:03:47

A feasibility study evaluates the feasibility of a project and, therefore, the perception of objectivity is a key aspect of its credibility research for prospective investors and lending institutions.If you've earned [PMP certification training](https://www.edureka.co/pmp-certification-exam-training), being underemployed isn't an issue. However, it's more likely you'll earn more for the work you're doing. There are five kinds of feasibility studies, which are distinct areas that feasibility studies study as listed below. 

**Technical Possibilities**

This evaluation focuses on technical tools available to the business. It assists organizations in determining whether the technical resources have the capacity and if the technical team can translate ideas into functional systems. Technical feasibility also includes an evaluation of the hardware, software and other technical requirements for the system being proposed. In a way one, a company wouldn't intend to build Star Trek's transporters inside their facility. At present, this plan is not feasible on a technical level.

**Economic feasibility**

The majority of assessments involve an analysis of costs and benefits of the project. It helps companies determine the feasibility, cost and advantages of the project prior to financial resources are allotted. It also functions in the capacity of an objective assessment of the project and helps decision makers determine the positive economic impact to the business that the proposed project can offer.

**Legal feasibility**

This evaluation focuses on whether the project proposed is in conflict with the legal requirements of regulations regarding zoning as well as data protection legislation or social media law. Let's say that a company wants to build an office building at the exact location. A feasibility study could reveal that the ideal location for the business isn't zoned to accommodate that kind of business. The company has reduced time and energy because they discovered that their idea wasn't feasible in the very beginning.

**Operational feasibility**

This type of assessment requires an analysis to assess whether and how the organization's requirements can be met through finishing the project. Operational feasibility studies will also analyze how a plan of action meets the requirements that are identified during the analysis phase of the system's development.
Scheduling Possibilities
This is the one that is most crucial factor in the success of a project as projects will fail If it's not completed on time. To determine feasibility of scheduling the organization determines how long it will require to finish.

**Once these areas have been considered The feasibility analysis can help to identify any limitations that the project could be confronted with, such as:**

1. Internals Project Constraints: Technical, Technology, Budget, Resource, etc.
2. Internals Corporate Limits: Marketing, Financial Export, Finance, etc.
3. External Constrained Environmental, Logistics and Laws and Regulations, etc.
Apply Discount to Prices
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 07:00:51

A **sentence** is a string of single-space separated words where each word can contain digits, lowercase letters, and the dollar sign `'$'`. A word represents a **price** if it is a sequence of digits preceded by a dollar sign.

*   For example, `"$100"`, `"$23"`, and `"$6"` represent prices while `"100"`, `"$"`, and `"$1e5"` do not.

You are given a string `sentence` representing a sentence and an integer `discount`. For each word representing a price, apply a discount of `discount%` on the price and **update** the word in the sentence. All updated prices should be represented with **exactly two** decimal places.

Return _a string representing the modified sentence_.

Note that all prices will contain **at most** `10` digits.

**Example 1:**

**Input:** sentence = "there are $1 $2 and 5$ candies in the shop", discount = 50
**Output:** "there are $0.50 $1.00 and 5$ candies in the shop"
**Explanation:** 
The words which represent prices are "$1" and "$2". 
- A 50% discount on "$1" yields "$0.50", so "$1" is replaced by "$0.50".
- A 50% discount on "$2" yields "$1". Since we need to have exactly 2 decimal places after a price, we replace "$2" with "$1.00".

**Example 2:**

**Input:** sentence = "1 2 $3 4 $5 $6 7 8$ $9 $10$", discount = 100
**Output:** "1 2 $0.00 4 $0.00 $0.00 7 8$ $0.00 $10$"
**Explanation:** 
Applying a 100% discount on any price will result in 0.
The words representing prices are "$3", "$5", "$6", and "$9".
Each of them is replaced by "$0.00".

**Constraints:**

*   `1 <= sentence.length <= 105`
*   `sentence` consists of lowercase English letters, digits, `' '`, and `'$'`.
*   `sentence` does not have leading or trailing spaces.
*   All words in `sentence` are separated by a single space.
*   All prices will be **positive** integers without leading zeros.
*   All prices will have **at most** `10` digits.
*   `0 <= discount <= 100`

**SOLUTION:**

    class Solution:
        def discountPrices(self, sentence: str, discount: int) -> str:
            words = sentence.split()
            n = len(words)
            for i in range(n):
                if words[i][0] == '$' and words[i][1:].isnumeric():
                    val = words[i][1:]
                    newprice = eval(f"{val} * (1 - {discount} / 100)")
                    newprice = "{:.2f}".format(newprice)
                    words[i] = f"${newprice}"
            return " ".join(words)
WooCommerce Custom Product Addons
Tags: webdesign, woocommerce, webdev, ecommerce
Published: 2022-06-10 06:31:57

You can show various product options on product pages with [WooCommerce extra product options](https://codecanyon.net/item/woocommerce-product-addons-custom-product-options-plugin/20810733). Store owners can charge an additional price for product options, which increases their profits. It is useful if you have a series of products with varying attributes. This way you can display all product options on one page rather than creating separate pages. In the back office, it enables the 9 types of fields through which you can create various product options. The customer will be charged according to the options they choose. With this plugin, you can create product options like a black, blue, or green bottle, a car with different models or years, laptops with different specifications, etc. 

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/chojdhykd7p9x62btrrw.png)
Share an open source project of mine called openapi, about API security interaction.
Tags: apisecurityinteraction, javaopenapisdk
Published: 2022-06-10 06:58:54

    Recently I wrote an open source java project about API security opening and calling. It mainly solves the problems of data encryption and decryption and signature verification in API interaction. The goal of the project is to provide an sdk that can quickly build an open API. Looking for someone to join in.
    project url: https://github.com/hdwang123/openapi
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l6gwys3wfrpo78uadxqx.png)
Project Planner for businesses
Published: 2022-06-10 06:58:18

Project planner helps you to organize your work and save time for different projects. Scalable project planning for any type of day-to-day work. It needs just one minute to start using. Try [project planner](https://projectplanner.ai/) now and see how it works for you! You can keep your tasks in the cloud, sync them with all devices, share them in groups or create projects just like you want with custom fields and subprojects.
WooCommerce Product Bundles Plugin
Tags: webdesign, webdev, woocommerce, ecommerce
Published: 2022-06-10 06:47:58

boost your store sales by creating bundles of products for your store with  [WooCommerce product bundles](https://codecanyon.net/item/woocommerce-product-bundles-plugin-with-bulk-discounts/22668687). This plugin enables you to create bundles of products so customers can buy multiple products at once. The bundles can include digital products, simple products, and variable products. The pricing can either be a fixed price or a product-based price. You can set a limit for each product quantity to sell in a  bundle. Customers can opt to purchase bundle products. You can offer a fixed price or a percentage discount for a bundle. This makes it easy to keep track of simple and variable products.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qjyts8wx81qub6fz0nd0.png)
One liner - remove html tags from a string
Tags: javascript, html, webdev, programming
Published: 2022-06-10 06:43:13

```
var plainText = content.replace(/<[^>]*>/g, '');
```


Refer: https://stackoverflow.com/questions/51195143/is-there-a-way-to-remove-html-tags-from-a-string-in-javascript/51195294#51195294
Self improvement
Tags: selfimpovement, career
Published: 2022-06-10 06:37:15

Before my first interview I thought🤔:
I know that I have enough knowledges for that position, I ready to go and begin an employment". But I have understood that this was a big mistake and my knowledges were very small. That interview was great for me, great, because I understood how many things there were that I don’t know and it gave me clear imagine where I should start.
IT field grows very fast and we have to learn every time to achieve our best achievements.
The interview is not only about to get new job, it’s about to understand what you know and what you should to learn, too.

Good luck all in your career✌️
masonite 模型-表-控制器 api编写流程
Tags: masonite, python
Published: 2022-06-10 06:34:18



假设我们需要管理用户的api key ,api secret。


## 生成model

```bash
python craft model ApiKey
```

在app/models，将会得到一个模型

```python
""" ApiKey Model """

from masoniteorm.models import Model


class ApiKey(Model):
    """ApiKey Model"""

    pass
```

我们填充一点需要的内容。



```python
""" ApiKey Model """

from masoniteorm.models import Model
from masoniteorm.relationships import belongs_to


class ApiKey(Model):
    """ApiKey Model"""

    __table__ = 'api_keys'

    __fillable__ = ['id', 'api_key', 'api_secret', 'uid']

    # 它属于某个用户的，这里要定义一个反向关联的模型

    @belongs_to('uid', 'id')  # 第一个字段是api_keys的存储的值，第二个id代表了users表里面的id
    def user(self):
        from app.models.User import User
        return User
```



## 生成迁移文件

```bash
python craft migration create_api_keys_table --create api_keys
```

![迁移文件](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/d1fkbtlqb33yigq5u1jx.png)
 

我们填充下字段的描述


```python
"""CreateApiKeysTable Migration."""

from masoniteorm.migrations import Migration


class CreateApiKeysTable(Migration):
    def up(self):
        """
        Run the migrations.
        """
        with self.schema.create("api_keys") as table:
            table.increments("id")
            table.string("api_key").unique()
            table.string("api_secret").unique()
            table.integer("uid").unsigned()
            table.timestamps()

    def down(self):
        """
        Revert the migrations.
        """
        self.schema.drop("api_keys")
```

**执行迁移**

```bash
python craft migrate
```


## 创建一个控制器


接下来创建一个API Controller，测试我们的逻辑


```bash
python craft controller api/ApiKeyController -a
```


接下来注册路由


routes/api.py

```python
from masonite.routes import Route

ROUTES = [
  ...
    Route.api('apikeys', 'api.ApiKeyController')
]
```


控制器代码改写

```python
from masonite.authentication import Auth
from masonite.controllers import Controller
from masonite.request import Request
from masonite.views import View

from app.models.ApiKey import ApiKey


class ApiKeyController(Controller):
    def index(self, view: View):
        return view.render("")

    def show(self, view: View):
        return view.render("")

    def store(self, request: Request, auth: Auth):
        api_key = request.input("api_key")
        api_secret = request.input("api_secret")
        obj = ApiKey()
        obj.api_key = api_key
        obj.api_secret = api_secret
        obj.uid = auth.user().id
        obj.save()
        return {"code": 0, "message": "success"}

    def update(self, view: View):
        return view.render("")

    def destroy(self, view: View):
        return view.render("")
```


## 测试

![测试提交](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/riynvoh0p0dnkem59eqe.png)
 


数据库检查确认


![数据库查看](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/anxlk1mobd3zi9lv54fr.png)
 

确认无误，没问题，基本的逻辑就全走通了，剩下的根据需要添砖即可。
Remove Covered Intervals
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 06:30:47

Given an array `intervals` where `intervals[i] = [li, ri]` represent the interval `[li, ri)`, remove all intervals that are covered by another interval in the list.

The interval `[a, b)` is covered by the interval `[c, d)` if and only if `c <= a` and `b <= d`.

Return _the number of remaining intervals_.

**Example 1:**

**Input:** intervals = \[\[1,4\],\[3,6\],\[2,8\]\]
**Output:** 2
**Explanation:** Interval \[3,6\] is covered by \[2,8\], therefore it is removed.

**Example 2:**

**Input:** intervals = \[\[1,4\],\[2,3\]\]
**Output:** 1

**Constraints:**

*   `1 <= intervals.length <= 1000`
*   `intervals[i].length == 2`
*   `0 <= li < ri <= 105`
*   All the given intervals are **unique**.

**SOLUTION:**

    import bisect
    
    class Solution:
        def removeCoveredIntervals(self, intervals: List[List[int]]) -> int:
            intervals.sort(key = lambda p: (p[0], p[0] - p[1]))
            n = len(intervals)
            i = 0
            while i < len(intervals):
                a, b = intervals[i]
                j = i + 1
                while j < len(intervals) and intervals[j][0] <= b:
                    c, d = intervals[j]
                    if d <= b:
                        intervals.pop(j)
                    else:
                        j += 1
                i += 1
            return len(intervals)
WooCommerce Register Form Plugin
Tags: webdesign, woocommerce, webdev, ecommerce
Published: 2022-06-10 06:25:20

Your customers can provide you with more information when they register on your website, with the [WooCommerce register form](https://codecanyon.net/item/woocommerce-registration-plugin-add-custom-registration-fields/20515456). From the backend, you can add 14 types of fields to your registration form. You can simply drag and drop these fields to your registration form. The default fields can also be disabled and enabled from the backend. Furthermore, you can edit the labels of fields so they are more readable and you can choose whether or not they are required. Furthermore, it provides social login options such as Facebook and Twitter, so your customers can sign up with a single click. You can enable Google ReCaptcha on your registration page which  prevents spam on your site.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a8j7wdvuwpt5t2rbcz87.png)
WooCommerce Price Calculator Plugin
Tags: webdesign, woocommerce, webdev, ecommerce
Published: 2022-06-10 06:12:14

Calculate the price of variable-sized items using [WooCommerce price calculator](https://codecanyon.net/item/woocommerce-measurement-price-calculator-plugin/20515113). By evaluating the price per unit, the plugin automatically calculates prices. The customer is not forced to buy products in fixed sizes, so he can pick products that fit his needs. Customers can enter their measurements for a price estimate based on their measurements. Depending on the measurement range, each product can have a unit price and a discounted price. Many online stores can use this plugin to sell flour, rice, sugar, fertilizer, wallpaper, blinds, and floors. Stocks and variations can be managed easily.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zgu740soue3m1mfzyd5g.png)
Easy to Debug NullPointerException with Java 17
Tags: java, npe, nullpointer, java17
Published: 2022-06-10 06:07:40


As Java Developer, We have faced NullPointerException  throughout
our Java Development career. Sometime ,it is difficult to find such exception at Compile time since its not a checked exception. for example, look at runtime error message in below code.


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

Exception Message : 
`Exception in thread "main" java.lang.NullPointerException
	at MyClass.main(MyClass.java:5)`

 Error message is not clearly informing which variable has an issue. 
We need more information on variable causing this exception and that's where  JEP-358   [](https://openjdk.java.net/jeps/358)  comes for rescue.

If We run same code with Java 17 , It provides more information on  which variable is causing NullPointerException.

Exception Message : 
`Exception in thread "main" java.lang.NullPointerException: Cannot invoke "String.equals(Object)" because "<local2>" is null
	at MyClass.main(MyClass.java:5)`


**NOTE: 
This change was introduced in Java 14 but JAVA 14 doesn't have LTS  ( long term support)**



Happy Coding !!!!