teleren/devto huggingface dataset:
Some popular Go libraries
Tags: go, beginners, vietnameseblogs
Published: 2022-08-26 10:24:00

*Lint: 
- Khái niệm: Là một thư viện hỗ trợ phân tích source code để gắn cờ kiểm tra lỗi lập trình, bug, lỗi cấu trúc không đúng, kiểm tra duplicate, ...

- Cài đặt:
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
golangci-lint version
golangci-lint help linters
//Để chạy linters tại project thư mục test:
golangci-lint run test/main.go
	
- Config golangCI-lint:
Có 2 cách để config golangCI-lint: thông qua cmd hoặc file
1. CMD:(cấu trúc câu lệnh "$ golangci-lint help linters | sed -n '/Linters presets:/,$p'")
//Ví dụ:
golangci-lint run -p bugs -p error test/main.go
2. config file .golangci.yml:
//Ví dụ:
linters-settings:
 errcheck:
    check-blank: true
    (#)report about not checking of error in type assertions: 'a:=b.(MyStruct)'
    check-type-assertions: true
    (#)Path to a file containing list of functions to exclude from checking.
    exclude: /path/to/file.txt
    
*Go validator:
- Mục đích: dùng để đảm bảo dữ liệu vào hệ thống đúng cấu trúc struct và trên các thẻ tag.
- Cài đặt: 
go get github.com/go-playground/validator/v10
- Để bắt lỗi validatorError:
err := validate.Struct(user)
validationErrors := err.(validator.ValidationErrors)
- Loại validator:
Package hỗ trợ cho struct, biến, tùy chỉnh kiểu dữ liệu fields,... 
- Ví dụ về validator:
Kiểm tra tính hợp lệ các thuộc tính trong struct:
type User struct {
	Id       int    `valid:"required"`
	Name     string `valid:"required"`
	Email    string `valid:"email~email k hop le"` (~ để thay đổi message khi lỗi)
	Password string `valid:"required"`
}
Cách kiểm tra: 
if ok, err := govalidator.ValidateStruct(user); err != nil {
	fmt.Print(err)   // In ra các thông báo lỗi
} else {
	fmt.Print("Struct hợp lệ")
}
*Note: nếu có quá nhiều trường cần require thì viết func:
func init() {
  govalidator.SetFieldsRequiredByDefault(true)
}
rồi những trường nào không cần require thêm tag valid: "-". Khi cần nhiều ràng buộc thì cách nhau bằng dấu phẩy.

*Logrus: 
- Định nghĩa: Dùng để ghi dữ liệu về sự kiện xảy ra trong ứng dụng khi hoạt động.(Log)
- Mục đích: Vì trong môi trường develop thì IDE có hỗ trợ debug báo lỗi để biết dễ phát hiện và biết lỗi chỗ nào. Nhưng trên môi trường product thì không thể xem lỗi xảy ra.
- Lưu ý:
Thường sẽ ghi log những dữ liệu đầu vào và đầu ra, thông tin liên quan đến thay đổi dữ liệu, performance và thông tin bất thường.
Những thông tin nhạy cảm không nên ghi log hoặc log được mã hóa(thông tin người dùng, mật khẩu,...)
- Cài đặt:
go get "github.com/Sirupsen/logrus"
Cách dùng cơ bản tương tự "fmt"
Ngoài ra có log.SetFormatter(&log.JSONFormatter{}), Log level.

*Sentry:
- Định nghĩa: Sau khi để hiển thị lỗi trong môi trường product thì Sentry dùng để theo dõi lỗi và sự kiện tại flow đó
- Cài đặt:
go get "github.com/Sirupsen/logrus"
Basic OAuth2
Tags: oauth2, beginners, vietnameseblogs
Published: 2022-08-26 10:22:00

*OAuth là phương thức xác thực người dùng thông qua nhà cung cấp thứ 3(ví dụ như FB, Google, Github,...)
*Cách vận hành:
Ứng dụng gửi yêu cầu ủy quyền truy cập đến FB, Github,... thông qua người dùng. Nếu người dùng đồng ý, ứng dụng sẽ nhận được ủy quyền(token string) từ phía user.
Ứng dụng gửi thông tin định danh(ID) + ủy quyền của user tới chức năng Author server bên nhà cung cấp thứ 3.
Sau khi kiểm tra xác thực và ủy quyền hợp lệ, Author server sẽ gửi lại 1 access_token để xác thực. Nếu access_ token hợp lệ, ứng dụng sẽ cho phép người dùng truy cập.
*OAuth 2.0 tốt hơn so với OAuth 1.0:
- Nhiều luồng OAuth hơn và hỗ trợ tốt hơn cho các ứng dụng không trên trình duyệt.
- OAuth 2.0 không yêu cầu ứng dụng khách hàng phải có mã.
- Chữ ký OAuth 2.0  ít phức tạp hơn nhiều.
- Mã thông báo truy cập OAuth 2.0 ngắn hạn theo phiên và được làm mới khi truy cập lại. (OAuth 1.0 được lưu trữ 1 năm hoặc hơn, không tối ưu)
OAuth 2.0 có sự phân tách rõ ràng  về vai trò  giữa máy chủ xử lý yêu cầu OAuth và máy chủ xử lý ủy quyền người dùng.
Nguồn tham khảo: https://helpex.vn/question/oauth-2-khac-voi-oauth-1-nhu-the-nao-5cb065a7ae03f646208d3831
Integrate Security Into the SDLC
Tags: devops, security, devjournal, programming
Published: 2022-08-26 10:18:51

**Open Source Vulnerability Scanning**

Most software projects contain thousands of external dependencies. Many of these are open source components which could contain security vulnerabilities, may have been created without security best practices, or which may have potential licensing issues once incorporated into a project. 

Open source vulnerability scanning – also known as software composition analysis (SCA) – analyzes open source components, libraries, and their dependencies present in the analyzed codebase. Any detected open source artifacts are identified by their version, distribution, source, common platform enumeration (CPE), and other distinguishing characteristics. 

**1. Scanning in development:** Developers can automatically be notified of security issues in components they are including. They can then make faster, informed decisions on how to address or avoid introducing these risks.

**2. Scanning in security testing:**** Any component with vulnerabilities that exceed a predefined risk threshold should raise an alert and be inspected before deployment to production. These alerts can trigger remediation activities from development teams or be reviewed and prioritized by security teams.

**3. Scanning in production and pre-production:**** Any new vulnerabilities or risks that enter the application after security review can be detected, alerted upon, and addressed. This includes risks from artifacts that entered the project through means other than the SDLC or CI/CD pipeline, zero-day vulnerabilities, and malware.

**Benefits of [DevSecOps Managed Services](https://www.ismiletechnologies.com/devsecops-managed-services/)**

1. Increased collaboration between all teams - development, security, and operations
2. Threat Modeling & Architecture reviews help eliminate security threats and Vulnerabilities at an early stage in the lifecycle
3. Achieve greater agility and speed while designing a future-proof system for scaling
4. Opportunities for quality assurance testing and automated builds wherever possible
5. Automatic inbuilt Security of Code
6. Continuous Security Enablement at all stages in the lifecycle
7. Extensive experience with most modern security implementation tools like Kubernetes, Docker, Jenkins, and Datadog
PHPStorm Tips #10 : Last Edit Location
Tags: phpstorm, productivity, php, webdev
Published: 2022-08-26 10:09:02

Editer le fichier **A**, aller jeter un oeil au fichier **B**, puis **C**, puis **D**, puis ouvrir un dossier pour lire le fichier **E**.

> Mince, j'ai fait ma modif dans quel fichier au fait ?

Bien que la tempête PHP colore les onglets en bleu s'ils sont modifiés et rouge s'ils sont nouveaux dans le VCS, il est parfois difficile de s'y retrouver.

![Screenshot de beaucoup d'onglets PHPStorm](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zmv10zuo429krs9b0dws.png)

Le raccouci **Last Edit Location** vous permet de **revenir sur le dernier fichier que vous avez édité**, en l'occurence, le fichier **A** dans mon exemple.

Par défault, c'est `ctrl` + `shift` + `Backspace`, assez simple de s'en souvenir.

![Screenshot du raccourci](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i6od15ei6yg8obi6ul7g.png)

En appuyant plusieurs fois dessus, il remontera votre historique d'édition **pour la session en cours**.
Mi primera experiencia como DevRel en España
Tags: beginners, programming, career, java
Published: 2022-08-26 10:00:42

Estoy comenzando la ruta de DevRel (_o Developer Advocate_) para una Startup española, si bien siempre estuve metido con la venta, preventa, generacion de manuales y comunicador (_mas bien charlatan_) de las empresas en las que estaba, siento que es un nuevo mundo para mí.

Espero poder hacerlo bien, ya que han depositado esa confianza en mi.

Quienes tengan consejos para hacer mejor este trabajo, seran mas que bien recibidos y si alguien tiene algo de curiosidad sobre automatizacion de procesos (_con o sin codigo_) los invito a consultarme.

Gracias por el apoyo.
How can I link android with wordpress?
Tags: wordpress, posts, android, integrate
Published: 2022-08-26 09:50:29

Hello, I have been facing problems to integrate my android with wordpress, it is not about messages or sms alert but linking a whole android system in it. 
Can anyone from team help me in it?
Here is [my website](https://choosetire.com/).
Thanks 
Cheers.
Smtp services provider
Tags: javascript, beginners, webdev, programming
Published: 2022-08-26 09:26:21

[Smtp services provider](https://www.idealsmtp.com/smtp-server-provider)Are you looking to buy Best SMTP relay service provider for bulk email marketing? Do you want to set up your dedicated SMTP server with Ip Rotation or bulletproof Bulk email server for Small business? Are you looking for private SMTP server? A simple way is to buy dedicated SMTP mail server or bulletproof non-suspended smtp mail server for bulk email marketing. Firstly, we should know what an SMTP email server means and How it works?

SMTP stands for Simple Mail Transfer Protocol, and its Primary function is to manage email sending, receiving, and relaying. Your emails are simply strings of text; SMTP assists servers and email clients in categorizing and organizing the data you transmit. When someone sends an email, they split the sender, recipients, email body, and title heading into parts. It is only applicable to outgoing emails. SMTP is also in charge of establishing contact between servers. The first server identifies itself and sends the kind of action it will carry out only after the second server has authorized the action is the email sent. Finally, SMTP relay simplifies everyone's life as marketers by doing all of the heavy lifting in the background, allowing everyone to spend more time producing content and expanding our contact lists.

While sending singles emails, the messages get routed via SMTP and the POP3 server of your email recipient before landing into the inbox. However, when you send emails in bulk, covering the journey from sent to received isn't easy. The emails server comes with certain limitations on the number of emails sent in a day or hour. Furthermore, the bigger the campaign, the lower rate of delivery may get. Ergo, the selection of the right bulk email service becomes critical for the success of your email marketing campaign.
Where Is Everyone? The Global Impact of COVID on Road Traffic
Published: 2022-08-26 09:04:51

Slides from a 4 minute lightning talk at FOSS4G2022 in Firenze, IT.

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

HERE Traffic Analytics provide the  data for this presentation. Data is collected from multiple GPS sensors globally. The traffic data was aggregated from hourly counts aggregated by day for 2019 to 2021. Congestion is calculated from data, a congestion score of .3 is considered congestion. To put the score in perspective, if you travel time is 10 minutes, a .3 congestion score adds three minutes to trip (10 x 0.3).


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

Data was collected from the 10 largest cities in the USA, Singapore, India, Australia, UK, Germany, and France. Only the two largest and two smallest cities were compared.

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

For western countries, traffic congestion follows a similar pattern with an initial drop in congestion in April and May of 2020 and fluctuations anecdotally following COVID surges. Overall, congestion has declined.

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

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

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

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

For India, we see a variation between Delhi and Jaipur compared to Mumbai and Pune. Singapore follows the general pattern of an initial drop in congestion with drops corresponding with surges.

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

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

Australia presents a different pattern where there is a marked deviation in traffic congestion between the more populous cities of Sydney and Melbourne and the smaller cities of Perth and Brisbane. Note that congestion in Perth and Brisbane is greater in 2021 than in 2019. 

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

This initial exploration of the data leads to more questions. Variations in population, road network, and also COVID response could help explain differentials in traffic congestion.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rt72e3aj0x6raup8z6f0.png)
Finally, the kotlin API and External Cache are supported, and my ORM is finished.
Tags: java, kotlin, orm, redis
Published: 2022-08-26 09:01:48

Hi Guys

It's been a few more months since the last message, my ORM is completely finished, with two important changes.

1. Kotlin API is supported, all the code snippets in the documentation become tab containing 2 cards: Java and Kotlin.
2. Support powerful external cache.

- Does not affect user's choice of caching technology_(The examples use Caffeine and Redis)_.

- For object trees with arbitrary depth, not simple objects.

- Automatically guarantee data consistency between database and cache.

**Youtube link:** [**https://www.youtube.com/watch?v=Rt5zNv0YR2E**](https://www.youtube.com/watch?v=Rt5zNv0YR2E)

*(The framework supports Java API and kotlin API, but for easy understanding, this video only uses kotlin to explain)*

Total time: *36 minutes*.

- Object Fetcher: Query object trees with arbitrary depth*(06:10)*

- Save Command: Save object trees with arbitrary depth*(06:44)*

- External Cache: Cache object trees with arbitrary depth, ensure data consistency*(12:09)*

- Dynamic table joins *(01:23)*

- Paging query *(01:50)*

- Quickly build Spring GraphQL applications *(05:27)*

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

**The story of the project, its creative process**

In the past nearly 20 years of work, I have deeply used too many ORM frameworks, and read all the source code of some of them, but none of them can meet my expectations.

So I quit my job in June last year, stay at home, work hard for my ideals, develop several open source projects. The last project is to create a revolutionary ORM, to be the most powerful and fastest.

> Q: The competition for ORM ended many years ago, why create new ORM?
>
>
>
> A: To solve deep-seated problems, a large number of developers are troubled by these problems every day, but they are not aware of it.
>
>
>
> Q: Why give up all income to create these projects?
>
>
>
> A: My environment that seeks short-term interests, not long-term ones. Lack of innovation and no support for innovation.

Keep trying, keep looking for the best solution. During this period, I also encountered a lot of unhappy things. For example, others were not optimistic, and the [r/java](https://www.reddit.com/r/java/) community of reddit blocked my account on the grounds that they were not allowed to promote their related matters. But these are not important, I tried to solve all the problems I faced before, and finally today, jimmer is fully completed, and all my pre-design goals have been achieved.

During the 14 months of voluntarily giving up any income for the sake of the ideal. I contributed to three projects, in chronological order:

1. A small project for web developers: https://github.com/babyfish-ct/graphql-ts-client.
2. A small project for web developers: https://github.com/babyfish-ct/graphql-state.
3. A medium project for Java and Kotlin developers: https://github.com/babyfish-ct/jimmer.

In any case, now I'm happy because all my ideas became reality.
Github Commands.
Tags: github, git, beginners, githunt
Published: 2022-08-26 09:00:00

When I started using git 3 years ago, I found it very confusing. It had over 100 commands that came with arguments/options.

After a while, I realized that I didn't have to learn them all to hit the ground running in most teams.

This was how I understood the commands I used often:

- git status - where am I? what has changed?
- git clone - copy an upstream repository into a local folder
- git init - start tracking this folder or create a new git repository.
- git checkout - branch away to a new or existing branch.
- git add - prepare my most recent code changes for my next commit.
- git commit - advance added changes to be ready for publishing.
- git push - publish committed changes.
- git pull - get me an updated version from upstream.
- git merge - combine branches (local).
- git branch - switch branches.
- git diff - what is happening?
- git log - what has happened?
- git restore - undo changes


Feel free to add yours :)
Min Cost Climbing Stairs
Tags: leetcode, cpp, dynamicprogramming
Published: 2022-08-26 08:48:40

You are given an integer array cost where cost[i] is the cost of ith step on a staircase. Once you pay the cost, you can either climb one or two steps.

You can either start from the step with index 0, or the step with index 1.

Return the minimum cost to reach the top of the floor.


```cpp

class Solution {
public:
    int minCostClimbingStairs(vector<int>& cost) {
        int n = cost.size();
        vector<int> dp(n + 1); 
        for (int i = 2; i <= n; i++) {
            int jumpOneStep = dp[i - 1] + cost[i - 1];  
            int jumpTwoStep = dp[i - 2] + cost[i - 2];  
            dp[i] = min(jumpOneStep, jumpTwoStep);
        }
        return dp[n];
    }
};

```
Data Model (__getitem__())
Tags: python
Published: 2022-08-26 08:33:28

## Data Model

Quand dans un script Python on fait `my_object[i]` c'est que l'objet `my_object` est une instance d'une classe qui a une méthode spéciale `__getitem__(self)` . Un exemple ci dessous.
### Sans la méthode spéciale

```python
class Building:
    def __init__(self, n_flats):
        self.__flats = [i for i in range(n_flats)]
​
building = Building(10)
​
building[4]
```

```
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [1], in <module>
      3         self.__flats = [i for i in range(n_flats)]
      5 building = Building(10)
----> 7 building[4]
​
TypeError: 'Building' object is not subscriptable
```

### Avec

```python
class Building:
    def __init__(self, n_flats):
        self.__flats = [i for i in range(n_flats)]
        
    def __getitem__(self, i):
        return f"You have selected the building #{self.__flats[i]}"
​
building = Building(10)
​
building[4]
```
```
'You have selected the building #4'
```

L'utilisation de `'[i]'` est un raccourcis de `my_object.__getitem__()`. Une liste par exemple est une instance de classe qui a cette méthode implémentée

### Source
__Fluent Python__ - *Luciano Ramalho*
JavaScript Loops
Tags: javascript, webdev, beginners, tutorial
Published: 2022-08-26 08:23:53

Hello everyone, welcome to the third blog of the beginner series. 
In previous blog we talked about data type method, today we will be discussing basics on loops.

## **What is loop?**

Loop is a sequence of instruction that is continuously repeated until a certain condition is reached.

## **Types of loops :**
 
There are three types of loops, **"while loops"**, "**for loops"**, "**do-while loop"**.

## **while Loops:
**
while loops continue to run until a condition is true.
 
**Syntax :**

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

The purpose of a while loop is to execute a statement or code block continuously  repeated as long as an expression is true. Once the expression became false, the loop terminates.


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

**Output:**

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

## **do-while Loop:**

do-while loop is similar to the while loop except that the condition check happens at the end of the loop.

Syntax:

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

If the condition is true the loop will repeated. Or loop will always be executed at least once , even if the condition is false.


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

Since the do block is run first without checking the condition, this can cause unexpected issues if you're not careful. 

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

## **For Loop:**
for loop are the most common type of loop. for loop repeats until a specific condition evaluates to false.


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

The initial expression , if any is executed. This expression usually initialize one or more loop.
The condition Expression is ending of the loop. If the expression is true , the loop statements execute.
To execute multiple statements use  block statement.

Here the example of for loops. The most common loop -

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

Output:

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

## **Ending Notes**

This is all about loops, thanks for your reading till the end.

You will also check this link :
https://www.w3schools.com/js/