teleren/devto huggingface dataset:
Vuejs3 Template Refs inside v-for
Tags: vue, vuejs3
Published: 2023-05-06 03:21:41

Here's a short tutorial on using Vue.js3 template refs inside `v-for` to call child component methods with the Composition API.

Assuming you want to invoke the reset function of each child component, you can accomplish this as follows:

App.vue
```vue
<script setup>
import { ref } from 'vue'
import Comp from './Comp.vue'
import Comp1 from './Comp1.vue'
const compRefs = ref([])
  
function onReset() {
  compRefs.value.forEach(comp => comp.onReset())
}
</script>

<template>
  <div v-for="n of [0, 1, 2]">
    <template v-if="0 === n % 2">
      loop {{n}}: <Comp ref="compRefs"></Comp>
    </template>
    <template v-if="1 === n % 2">
      loop {{n}}:<Comp1 ref="compRefs"></Comp1>
    </template>
  </div>
  <button @click="onReset">
    Reset
  </button>
</template>
```

Comp.vue
```vue
<script setup>
import { ref } from 'vue'
const msg = ref('')
  
function onReset() {
  msg.value = 'Reset is activated'
}
  
defineExpose({ onReset })
</script>

<template>
  <div>
   Child COM {{ msg ? ':' + msg : '' }}
  </div>
</template>
```

Comp1.vue
```vue
<script setup>
import { ref } from 'vue'
const msg = ref('')
  
function onReset() {
  msg.value = 'Reset is activated'
}
  
defineExpose({ onReset })
</script>

<template>
  <div>
    Child COM1 {{ msg ? ':' + msg : '' }}
  </div>
</template>
```

Please note that the function you want to invoke must be exposed and the template ref should be placed on the child component, rather than on the div where the v-for directive is specified. This is because we need to access the function of the child component.

