teleren/devto huggingface dataset:
Consigue fechas relativas en Javascript
Tags: javascript, webdev, i18n, spanish
Published: 2022-09-13 13:56:52


Las fechas pueden ser algo bastante engorroso de trabajar, una de esas complicaciones nace cuando el requerimiento es el de mostrar la fecha de algún contenido de la aplicación en formato relativo a la fecha actual: `Hace 2 semanas`. 



Por suerte, Javascript ofrece una solución nativa para esto *Intl.RelativeTimeFormat*.



Al igual que los otros constructores expuesto por el objeto *Intl*, este constructor recibe dos argumentos, el primero un string que identifica el lenguaje que se quiere utilizar, y el segundo un set de opciones:



> Te invito a leer los otros artículos sobre Internacionalización:  
> [Formato de Fechas](https://matiashernandez.dev/blog/post/formateando-fechas-en-javascript) y [Formato de números](https://matiashernandez.dev/blog/post/como-dar-formato-de-moneda-a-un-numero-en-javascript) 



```typescript
type Options = {
    localeMatches: 'best fit' | 'lookup',
    numeric: 'always' |'auto'  // The format of the output
    style: 'long' | 'short' | 'narrow'
}
```

El método `format` de este constructor también recibe dos argumentos:

* Un valor entero que indica el total de tiempo que se quiere mostrar
* Un string que identifica la unidad de tiempo a utilizar. (`day`,`month`,`year`, etc)



```javascript
const formatter = new Intl.RelativeTimeFormat('es-ES');
const monthAgo = formatter.format(-1, 'month') // hace 1 mes
const futureMonth = formatter.format(1, 'month') // en 1 mes
```

### ¿Cómo utilizar las fechas relativas?

SI hablamos de fechas relativas es casi obvio que estarás usando fechas en alguna parte, por ejemplo: Tienes una colección de artículos que tienen una fecha de publicación, pero no quieres mostrar la fecha si no un texto indicando hace cuanto tiempo fueron creados.



Para lograrlo deberás hacer algo de matemáticas de fechas para obtener la diferencia y usar ese valor para obtener el texto relativo.

```javascript
const publicationDate = new Date('2022/01/05')

const currentDate = new Date()

const msPerDay = 1000 * 60 * 60 * 24;

const diffTime = Math.abs(currentDate - publicationDate);
const diffDays = Math.ceil(diffTime / msPerDay);


const enRtf = new Intl.RelativeTimeFormat("en-US", {
  numeric: 'auto',
});

console.log(enRtf.format(-diffDays, "day")); // 251 days ago
console.log(enRtf.format(-diffDays/30, "month")); //8.367 months ago


const esRtf = new Intl.RelativeTimeFormat("es-ES", {
  numeric: 'auto',
});

console.log(esRtf.format(-diffDays, "day")); // hace 251 días
console.log(esRtf.format(-diffDays / 30, "month")); // hace 8.367 meses
```



![Footer Social Card.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1615457338201/5yOtr5SdF.jpeg)
✉️ [Únete a Micro-bytes](https://microbytes.matiashernandez.dev)         🐦 Sígueme en [Twitter](https://twitter.com/matiasfha)           ❤️ [Apoya mi trabajo](https://buymeacoffee.com/matiasfha)
HOW TO RESOLVE MERGE GIT CONFLICT.
Tags: javascript, webdev, beginners, programming
Published: 2022-09-13 13:50:15

What Are Merge Conflicts and What Is Git Merge?
Git is a version control program that maintains a history of every version of your files. Anytime you want, you can recover an earlier version by going back to any of the versions.

Consider that you have produced a file named “doc.txt” and uploaded it to a Git repository. The file is currently associated with its most recent version. The file now has a new version attached if your coworker edited it and sent it back to the repository.
You can maintain consistency between the present content of the file and earlier versions by using the Git Merge functionality. This is crucial because everyone should always be editing the most recent content of the file without overwriting modifications made to earlier versions.

Before pushing a new update to the same file, Git merge enables you to combine changes made by other developers.
We should be cautious of two things when using Git merge:

What kinds of modifications were made between two versions of a file? Existing content may be changed, deleted, or replaced with new content.

There are two different scenarios that are possible. Either the same region of the file saw modifications, or the changes occurred in distinct sections of the file. Same region refers to modifications that have been done to a file’s vicinity (for example, the same paragraph, line, etc.).

Fortunately, Git uses the auto-merge approach to handle the majority of these situations automatically. Git won’t, however, attempt an auto-merge if the same area of the file has undergone changes. Instead, it defers to your decision to resolve.

How Can Merge Conflicts Be Solved in Git?
The procedures required to resolve merge conflicts in Git could be shortened by taking a few specific actions.

Opening the conflicted file and making the appropriate adjustments is the simplest way to remedy the issue.

After making changes to the file, we may stage the newly merged material using the git add a command.

The git commit command is used to create a new commit as the last step.

A fresh merge will be created by Git. Decide to complete the integration.

Now let’s examine the Git commands that can be crucial in settling conflicts.

Git Commands to Resolve Conflicts
1. git log — merge
The list of commits that are creating the conflict is produced by the git log — merge command.

2. git diff
To find discrepancies across states of repositories or files, use the git diff program.

3. git checkout
The git checkout command is used to reverse file modifications or to switch branches.

4. git reset — mixed
To reverse changes made to the working directory and staging area, use the git reset — mixed command.

5. git merge — abort
The git merge — abort command facilitates stopping the merging operation and returning to the initial state.

6. git reset
When merging, the git reset command is used.
Looking for research interview participants
Published: 2022-09-13 13:46:06

Hi all, 

my Name is Sebastian, I am a researcher currently looking into blockchain / web3 coding education options. I am looking for interview participants (profile: you are a dev interested in web3 or already working in web3) for a 20 minutes interview. As a Thank you, I am happy to offer a 75$ Amazon voucher in return.

In case you are open to this, feel free to book a slot via https://calendly.com/dienst-basti/30min?month=2022-09

Let me know if you have any questions!

Thank you,
Sebastian
TIL: Auto push new branches
Tags: git
Published: 2022-09-13 13:36:45

Add the following line to the `config` file in your `.git` folder (or to your global git config) to auto push a new branch you've created locally:

```properties
[push]
    autoSetupRemote = true
```

Now, on the first time you enter `git push` for a new branch your terminal won't complain that the remote doesn't exist, it just pushes your branch.
Machine Learning Projects for Students
Tags: machinelearning, projects, ai, engineering
Published: 2022-09-13 13:33:27

Machine knowledge is a trending arena in computer science that allows the computer the capability to learn without being programmed explicitly. Artificial Intelligence is the broader conception of machines being suitable to carry out tasks in a way that we'd consider “ smart ”. [Machine Learning](https://www.youtube.com/watch?v=8gkUS4EJry4) is a current operation of AI grounded on the idea that we should really just be suitable to give machines access to data and let them learn for themselves.

"What projects can I do with machine learning ?"

We often get asked this question a lot from students getting started with machine learning. We experts recommend that you explore some exciting, cool, fun, and easy machine learning project ideas across diverse business domains to get hands-on experience on the machine learning skills you've learned.  

We've curated a list of innovative and interesting [machine learning projects for students](https://takeoffprojects.com/machine-learning-projects-for-students) with source code. These student projects on machine learning are a perfect blend of various types of challenges one may come across when working as a machine learning engineer/deep learning engineer/data scientist.

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

 Few of the machine learning projects for students are:

- [Motion Detection Using Background Subtraction Technique In Surveillance](https://takeoffprojects.com/project-details/motion-detection-using-background-subtraction-technique-in-surveillance--415)
- [Leaf Disease Detection for Agriculture Industry](https://takeoffprojects.com/project-details/leaf-disease-detection-for-agriculture-industry--402)
- [Object Detection Using Tensor Flow In Shopping Malls](https://takeoffprojects.com/project-details/object-detection-using-tensor-flow-in-shopping-malls--422)
- [E-commerce Sales Prediction Using Listing Keywords](https://takeoffprojects.com/project-details/e-commerce-sales-prediction-using-listing-keywords--4738)
- [Handwriting Recognition for Vegetable Merchant
](https://takeoffprojects.com/project-details/handwriting-recognition-for-vegetable-merchant--398)
Admin Approval on User Registration
Tags: webdev, tutorial, wordpress, programming
Published: 2022-09-13 13:17:31

Whether you're setting up email activation on registration, this [video](https://youtu.be/kIBhKy8jnZ8) will show you the easiest way to do it. We'll also show you how to add user activation options, so you can ensure that your users are fully registered and ready to use your site.

User activation option upon registration:
- Auto activation
- Need email verification
- Need admin approval
- Need both email verification and admin approval
I know HTML CSS but cant create anything by myself
Tags: html, javascript, webdev, beginners
Published: 2022-09-13 13:09:04

**Its happening because of your habit**. 

These days most of the beginners have it. Which is copying and pasting.

**Please try to avoid this habit**. It wont help you. Only it will cost your time.

One solution from my side is, try to do the coding by yourself. Don't copy past codes. Try to do the coding line by line by yourself. If you face any problem or get stuck somewhere, then research about it. Try to clear your basics first.

And one last thing, this field requires time to be a pro. Take your time & keep creating new thing yourself. If you don't have the interest to create something new by yourself, then you cant learn it.

It will take time. You can watch my video [tutorials](https://www.youtube.com/c/Tech2etc) about HTML & CSS to clear your basics.
Why I am unable to authenticate using Auth0?
Tags: help, php, laravel
Published: 2022-09-13 13:07:46

I try to make an authenticatable endpoint using Auth0:

{% stackoverflow 73703488 %}

But I'm stuck on this error:

```
Argument 1 passed to Auth0\Login\Auth0Service::__construct() must be of the type array, null given, called in /var/www/html/api/vendor/auth0/login/src/Auth0/Login/LoginServiceProvider.php on line 68
```

Can somebody help me?
14 days of Git
Tags: git, devops, 14daysofgit
Published: 2022-09-13 12:55:53

Git is a tool that I have learnt as I go.  I've read some basic tutorials, I've mashed some keys into the command line and managed to make it do what I want to.  But I don't really know the tool.

I haven't sat down and read the manual at all.  

I want to change that. 

I want to spend some time learning Git properly. 

Working through some scenarios and learning. 

With the aim at being a more proficient Git user. 

It's a journey, I want you all to join me on. 

## The plan
I have a learning plan.  I want to spend an hour or two a day learning something different and sharing it. 

My learning plan starts from the very beginner, I'm going to start from scratch.  Although I might know some of the beginning topics already I want to make sure I really understand them. 

You can follow along on with me.  Whether you are a beginner to Git or something that, like me, has been using it but it's been a hit or miss learning experience. 

You can find the learning plan I have designed on GitHub - [https://github.com/weeyin83/14daysofgit](https://github.com/weeyin83/14daysofgit)

My aim is for me to learn new things and explore new topics and help others as well. 

I'll be posting a new blog post after every day's learning activities.  You'll be able to find all those blog posts using the tag [14daysofgit](https://dev.to/t/14daysofgit). 

Let's get started!
How do you become a professional WordPress designer?
Tags: wordpress, webdev, beginners, design
Published: 2022-09-13 12:50:14

**Only practice can make you a professional WordPress designer.**

It is very easy to design websites using WordPress. But your design will pop up from thousands of designs only if you can create something creative.

So you need to 
* keep practicing.
* try to understanding the design patterns.
* look after new design [trends](https://1.envato.market/c/2672959/275988/4415).
O que é o Index ?
Tags: webdev, beginners, tutorial, html
Published: 2022-09-13 12:25:11

O index é o nome padrão do arquivo principal do site, sempre que o servidor for buscar o primeiro arquivo para executar, será o arquivo com o nome index. O servidor pode estar configurado para buscar primeiro arquivos com outros nomes, mas no geral será sempre o index. Por ser o arquivo principal normalmente ele não aparece na url do site.
O arquivo index é usando para os formatos de arquivo .html, .php e .asp.
Append() function in Python.
Tags: beginners, programming, python, append
Published: 2022-09-13 12:43:14

**1.What is Append function?**
Append function is used to add a item at the end of the sequence if the condition is True.

**Example1**
```
subjects = ['Maths','Science','Physics']
subjects.append('Chemistry')
print(subjects)
```
**Explanation:**
Statement 1:
subjects = ['Maths','Science','Physics']
Statement 2:
append functions is being used in Statement 2 So, 'Chemistry' will be added at the end of the sequence.
**Final Output:**
['Maths', 'Science', 'Physics', 'Chemistry']

**Example 2**

```
list1=['Mathematics', 'AI', 'Science','Political Science']
list2=[]
for i in list1:
 if 'a' in i:
    list2.append(i)
print(list2) 
```
**Explanation:**
Iteration1:
"a" in 'Mathematics' , condition becomes True and it will be added at the end of list2.
Iteration1:
"a" in 'AI' , condition becomes FALSE and it will not be added in sequence.

**Final output**
['Mathematics', 'Political Science']
The power of powertoys
Tags: productivity, tutorial, programming, writing
Published: 2022-09-13 12:38:29

Ketika melihat beberapa orang menggunakan Macbook nya. Saya sangat iri dengan produktivitas yang dapat dilakukan dengan komputer itu. Hal yang membuat saya iri salah satunya adalah fitur "[Spotlight](https://support.apple.com/id-id/guide/mac-help/mchlp1008/mac)" nya.

Fitur ini adalah bawaan dari Mac OS untuk penggunanya yang dapat mempermudah pencarian sesuatu seperti program, file, web dll. Namun bagaimana dengan pengguna Windows seperti saya? Tentunya Microsoft sudah menyediakan fitur pencarian bawaannya, tapi itu bukan fitur yang bisa di banggakan LOL :-)

Bagi Anda pengguna Windows saya pikir bisa menggunakan Powertoys. Anda dapat menginstallnya melalui beberapa cara, seperti:

1. Melalui Github
2. Melalui Microsoft Store (Rekomendasi)
3. Melalui Winget

Setelah melakukan penginstalan, Anda akan mendapatkan tampilan seperti ini. 

![Gambar 1: Tampilan Aplikasi Powertoys](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fht08ob87z998ye152v.png)

_Note:_ Pastikan pengaturan berjalan saat _startup_ diaktifkan.

## Fitur-fitur
Inilah beberapa fitur-fitur yang saya sangat suka di _Powertoys_. Adapun fitur-fitur pada versi v0.62.0 yang saat ini saya sering pakai adalah:

### Powertoys Run
![Gambar 2: Powertoys Run](https://ik.imagekit.io/dz5f3sbago/devto/pt-powerrun-demo_Y8eATwdAw.gif)

Memberikan pengalaman penggunaan "SpotLight" di komputer Windows Anda. Dapat melakukan pencarian file, folder, program, web, menjalankan shell dan masih banyak lagi. Anda dapat melihat lebih banyak lagi di sini [https://docs.microsoft.com/en-us/windows/powertoys/run](https://docs.microsoft.com/en-us/windows/powertoys/run).

### Mouse Utilities

![Gambar 3: Mouse Utility](https://ik.imagekit.io/dz5f3sbago/devto/pt-mouse-utilities-find-my-mouse_jhQWXBnJB.gif)

Dengan menggerakkan berulang mouse Anda, Anda dapat melihat dimana posisi mouse Anda berada dengan cepat. 

### Fancy Zone

![Gambar 4: Fancy Zone](https://ik.imagekit.io/dz5f3sbago/devto/pt-fancyzones-quickswap__1__QCadDWQ0V.gif)

Dengan fitur ini mengatur layout di windows menjadi lebih mudah. Anda dapat mengatur layout secara _custom_ dengan fitur _layout editor_. 

### Text Extractor

![Gambar 5: Text Extractor](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rebp28dklvrqf5c8r2fn.gif)

Ucapkan selamat tinggal pada plugin [_Copyfish_](https://ocr.space/copyfish) karena di _Powertoys_ telah memiliki fitur yang serupa dan berjalan native di _windows_.
Tipos Primitivos no C#
Tags: csharp, beginners, dotnet
Published: 2022-09-13 12:36:12

Tipos primitivos são um conjunto de tipos de dados básicos que servem de base para todos os outros tipos. 

Podemos os resumir em 4 categorias: **Inteiro**, **Real**(float), **Lógico** e **Texto**. Ainda assim, muitas linguagens de programação subdividem essas categorias dependendo da quantidade de memória utilizada, por exemplo _shorts_ e _longs_ para os inteiros.

Na linguagem C# não há uma definição dos tipos primitivos em sua especificação. Ao invés disso são usados aliases para os tipos definidos na plataforma .NET! Isso quer dizer que você pode utilizar qualquer das nomenclaturas sem nenhum problema.
A tabela abaixo mostra como ficam essas relações, com uma legenda da categoria a qual cada tipo pertence:

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

Na própria [documentação](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/built-in-types) do C# podemos ter mais informações sobre cada um desses tipos.
A próxima tabela resume bem o que cada um desses tipos representa (ou suporta):

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

É importante ter em mente os limites do que podemos atribuir a cada um dos tipos. Ao mexermos com dinheiro por exemplo, usamos o tipo decimal, pois apesar de float e double possuírem casas decimais, o tamanho deles certamente causará perda de precisão e suas variáveis deixarão de apresentar o valor que você espera delas... (Mais sobre isso [aqui](https://docs.microsoft.com/en-us/cpp/build/why-floating-point-numbers-may-lose-precision?view=msvc-170)).

Esse é o post das tabelas, e aqui vamos preparar mais uma. Todos os tipos possuem um valor padrão. Esse padrão é o que será atribuído a uma variável de dado tipo caso não lhe passemos nenhum outro valor.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jbpyqsfvh77tp5bd5lri.png)

Aqui o __char__ teve uma definição um pouco mais complicada por se tratar de um tipo que representa um caractere [Unicode](https://home.unicode.org/), de forma mais simples esse valor representa ''.

Por último, podemos [converter](https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/numeric-conversions#explicit-numeric-conversions) alguns tipos primitivos para outros, seja através de um __casting__(explicitamente) ou de maneira implicita. Como regra, podemos assumir que a conversão de um tipo menor para um maior pode ser feita de maneira implícita, enquanto para converter tipos maiores em menores precisos deixar explicito para o compilador que sabemos o que estamos fazendo!
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zgmtc2hw7o21mn1nyep1.png)

Essa foi uma introdução aos tipos primitivos, espero que tenha sido claro para você!
Cool GitHub repositories for self-taught
Tags: git, javascript, programming, webdev
Published: 2022-09-13 12:16:33

A list of programming tutorials in which developers learn how to build an application from scratch. 
([https://github.com/practical-tutorials/project-based-learning](https://github.com/practical-tutorials/project-based-learning))

EBooks ([https://github.com/EbookFoundation/free-programming-books](https://github.com/EbookFoundation/free-programming-books))

Web Developer RoadMap ([https://github.com/kamranahmedse/developer-roadmap](https://github.com/kamranahmedse/developer-roadmap))

List of free public APIs for use in Web Development ([https://github.com/public-apis/public-apis](https://github.com/public-apis/public-apis))

Learn and expand your coding Skills ([https://github.com/freeCodeCamp/freeCodeCamp](https://github.com/freeCodeCamp/freeCodeCamp))
Some of the really cool Website especially for improving Javascript Knowledge and code skills
Tags: javascript, programming, beginners
Published: 2022-09-13 12:11:28

[https://www.jschallenger.com/](https://www.jschallenger.com/)
(Do code challenges  & improve the logic implementation)

[https://www.java5cript.com/](https://www.java5cript.com/)
(Any thing you can learn about JavaScript & in that you will find the other options like Books, Courses, Videos, Fundamentals specific for JavaScript)


**I would say this will help individuals who are working in JS framework OR looking to move in JS**
Some of the good Cheat Sheet found on internet
Tags: javascript, webdev, beginners, programming
Published: 2022-09-13 12:08:56

**OverAPI**: This cheat sheet for many web programming language such as JS, PHP, Node, CSS etc...
URL: [https://overapi.com/](https://overapi.com/)

**Git Sheet**: Each GIT command explains in detail
URL: [https://gitsheet.wtf/](https://gitsheet.wtf/)

**Developer Cheat sheet**: Contains various cheat sheet like React, ES6 etc...
URL: [http://www.developer-cheatsheets.com/](http://www.developer-cheatsheets.com/)
Roadmap Of Javascript
Tags: javascript, frontend, beginners, programming
Published: 2022-09-13 12:07:30

This road map shows most of the topics related JavaScript, you can also learn one by one each topic by completed the highlighted link and their related lessons.

Road map of JavaScript: [https://learnjavascript.online/knowledge-map.html](https://learnjavascript.online/knowledge-map.html)
2022: Best State management libraries in React JS
Tags: javascript, react, redux
Published: 2022-09-13 12:06:05

As we all know that in react, state management is the way from that we can access the object in entire web & most of the projects and at the time of learning we are using "react-redux" but now we have to use other state management libraries those are more compatible compare to "react-redux"


- Zustand: [https://zustand-demo.pmnd.rs/](https://zustand-demo.pmnd.rs/)

- Recoil: [https://recoiljs.org/](https://recoiljs.org/)

- Hookstate: [https://hookstate.js.org/](https://hookstate.js.org/)

- Redux Toolkit: [https://redux-toolkit.js.org/](https://redux-toolkit.js.org/)


So now I am expecting from you guys that from the next/new projects we are starting to use new state management libraries...

**"Learn continually – there’s always “one more thing” to learn."**
Best Animation Libraries specific in React
Tags: javascript, react
Published: 2022-09-13 12:02:46

Nowadays many frameworks/libraries have come to make you fast in development, according to UI development trending some of the tools are currently frequently used to create isolated components to make development faster.

[https://www.framer.com/motion/](https://www.framer.com/motion/) (Animation effect)

[https://storybook.js.org/docs/react/get-started/introduction](https://storybook.js.org/docs/react/get-started/introduction) (creating components)