teleren/devto huggingface dataset:
🎉Vue3+Vite2.6+TypeScript+ant-design-vue+egg.js
Published: 2022-08-12 04:49:21


>Bag快速开发管理系统、门户网站、博客系统框架，提供基础的框架，快速搭建企业产品，响应式开发，你可以将它应用在任何需要服务端管理的应用。如：开发管理系统的 API 接口、门户网站博客、企业内部的业务管理、ERP、CMS、APP 的后台等

### 技术选型

>Bag管理系统采用Vue3、Vue-Router4、Vuex4、Ant-Design-Vue、Vite、TypeScript、Egg.js、Mysql构建

>Bag门户博客前台采用Vue3、Vue-Router4、Vite 、Pinia、Element-plus、Equal-Vue、Bootstrap、Vite、TypeScript、Egg.js、Mysql构建，按需加载模块，内置丰富UI

### 一键安装
>快速开发，内置集成后台系统、也阔以自定义后台API
```bach
npm i vue-bag-admin --save 
```

### 应用
```js
import {createApp} from 'vue'
import install from 'vue-bag-admin'
import 'vue-bag-admin/lib/style.min.css'
import App from './App.vue'
import 'vue-bag-admin/mock/admin' // 如果后台服务,不用此mock数据

createApp(App).use(install)
```

### 开发

```js
npm run dev
```