You can checkout the code on this [playground](https://play.vuejs.org/#eNrdUk1rg0AQ/SsPoWxKUxNzDJq2hBxLIdeYQ6prs1R3F12lIP73jutHK6SE9li8ODNv3pt5s7XzpLVbldxZO34R5UIbFNyUehNKkWmVG9TIeYIGSa4yMIKysbRVme7z7qINWqZp2ZvUvR4QKVkYRJTZ86RA0ErMDsfbUAKhTEoZGaEklNxzmmZ2i7qtDHi3OqUldxOV707RedamEWxs2R1biKsJpb/olqJ1KDA80+nJcIoAPxYVqntiCUKHtBIclnN4c6yOoWMRhBk6CCgSwi0RBAEkbrAaQUCqlEZdy6ZZw7em0D6EHgYmqG/3H2gXk0ku6HjXdKyM95OOd1nIX9DO3d9raQw5/BilInonit63UayLbE8Hpfw3NmfuDPf+3cvpLp8Vb/3RGbtydIJ296YGZisQBU6ErWiQmCjpzC1BzBMh+e5Dq4LP6oEGDfFfeQXdytuzSGNsX57JYTvgA9ia4c7+r8EYGqs0mDjxtv16T+wb/y+mfLni/dmW5hMUyXSL).

That's all, Enjoy!
Lexicographical String Comparison in JS, and Why You Should Care
Published: 2023-05-06 02:54:14

Lexicographical comparison is the process of comparing strings based on the alphabetical order of their characters. It plays a vital role in numerous real-world applications, such as:
1. Sorting lists of names or words
2. Implementing search algorithms, like binary search or trie data structures
3. Detecting duplicate entries in databases or arrays
4. Implementing lexical analysis in parsers and compilers
### Lexicographical Comparison in JavaScript.

JavaScript provides the default string comparison through the use of comparison operators (`<`, `>`, `<=`, and `>=`). These operators perform lexicographical comparison, meaning they compare the characters in strings according to their Unicode code points.

Let's look at a simple example:

```javascript
const string1 = 'apple';
const string2 = 'banana';

console.log(string1 < string2); // true
```

In this example, the comparison `string1 < string2` returns true, as the Unicode code point for 'a' is less than the Unicode code point for 'b'.
### Common Mistakes 

1. **Case sensitivity** : JavaScript's default string comparison is case-sensitive. It can lead to unexpected results when comparing strings with different cases.

```javascript
const string1 = 'Apple';
const string2 = 'banana';

console.log(string1 < string2); // false
```

To avoid this issue, always convert strings to the same case (lowercase or uppercase) before performing a comparison.

```javascript
console.log(string1.toLowerCase() < string2.toLowerCase()); // true
``` 

2. **Numeric strings** : When comparing numeric strings, JavaScript's default lexicographical comparison may produce incorrect results.

```javascript
const num1 = '10';
const num2 = '2';

console.log(num1 < num2); // true
```



To compare numeric strings accurately, convert them to numbers before performing the comparison.

```javascript
console.log(Number(num1) < Number(num2)); // false
```
### Language Specific Peculiarities

When comparing strings in languages other than English, JavaScript's default lexicographical comparison may produce unexpected results due to differences in character order and Unicode code points.

Consider this example with two French words:

```javascript
const string1 = 'côte';
const string2 = 'coté';

console.log(string1 < string2); // false
```



To handle language-specific peculiarities, use the `localeCompare()` method. This method compares strings based on the rules of the specified locale, providing accurate results for different languages.

```javascript
console.log(string1.localeCompare(string2, 'fr')); // -1
```



In the example above, `localeCompare()` returns a negative value, indicating that `string1` should come before `string2` in French alphabetical order.

### Conclusion

Understanding lexicographical comparison in JavaScript is essential for handling and processing text data effectively. By being aware of common mistakes and language-specific peculiarities, you can ensure accurate string comparisons in your web applications, regardless of the language being used.
Définir les attributs dans le constructeur d'une classe en TS 🇫🇷
Tags: typescript, french, poo, programmation
Published: 2023-05-06 02:50:11

Dans cette vidéo, nous allons voir **la syntaxe courte et abrégée en TypeScript pour déclarer les propriétés (attributs) d'une classe** directement via les arguments du constructeur.


{% youtube f_A837qpMJo %}


---

👉 *Projets OpenSource sur GitHub https://github.com/pH-7* 💡

😋 Tu apprécies mon travail ? Veux-tu me supporter en m’offrat un café ? https://ko-fi.com/phenry
How to become a Pro Programmer
Tags: programming, productivity, learning, developer
Published: 2023-05-06 02:45:45


## How to become a Pro Programmer
>  Don’t forget to subscribe [https://www.youtube.com/@therealdumbprogrammer/about](https://www.youtube.com/@therealdumbprogrammer/about)

We all start our programming journey from Zero but we don’t want to be in that state for long, right! We want to improve, we want to climb the ladder.

How we improve ourselves depends on our habits and learning. Here are seven habits that distinguish a good programmer:

## 1. Write clean and readable code:

A good programmer always prioritizes code readability and understands that they are not only writing code for themselves but also for their teammates, clients, and future developers. Hence, they use consistent naming conventions, properly indent code, use whitespace to separate different code blocks, and keep their code concise and modular.

## 2. Document code:

Documenting code is crucial for understanding its purpose, inputs, and outputs. A good programmer documents their code with comments, explaining how the code works and what it does, and providing examples of how to use it. They also ensure that the documentation is up-to-date, especially when changes are made.

## 3. Practice Test-Driven Development (TDD):

A good programmer understands the importance of writing automated tests to verify code functionality. They use TDD to write tests first and then develop code that passes those tests. TDD helps ensure that code meets requirements, is maintainable, and is resilient to changes.

## 4. Continuous learning:

A good programmer never stops learning. They keep up with new technologies, best practices, and industry trends. They read books, blogs, participate in online courses, attend conferences, and engage with the programming community.

## 5. Collaborate effectively:

A good programmer knows how to work well in a team. They listen to other team members, provide constructive feedback, and communicate effectively. They understand that programming is a team sport, and everyone’s contributions are essential to delivering high-quality code.

## 6. Embrace simplicity:

A good programmer understands that keeping things simple is key to producing maintainable code. They prioritize the use of simple and elegant solutions over complex ones. They also avoid over-engineering and always strive for the simplest solution that meets the requirements.

## 7. Refactor frequently:

A good programmer understands that code quality is a continuous process, and they are not afraid to refactor code frequently. They use automated refactoring tools to improve code quality and make it more maintainable. They also refactor code to remove duplication, improve readability, and remove technical debt.
Soi cầu 247 - Chuyên trang dự đoán xổ số chuẩn xác và miễn phí
Tags: soicau247, soicau247io
Published: 2023-05-06 02:41:19


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xewtoy1s0ty2k7ybz20y.jpg)Nội dung "Soi cầu 247 - Chuyên trang dự đoán xổ số chuẩn xác và miễn phí" có ý nghĩa rất quan trọng đối với các bạn chuyên soi cầu xổ số hàng ngày. Đây là một trang web chuyên cung cấp các thông tin dự đoán xổ số miễn phí và chính xác nhất.

Với đội ngũ chuyên gia giàu kinh nghiệm và tâm huyết, [soi cầu 247](https://soicau247.io/) cam kết cung cấp những thông tin dự đoán xổ số chính xác và miễn phí nhất đến cho người chơi. Điều này giúp các bạn chuyên soi cầu xổ số có thể tìm thấy các bảng dự đoán xổ số chuẩn xác và miễn phí để tham khảo.

Thông tin dự đoán xổ số được cập nhật thường xuyên và đánh giá cao về tính chính xác. Ngoài ra, Soi cầu 247 còn cung cấp các thông tin thống kê xổ số, những bí kíp chơi xổ số thông minh, cùng nhiều thông tin hữu ích khác giúp bạn tăng cơ hội trúng thưởng.

Đặc biệt, Soi cầu 247 cung cấp các bảng dự đoán xổ số miễn phí hàng ngày, hàng tuần và hàng tháng. Điều này giúp các bạn chuyên soi cầu xổ số có thể tham khảo và đánh giá độ chính xác của các bảng dự đoán từ cộng đồng người chơi khác. Cộng đồng người chơi xổ số sẽ cùng nhau soi cầu và chia sẻ thông tin để đưa ra các dự đoán chính xác và tối ưu nhất.

Với tính năng chia sẻ bảng dự đoán từ người dùng, các bạn chuyên soi cầu xổ số có thể tham khảo và đánh giá độ chính xác của các bảng dự đoán từ cộng đồng người chơi khác, giúp các bạn có được những quyết định đúng đắn và tối ưu nhất.

Tóm lại, nội dung "Soi cầu 247 - Chuyên trang dự đoán xổ số chuẩn xác và miễn phí" mang lại ý nghĩa rất quan trọng đối với các bạn chuyên soi cầu xổ số hàng ngày. Với các thông tin dự đoán xổ số chính xác và miễn phí, các bạn chuyên soi cầu xổ số có thể tìm thấy các bảng dự đoán xổ số chuẩn xác và miễn phí để tham khảo và đưa ra các quyết định chơi xổ số đúng đắn và tối ưu nhất.
[https://soicau247.io/](https://soicau247.io/)
Exploring useRef, useMemo, and the Challenges of Working with Multiple Components
Tags: webdev, javascript, beginners, programming
Published: 2023-05-06 02:09:24

Day 95 of #100DaysOfCode: Today, I’ve been immersed in the world of buttons, particularly the undo button. Within the MainButtons component, which is a child component of ClientDashboard, I’ve set up the functionality to trigger the handleUndo function when the undo button is clicked. This, in turn, calls the undoFunction() responsible for executing the undo action.

To manage the undo function effectively, I’ve utilized the useState hook. It allows me to seamlessly handle the state of the undoFunction within the Customer component, another child component of ClientDashboard. The connection between these components is established using the useEffect hook, which ensures that the undoFunction is properly updated whenever any changes occur.

The ClientDashboard component keeps throwing an error, claiming that undoFunction is not a function. I’m currently debugging this issue.

Stay tuned for further updates on my progress as I continue to unravel the mysteries of buttons and conquer the challenges that come my way 😆
Github Action to check helm charts for deprecated k8s APIs
Tags: githubhack23
Published: 2023-05-05 16:02:45

## What I built 
I Built a github action which checks your helm chart for deprecated k8s API usages by leveraging [pluto](https://github.com/FairwindsOps/pluto) functionality.

At the moment, you have to build this on your own using multiple steps in your github action workflow. This github action simplifies it in one step and makes your workflow definition more readable.

### Category Submission: 
- Maintainer Must Haves
- DIY Deployments

### App Link
[Helm pluto github action](https://github.com/marketplace/actions/check-deprecated-k8s-apis)

### Description 
Without the plugin, you have to put multiple steps in your github action pipeline to match necessary preconditions:
- Download helm
- Download pluto
- render your helm chart
- hand over helm chart to pluto

This github action takes care of all the preconditions and allows you to verify your helm chart in a single step.

It's just a minor improvement, but by using this action you do not have to take care of the boilerplate.

### Link to Source Code 
[Source Code](https://github.com/eddykaya/helm-pluto-github-action)

### Permissive License 
Apache 2.0
## Background (What made you decide to build this particular app? What inspired you?) 
I built this as a shared library for Jenkins and did not find a pendant for github actions.

### How I built it (How did you utilize GitHub Actions or GitHub Codespaces? Did you learn something new along the way? Pick up a new skill?) 
This is a github action itself.

### Additional Resources/Info
An example usage can be found [here](https://github.com/eddykaya/yahc)
PostgreSQL on OpenBSD: 12 から 13 へのアップグレード - pg_dumpall 使用
Tags: postgres, database, migration, openbsd
Published: 2023-05-06 01:14:05

## はじめに

[OpenBSD](https://www.openbsd.org/) の [6.8](https://www.openbsd.org/68.html) から [6.9](https://www.openbsd.org/69.html) へのアップグレードに際しては、[PostgreSQL](https://www.postgresql.org/) サーバーも ([12](https://www.postgresql.org/docs/12/index.html).6 から [13](https://www.postgresql.org/docs/13/index.html).2) へアップグレードする必要があります。[OpenBSD の アップグレード・ガイド (英語) でそのように案内されています](https://www.openbsd.org/faq/upgrade69.html#SpecialPackages)。
本記事では、以下の `postgresql-server` パッケージ公式の readme に沿って、実施した内容を記載します:

```console
$ nvim -R /usr/local/share/doc/pkg-readmes/postgresql-server
```

[本記事とは別の方法もあります](https://obsd.solutions/ja/blog/2023/05/06/postgresql-on-openbsd-upgrade-14-to-15/index.html)。[`pg_upgrade`](https://www.postgresql.org/docs/12/pgupgrade.html) を使う方法です。追加のパッケージのインストールが必要ですが、マイグレーション速度の向上が期待できます。

## チュートリアル

サーバーが動いていることを確認しましょう。

```console
$ doas rcctl check postgresql
postgresql(ok)
```

[`pg_dumpall`](https://www.postgresql.org/docs/12/app-pg-dumpall.html) を実行します。

```console
$ doas su _postgresql -c "cd /var/postgresql \
    && pg_dumpall -U postgres > /var/postgresql/full.sqldump.bkYYMMDD"
$ # pg superuser's password is required times of the number of tables
```

なおここでの "YYMMDD" は実際のバックアップ取得日にしてください。一例ですが [Fish シェル](https://fishshell.com/) でしたら `date +"%y%m%d"` でシステム日をセットできます。

サーバーを停止します。

```console
$ doas rcctl stop postgresql
postgresql(ok)
$ # check the server is stopped
$ doas rcctl check postgresql
postgresql(failed)
```

サーバーのパッケージをアップグレードします。

```console
$ doas pkg_add -ui postgresql-server
$ # updated
```

`/var/postgresql/data` をつくりかえます。

```console
$ doas mv /var/postgresql/data /var/postgresql/data-12
$ doas su _postgresql -c "mkdir /var/postgresql/data"
```

[`initdb`](https://www.postgresql.org/docs/13/app-initdb.html) を実行します。

```console
$ # `--locale` option here can be omitted
$ doas su _postgresql -c "cd /var/postgresql && \
    initdb -D /var/postgresql/data -U postgres -A scram-sha-256 -E UTF8 -W \
        --locale=xx_XX.UTF-8"
$ # pg superuser's password is required
```

---

必ずしもというわけではありませんが、必要に応じて、サーバーの設定を行います。

```console
$ # in case of using tls/ssl connection
$ # - set `listen_addresses` and `ssl` option
$ doas nvim "/var/postgresql/data/postgresql.conf"
$ # - add `hostssl` authentication
$ doas nvim "/var/postgresql/data/pg_hba.conf"
$ # - create certificate if not exists
$ doas su _postgresql -c \
    "cp /var/postgresql/data-12/server.{crt,key} /var/postgresql/data/"
```

上記は [こちらの記事](https://obsd.solutions/ja/blog/2023/05/06/postgresql-12-tls-connection/index.html) に基づいています。

---

新しくなったサーバーを起動します。

```console
$ doas rcctl start postgresql
postgresql(ok)
$ # check the server is started and running
$ doas rcctl check postgresql
postgresql(ok)
```

データベースとテーブルやレコード等のオブジェクトをリストアします。

```console
$ doas su _postgresql -c "cd /var/postgresql && \
    psql -U postgres < /var/postgresql/full.sqldump.bkYYMMDD"
$ # restored
```

完了です 🙂
Türkiye SEO Merkezi Türk SEM Yazılım Ekibi Şimdi Dev.to 'da!
Tags: seo, google, turkey, webdev
Published: 2023-05-06 00:17:05

Türk SEM içerik ve yazılım geliştirme ekibi şimdi Dev.to 'ya kayıt oldu. Yakın zamanda yayınlamaya hazırladığı herkesin işine yarıyacak SEO aracı yapıyor. **[SEO Nedir](https://www.turksem.com/seı)** sayfasında gelişmeler aktif olarak kullanıcılarla paylaşılacak. Yeni geliştirilen uygulama yayınlanır yayınlanmaz biraz önce bahsettiğimiz SEO sayfasında duyurusu gececektir.

> [Google SEO Uzmanı](https://developers.google.com/search/docs/fundamentals/do-i-need-seo?hl=tr) yazısında bahsettiği gibi;
> Önerilen değişiklikleri uygulama konusunda kararlı olun. SEO tarafından önerilen değişikliklerin yapılması zaman ve çaba gerektirir. Bu değişiklikleri yapmaya zaman ayırmayacaksanız bir uzmanla çalışmanıza değmez.


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

SEO konusunda çalışma yapmak istediğinize emin olmalısınız. Eğer eminseniz Turksem.com SEO ekibi tam anlamıyla sizin yanınızda olacaktır.
Resolvendo problema de "foreign key constraint" ao migrar o Ghost CMS da v4 para v5
Tags: ghost, mysql
Published: 2023-05-05 23:59:07

Ao atualizarmos o Ghost para sua versão 5, diversos scripts de migração são executados, incluindo scripts que realizam alterações no Banco de Dados. E é justamente um desses scripts que ao não conseguir realizar uma mudança na base de dados, impossibilita a execução do Ghost.

Esse script tenta realizar uma mudança que afeta uma tabela com `foreign key constraint` , o que é bloqueado pelo Banco de Dados.

O script em questão, tenta executar o seguinte:

```sql
alter table `subscriptions` modify  `tier_id` varchar(24) not null
```

Podemos observar que ele tenta executar uma mudança na tabela `subscriptions` e nos retorna o seguinte erro:

```shell
Message: Ghost was able to start, but errored during boot with: alter table `subscriptions` modify  `tier_id` varchar(24) not null  - Cannot change column 'tier_id': used in a foreign key constraint 'subscriptions_tier_id_foreign'
Context: [object Object]
Help: Error occurred while executing the following migration: 2022-10-18-05-39-drop-nullable-tier-id.js
```

Para solucionar esse problema devemos desabilitar a checagem `foreign keys` antes de executar o script, após a execução da `query` podemos reabilitar a checagem normalmente. O script a seguir deve ser executado diretamente na base de dados de forma manual:

```sql
USE ghost_test; # Aqui seleciono a base de dados onde a tabela se encontra
SET foreign_key_checks = 0; # Desabilito as checagens foreign keys
alter table `subscriptions` modify  `tier_id` varchar(24) not null; # Executo a query que o Ghost tentou realizar
SET foreign_key_checks = 1; # Reabilito as checagens foreign keys
```

Agora, de volta ao Ghost, podemos executar o comando para iniciar sua execução:

```shell
ghost start
```

Processo finalizado!
How to access custom admin registration page with access code
Published: 2023-05-05 23:52:42

Hi Devs community, sorry I'm new to this forum and am also a beginner in Django. I've been working on a project that has three users. These users are admin, customer, and employee. Each has their own registration page that one could access and sign up easily. However, I want to make sure that for the admin registration page, it has to be accessed using an admin code so that only the website owners can register as admin and manage the website. I did that and it worked just fine. I wanted to add a custom decorator to enforce this but it's not working as I anticipated. Here's the link to my project on github https://github.com/billwhite16/custom_user.git . I would really appreciate any help or guidance on this. Thank you in advance.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yazquazie148nb2kwmf9.png)
"Why a Not-To-Do List is More Important Than a To-Do List for Productivity"
Published: 2023-05-05 23:37:21

When it comes to productivity, most people tend to focus on their to-do list. After all, it's easy to see what needs to be done and check off tasks as they are completed. However, many experts argue that a not-to-do list is just as important, if not more so, for achieving optimal productivity.

One of the main reasons that a not-to-do list is so important is that it helps you to focus on what is truly important. When you have a long list of tasks to complete, it can be easy to get bogged down in the details and lose sight of the bigger picture. By creating a not-to-do list, you are essentially setting boundaries and prioritizing the most important tasks.

For example, let's say you're a small business owner who is trying to grow your company. Your to-do list might include tasks like networking, developing new products, and increasing sales. However, your not-to-do list might include things like attending unnecessary meetings, taking on too many low-paying clients, or spending too much time on social media. By focusing on the things that you shouldn't be doing, you can free up time and energy to focus on the things that will truly help your business grow.

Another important benefit of a not-to-do list is that it helps you to avoid distractions and procrastination. We all have those tasks that we know we should be doing, but for some reason, we just can't seem to get around to them. By putting these tasks on your not-to-do list, you are effectively setting a deadline for yourself. This can help to create a sense of urgency and motivate you to get the task done.

A real-world example of this is a student who is preparing for an exam. Their to-do list might include studying, taking practice tests, and reviewing notes. However, their not-to-do list might include things like watching TV, scrolling through social media, or procrastinating by browsing the internet. By focusing on the things that they should not be doing, they can effectively manage their time and increase their chances of success.

In conclusion, a not-to-do list can be just as important as a to-do list when it comes to achieving optimal productivity. By setting boundaries, prioritizing tasks, and avoiding distractions, a not-to-do list can help you to focus on what is truly important and achieve your goals. So, the next time you're feeling overwhelmed by your to-do list, try creating a not-to-do list and see how it can help you to improve your productivity.