### 开源地址
[文档地址](https://vite.itnavs.com/doc/index.html)，[Github源码](https://github.com/hangjob/vue-bag-admin)


### 演示地址

[管理系统演示](https://vite.itnavs.com/admin.html)、[门户博客前台演示](https://vite.itnavs.com/web.html)

### 主要功能

1. 用户管理：系统管理员分配用户角色和角色权限
2. 角色管理：创建权限控制的主要对象，可以给角色分配不同api权限和菜单权限
3. 菜单管理：实现用户动态菜单配置，实现不同角色不同菜单
4. 富文本编辑器：MarkDown编辑器功能嵌入
5. 快速表单：一键开发CURD，配置化条件搜索示例
6. 快速API：基于Egg开发，增删改查API基本样列
7. 接口设计：模型创建，关联查询，一键接入
8. 权限指令：组件权限指令封装
9. 网络配置：基础axios封装，请求重连、错误取消，动态配置
10. 状态管理：丰富的Vuxe和Pinia任意选择
11. 路由配置：嵌套路由，动态路由可动态配置，快速呈现
12. 全局配置：站点基本配置背景图片、Login、Slogan等等
13. ....


## 预览
#### 后台

![2702235941-62f4f96172d14_fix732.png](https://p3-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/26aec783b72e4b0f992f226ffaaba127~tplv-k3u1fbpfcp-watermark.image?)
#### 前台

![2027974419-62f4f9861a4de_fix732.png](https://p6-juejin.byteimg.com/tos-cn-i-k3u1fbpfcp/212c0eb675c24887ab4dd3512a3a9e6a~tplv-k3u1fbpfcp-watermark.image?)
Two Pointers Templates in Python
Tags: algorithms, python
Published: 2022-08-12 04:46:00

## What is two pointers technique?
Two pointer technique is using two pointers in an array to solve problems efficiently.

## Templates
3 common two pointers techniques are:
- Sliding window
- Pointers from two ends
- Fast and slow pointers

### Sliding Window
Sliding window can be used to search something in a subarray.

```python
def get_counter():
    pass

def condition():
    pass

def do_something_before():
    pass

def do_something_after():
    pass

def sliding_window(arr):
    counter = get_counter()
    # outer loop to move end index
    while end < len(arr):
        end += 1
        # start index only increase when condition
        while condition():
            do_something_before()
            start += 1
    do_something_after()
```

### Pointers from two ends
Pointers from two ends can be used when the problem can be reduced to finding two elements in an array that satisfy a condition.

```python
def condition_left():
    pass

def condition_right():
    pass

def do_something():
    pass

def pointers_from_two_ends(arr):
    left, right = 0, len(arr)-1
    while left < right:
        if condition_left():
            left += 1
        if condition_right():
            right -= 1
        do_something()

```

## Fast and slow pointers
Fast and slow pointers can be used to:
- detect cycles
- remove duplicates
- find middle node

```python
def condition_slow():
    pass

def do_something():
    pass

def fast_slow_pointers(arr):
    slow = 0
    for fast in range(len(arr)):
        # only move slow pointer when condition
        if condition_slow():
            slow += 1
        do_something()
```
DFS Templates in Python
Tags: algorithms, python
Published: 2022-08-12 04:10:00

## What is DFS?
Depth-first Search (DFS) is a tree/graph traversal algorithm that explores as far as possible in each branch.
![Example of a tree](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eie5ru67waobbezfnbmx.png)
DFS traversal of the tree above would be:
`[0, 1, 3, 4, 2, 5 ,6]`

## DFS applications
Some of the applications of DFS are:
- traversing a explicit tree to find something
- traversing a graph to:
    - find topological sort of graphs
    - cycle detection in graphs
    - find spanning trees
- use backtracking to:
    - solve puzzles
    - solve combinatorial problems

## Templates
We can simply traverse through the tree/graph using the following templates.

### DFS on binary tree
```python
def do_something(root):
        pass

def dfs(root):
    if not root:
        return
    do_something(root)
    dfs(root.left)
    dfs(root.right)
```

### DFS on N-ary tree

```python
def do_something(root):
    pass

def get_children(root):
     pass

def dfs(root):
    if not root:
        return
    do_something(root)
    for child in get_children(root):
        dfs(child)
```

### DFS on graphs
```python
visited = set()
def do_something(root):
    pass

def get_neighbors(root):
    pass

def dfs(root, visited):
    if root in visited:
        return
    do_something(root)
    visited.add(neighbor)
    for neighbor in get_neighbors(root):            
        dfs(neighbor, visited)
```

In addition to simple traversals, we can also pass value up from child to parent (using return value) or pass value down from parent to child (using function parameters).

### Example of passing value up (return value)
Finding max depth of N-ary tree

```python
def get_children(root):
    pass

def max_depth(root):
    if not root:
        return 0
    depth = 0
    for child in get_children(root):
        depth = max(depth, max_depth(child))
    return depth + 1
```

### Example of passing value down (function parameter)
Print path on a binary tree

```python
def dfs_path(root, res):
    if not root:
        return
    res.append(root)
    dfs_path(root.left, res)
    dfs_path(root.right, res)
```

Backtracking is also a variation of DFS. Backtracking does not explore the whole tree/graph. Instead, backtracking stops exploring branches that cannot lead to a solution.

Backtracking can often be used to solve puzzles or combinatorial problems.

### Backtracking template

```python
def condition():
    pass

def do_something(root):
    pass

def get_children(root):
     pass

def backtrack(root):
    if not condition():
        return
    do_something(root)
    for child in get_children(root):
        backtrack(child)
```
Format USB FAT32 in Ubuntu
Tags: ubuntu
Published: 2022-08-12 03:57:05

## Step 1: Locate USB Drive
Open the terminal and run the following command: `df`
![](https://i.imgur.com/BTxp8Sp.png)
## Step 2: Unmount and Format USB Drive
Unmount the USB drives before formatting. To do so, run this command:
```
sudo umount /dev/sdb1
```
![](https://i.imgur.com/biePMPM.png)
After unmounting, format the USB drive using the preferred file system (replace **sdb1** with the name of your device):
+ To format a USB drive with FAT32 file system, use:
  ```
  sudo mkfs.vfat /dev/sdb1
  ```
## Step 3: Verify USB Drive Formatting
Confirm the formatting process has completed successfully:
```
sudo fsck /dev/sdb1
```
![](https://i.imgur.com/Pb4xYQg.png)
Eslint and Prettier
Published: 2022-08-11 20:06:38

**Install dependencies**

`yarn add -D eslint prettier eslint-plugin-prettier eslint-config-prettier`
`yarn add -D eslint-plugin-node eslint-config-node
`
**Initialize eslint**

`eslint --init`

```
=> Select this options for react
- To check syntax, find problems, and enforce code style
- JavaScript modules (import/export)
- React
- Does your project use TypeScript? » No
- Browser
- Use a popular style guide
- Airbnb: https://github.com/airbnb/javascript
- JSON
- Would you like to install them now? » Yes
- yarn
```


**Add configuration in .eslintrc**

```json
{
  "env": {
    "browser": true,
    "es2021": true,
    "node": true,
    "es6": true,
    "jest": true
  },

  "extends": [
    "airbnb",
    "airbnb/hooks",
    "eslint:recommended",
    "prettier",
    "plugin:jsx-a11y/recommended",
    "plugin:react/recommended",
    "airbnb",
    "prettier"
  ],
  "parserOptions": {
    "ecmaFeatures": {
      "jsx": true
    },
    "ecmaVersion": "latest",
    "sourceType": "module"
  },
  "plugins": ["react", "prettier", "react-hooks"],

  "rules": {
    "react/react-in-jsx-scope": 0,
    "react-hooks/rules-of-hooks": "error",
    "react/button-has-type": 0,
    "consistent-return": 1,
    "no-unused-vars": 1,
    "import/prefer-default-export": 0,
    "no-param-reassign": 0,
    "no-console": 0,
    "react/state-in-constructor": 0,
    "indent": 0,
    "linebreak-style": 0,
    "react/prop-types": 0,
    "jsx-a11y/click-events-have-key-events": 0,
    "react/jsx-filename-extension": [
      1,
      {
        "extensions": [".js", ".jsx"]
      }
    ],
    "prettier/prettier": [
      "error",
      {
        "trailingComma": "es5",
        "singleQuote": true,
        "printWidth": 100,
        "tabWidth": 4,
        "semi": true,
        "endOfLine": "auto"
      }
    ]
  }
}

```
**Workspace settings.json**

```json
{
  // Theme
  "workbench.colorTheme": "Default Dark+",

  // config related to code formatting
  "editor.defaultFormatter": "esbenp.prettier-vscode",
  "editor.formatOnSave": true,
  "[javascript]": {
    "editor.formatOnSave": false,
    "editor.defaultFormatter": null
  },
  "[javascriptreact]": {
    "editor.formatOnSave": false,
    "editor.defaultFormatter": null
  },
  "javascript.validate.enable": false,
  "editor.codeActionsOnSave": {
    "source.fixAll.eslint": true,
    "source.fixAll.tslint": true,
    "source.organizeImports": true
  },
  "eslint.alwaysShowStatus": true,
  // emmet
  "emmet.triggerExpansionOnTab": true,
  "emmet.includeLanguages": {
    "javascript": "javascriptreact"
  }
}

```
Tips for Getting Your First Developer Job
Tags: javascript, webdev, programming, job
Published: 2022-08-12 03:47:00

*Image by <a href="https://pixabay.com/users/geralt-9301/?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2496189">Gerd Altmann</a> from <a href="https://pixabay.com//?utm_source=link-attribution&amp;utm_medium=referral&amp;utm_campaign=image&amp;utm_content=2496189">Pixabay</a>*


I am sharing 5 Specific [Tips for Getting Your First Developer Job by James Quick.](https://www.youtube.com/watch?v=_WWlmFnPWlQ)

1. **Engage in community** - being part of a community is impactful. Twitter as an example is where you can connect with other devs. I am currently connected to a Facebook community with self-taught programmers and slack channel with Clever Programmer students. Build your network. Build your career. 

2. **Create *BOMB* portfolio projects** - stand out not only through your resume but by creating BOMB projects (it proves your passion and demonstrates your ability to create one project from start to finish). Resume is just bunch of words, your portfolio project is the proof. 

3. **Reach out to people** - ask advice from tenure or senior devs. It never hurts to ask. Ask advice from people with specific job that you wanted to get.  Start making connects and learn the job,  companies and roles you wanted to work in.

4. **Create content** - The best way to learn is to teach! Be visible! 

5. **Practice confidence** - Talk about yourself confidently! Feel really good of what you are and what you have accomplished. Pay attention to how you talk about yourself, what you build, and what you do.

I learned a lot here. Hope you'll do too!

To God be the glory!
Getting Started with the ASP.NET Core AutoComplete Control
Tags: webdev, dotnet, csharp
Published: 2022-08-12 03:35:01

Learn how to create and configure the ASP.NET Core AutoComplete control in an ASP.NET Core project. In this video, you will learn how to add a Syncfusion ASP.NET Core AutoComplete control to an ASP.NET Core application. You will see how to populate local data and remote data sources, set a custom height and width to the AutoComplete suggestion list, and sort the items. 

Product overview: https://www.syncfusion.com/aspnet-core-ui-controls/autocomplete

Download example from GitHub: https://github.com/SyncfusionExamples/getting-started-with-the-aspnetcore-autocomplete-control

{% youtube d9HspfUuL_4 %}
Dev Journal - Day 4 - Odin Project - JS Fundamentals 4 - Loops Part 1
Tags: beginners, odinproject, codenewbie
Published: 2022-08-12 03:26:00

Learned about Loops today

**Loops**
- are useful for repeating the same code multiple times.
- will often have slightly different code each time the loop runs, or the same code will run but with different variables.

**Loops break Statement**
- has similar utility to the break statement used in switch() conditionals
- is used to exit a loop before all iterations are complete and make the browser move on to any code that follows it.

**Loops continue Statement**
- is used to break or skip an iteration, if a specified condition occurs, and make the browser continuew ith the next iteration in the loop.

**map() vs filter()**
- map()in loops is used to modify items in a collection and create new collection containing the modified items
-filter() modifies items in a collection and creates a new collection containing only the items that match

**Tomorrow's Learning Plan**
- for loops
- while and do loops
- MDN Active Learning Tasks in Loops

**References**
1. [The Odin Project](https://www.theodinproject.com/lessons/foundations-fundamentals-part-4)
2. [W3 Schools] (https://www.w3schools.com/js/js_break.asp)
Redesign
Published: 2022-08-12 01:21:00

Welcome to [the new site!](https://www.lowsound.dev) I redesigned everything and even got a new domain name. The previous version was a Next.js site, and though I was happy with it, I wanted to experiment with something else. This site is pretty basic; no frameworks, minimal external libraries (just stuff that I need for the build process). It's good ol' HTML and CSS. However I did opt for Typescript instead of just going vanilla.

I kind of like this a lot better to be honest. It's more under my control. I don't have to think about SSR and all that because, well...static website.

Actually I just realized that I did use a pretty major library. There's an express server running on Heroku as well, and I also used nodemailer in there to power the contact form. Just like the old Next.js version of this site. Sorry, I exaggerated a little at the beginning.

Anyway, I'll try to actually use the blog this time. In fact, I promise to myself that I will. The old posts from the old website are still up here. They will soon be joined by more thoughts, ideas, and projects.

EDIT (Nov 13, 2022): there's no more contact page and so no more nodemailer. Heroku isn't going to be free anymore and I feel like I learned what I needed to at the time. Email is the way forward :)

o.khandxb@gmail.com
Codility Test Question
Published: 2022-08-12 00:34:00

Hi guys, i've been struggling to get to complete this codility question. 
**A binary gap within a positive integer N is any maximal sequence of consecutive zeros that is surrounded by ones at both ends in the binary representation of N.

For example, number 9 has binary representation 1001 and contains a binary gap of length 2. The number 529 has binary representation 1000010001 and contains two binary gaps: one of length 4 and one of length 3. The number 20 has binary representation 10100 and contains one binary gap of length 1. The number 15 has binary representation 1111 and has no binary gaps. The number 32 has binary representation 100000 and has no binary gaps.

Write a function:

function solution(N);

that, given a positive integer N, returns the length of its longest binary gap. The function should return 0 if N doesn't contain a binary gap.

For example, given N = 1041 the function should return 5, because N has binary representation 10000010001 and so its longest binary gap is of length 5. Given N = 32 the function should return 0, because N has binary representation '100000' and thus no binary gaps.

Write an efficient algorithm for the following assumptions:

N is an integer within the range [1..2,147,483,647].**

After series of failing, i finally came up with a solution. wont lie, it was frustrating at first, even the sample code i got online didn't work. 

well i finally found a way to solve the test. 

Below you'll find my code. 




```
function solution(N) {
  // write your code in JavaScript (Node.js 8.9.4)
  let base = N.toString(2);
  let result = 0; //initialize to 0
  let t = 0;
  let array = [];

  for (let n in base) {
    let b = base[n]; 
    if (b == 1) {
      if (t >= 0) {
        array.push(result);
        result = 0;
        t = 0;
      } else {
        t += 1;
      }
    } else {
      result = result + 1;
    }
  }

  return array.reduce((a, b) => Math.max(a, b), -Infinity);
}

```

If you're a software developer, i'll highly recommend you sign up on codility and have yourself some code challenges. You  might never know logical you are in solving problems until you try most of this test.
Iniciante testes em Golang
Tags: go, testing, beginners
Published: 2022-08-12 00:17:45

Primeiro vamos começar com um simples problema de devisão.

Nosso **main.go**: 

```
import (
	"errors"
	"fmt"
	"log"
)

func main() {

	result, err := divide(100.0, 10.0)
	if err != nil {
		log.Println(err)
		return
	}
	fmt.Println("Result: ", result)
}

func divide(x, y float32) (float32, error) {

	var result float32

	if y == 0 {
		return result, errors.New("divisor cannot be zero")
	}
	result = x / y
	return result, nil
}
```

**divide()** é a função que vamos testar. 
Primeiramente, vamos criar um arquivo chamado main **_test** .go, teste em Go devem seguir este padrão de nome, finalizando sempre com o _test.go, assim, ao executarmos o teste, o compilador saberá que deve rodar os testes do projeto.


Arquivo **main_test.go **
```
var tests = []struct {
	name     string
	dividend float32
	divisor  float32
	expected float32
	isErr    bool
}{
	{"valid-data", 100.0, 10.0, 10.0, false},
	{"invalid-data", 100.0, 0.0, 0.0, true},
	{"expect-5", 50.0, 10.0, 5.0, false},
}
```
Toda função de teste deve receber o ponteiro ***testing.T** 
```
func TestDivision(t *testing.T) {
	for _, testCase := range tests {
		got, err := divide(testCase.dividend, testCase.divisor)
		
		if testCase.isErr {
			if err == nil {
				t.Error("expected an error but did not get one")
			}
		} else {
			if err != nil {
				t.Error("did not expected an error but got one", err.Error())
			}
		}

		if got != testCase.expected {
			t.Errorf("the result we got %f is different than the expected %f result", got, testCase.expected)
		}

	}
}
```
Esta parte do nosso código é onde estamos definindo os dados que rodaremos no nosso loop, logo abaixo. 

Essa é uma alternativa, ao invés de ter **uma função separada para cada teste**, podemos criar um slice de struct com todos os casos de testes que queremos.
```
var tests = []struct {
	name     string
	dividend float32
	divisor  float32
	expected float32
	isErr    bool
}{
// casos de teste 
	{"valid-data", 100.0, 10.0, 10.0, false},
	{"invalid-data", 100.0, 0.0, 0.0, true},
	{"expect-5", 50.0, 10.0, 5.0, false},
}
```

Para executar os testes, basta executar o comando: 

```
go test
```
 
Neste primeiro momento, estou utilizando a biblioteca padrão do go para testar. Minha ideia neste repositório https://github.com/bbwithpointers/golang-tests-study é testar alguns frameworks de testes, além da lib padrão e fazer pequenas documentações de uso por aqui. Qualquer sugestão é bem vinda. =)
Change file/directory permissions in Nodejs
Tags: node, nodejstip, javascript
Published: 2022-08-12 00:15:48

𝗡𝗼𝗱𝗲𝗷𝘀 let's you set permissions on files/directories just like you do on your Unix systems.

I'm sure a lot of you have come across the 𝗰𝗵𝗺𝗼𝗱 utility in your OS of choice. Probably also executed something like this:

𝗰𝗵𝗺𝗼𝗱 𝟳𝟳𝟳

Which gives full access to everyone(can be evil). The number you see defines the read, write and execute access to owner, group and others(public).

Same thing can be achieved using the 𝗳𝘀𝗣𝗿𝗼𝗺𝗶𝘀𝗲𝘀.𝗰𝗵𝗺𝗼𝗱 method.

𝗡𝗼𝗱𝗲𝗷𝘀 also provides another version of this method made just for symbolic links; which are aliases to files.

Websites like https://lnkd.in/d7tCvnAw can help you calculate the permission number you need.

Hope this post inspires others to talk about 𝗰𝗵𝗺𝗼𝗱 in more depth at the OS level.

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

Did you learn something new today?

Like and share this post, and follow me for more!

![chmod in node](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nn0y7688m0uy97023wkv.png)
First AlmaLinux Community Election Coming Soon!
Tags: opensource, linux, community, contributorswanted
Published: 2022-08-11 23:08:35

After a year and a half, the time has finally come! The first election for the AlmaLinux OS Foundation board of directors is set to take place in September this year. This is a big moment for us and for the community at large, so we want to be as transparent and forthcoming as possible.

Let's take a look at where we're at right now.

## Now is the time

When we started the AlmaLinux OS Foundation we didn't have members to vote into a board, and so all current board members were appointed. Though necessary at the start of any such organization, it is ultimately counter to our goal of ensuring that the folks who are invested in the future of AlmaLinux are the ones to choose the future of AlmaLinux. Our bylaws were setup to include regular elections from the start, to ensure we could achieve the goal of all community members having a voice.

This is a good time to mention: if you care about the future of AlmaLinux, now is your time to join the AlmaLinux OS Foundation! The Membership Committee will meet for the last time before the election on August 18th. Anyone who's interested in voting this time needs to [apply for membership](https://almalinux.org/foundation/members/) before August 17th to have a vote this year!

## The Plan

We have outlined the entire plan for this [election on our wiki](https://wiki.almalinux.org/Election2022.html), but here are answers to the questions that I expect to get asked the most:

* An election committee was appointed at the last board meeting made up of community members and a board member who is not standing for election. 
* Any person who has been a member in good standing for at least three months by the time the election starts is eligible to be nominated for a seat on the Board of Directors.
* The election starts on Sept 4th, 2022, and will run until at least Sept 19th, 2022. If we don't reach quorum by Sept 19th, the election will stay open until quorum is reached.

A big list of questions and answers can be found [in the wiki](https://wiki.almalinux.org/Election2022.html). If you have any questions outside of that, you can reach out directly to the Election Committee at election2022@almalinux.org, or find us in the election channel of our [Mattermost](https://chat.almalinux.org/almalinux/channels/foundation-election-2022)! This is your last chance! Get your membership application submitted before August 17th to have a vote this year!
Day 612 : Upgrade
Tags: hiphop, code, coding, lifelongdev
Published: 2022-08-11 22:31:37

_liner notes_:
- Professional : Meeting filled day. Plus my new work laptop came in and took a while to set up and update the OS. I'm pretty sure it's the same model laptop and not an upgrade or anything. Worked on the demo application I've been making. Pretty much just watched this laptop take some time to update. I had to watch because when I didn't, the screen went black and wouldn't come on. So I had to basically babysit the computer. haha.

- Personal : Last night, I finished adding the suggestions functionality to my site https://doingstuff.in . There was a lot more to do than I originally thought. I ran into some issues, but figured it out, tested it and it seemed to work properly. I think I also went through some tracks.

![View from a mountain top looking at other green mountains extending into the distance at sunset](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8kwjyy3kqhzszldgh2u1.jpg)

So I posted a tweet with all the upcoming trips and started to be more a little more active. The plan is to get back to studying Japanese and maybe watch an anime. I'll also go through some tracks for the radio show this week.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube DqROS_ub6Q4 %}