teleren/devto huggingface dataset:
How to write unit test in jest.
Published: 2022-12-03 18:02:32

In this post I will show nice way to create unit test in jest.js. 

##Create test file first and describe all possible scenarios. 

In this case we have 3 scenarios. We just describe how the test looks like without any knowledge about our function.

```javascript
import { short } from "./short";

describe("short", () => {
  test("If array length < 3 should return array without modification", () => {
    const result = short(["1", "2"]);
    expect(result).toBe(result);
  });

  test("If array length > 3 Should return just first 3 elements of an array if there is no 2nd argument", () => {
    const result = short(["1", "2", "3", "4"]);
    expect(result).toBe(["1", "2", "3"]);
  });

  test("Should consider 2nd argument as a number which describe how long an array could be", () => {
    const result = short(["1", "2", "3", "4"], 2);
    expect(result).toBe(["1", "2"]);
  });
});

```

##Create function that will cover the tests scenarios.

Right now we can create function remembering about the tests we previously described. 

```javascript
const short = (array, number) => {
  if (number) return array.splice(0, number);

  return array.length < 3 ? array : array.splice(0, 3);
};

export default short;
```
One day code challenge
Tags: python, beginners, showdev
Published: 2022-12-03 17:51:42

I decided to set myself a one day code challenge to see if I could re-create a game and chose Quiddler, which is one of my all time favorite word games. 

If you’d like to read about it, here’s the wiki page: https://en.wikipedia.org/wiki/Quiddler

I decided I wanted a shorter game for my version, since there could be up to ten copies of the same card in the original card game and also got rid of the cards with two letters on them, such as “er” along any rules around additional players since my version would be single player.

I settled on 10 rounds, with an automatic 50 point bonus if you used all the letters in your hand. You start with one vowel, one consonant, and one random card. The random cards are twice as likely to be a consonant over a vowel, but are entirely random and you receive a new one each turn.

By far the largest issue I ran into was that Python didn’t seem to have an importable complete English dictionary. The closest I could find, Enchant, did not work on my version of VS Code but did work on Replit (after a 10 second updating delay).

Is Enchant a complete dictionary? No, words like “fake” and “mutt” don’t seem to be recognized, but in testing it, enough words were accepted that I continued on. The final product is a short spelling game I hope you enjoy.

Link to code: https://github.com/Meg-Div/DigitalCraftsProjects/tree/main/spelling-game

Link to game: https://replit.com/@Meg-Div/quiddler#main.py
AZ-400: Configure and manage repositories
Published: 2022-12-03 17:17:04

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Integrate GitHub repositories with Azure Pipelines, one of the services in Azure DevOps
- Configure permissions in the source control repository 
- Configure tags to organize the source control repository
- Recover data by using Git commands
- Purge data from source control
AZ-400: Plan and implement branching strategies for source code
Published: 2022-12-03 17:13:00

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Design a branch strategy, including trunk-based, feature branch, and release branch
- Design and implement a pull request workflow by using branch policies and branch protections
- Implement branch merging restrictions by using branch policies and branch protections
AZ-400: Design and implement a source control strategy
Published: 2022-12-03 17:09:13

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Design and implement an authentication strategy
- Design a strategy for managing large files, including Git LFS and git-fat
- Design a strategy for scaling and optimizing a Git repository, including Scalar and cross-repository sharing
- Implement workflow hooks
ChatGPT is taking over the world by this.
Tags: ai, webdev, machinelearning, api
Published: 2022-12-03 17:05:39

OpenAI is a research institute focused on developing artificial intelligence in a safe and responsible manner. It was founded by Elon Musk, Sam Altman, and other prominent figures in the tech industry with the goal of advancing the field of AI and ensuring that it is used for the benefit of all humanity. OpenAI is known for its work on developing advanced AI algorithms, including GPT-3, which is one of the largest and most powerful language processing models in the world.

## What is Chat GPT
It is a trained chatbot that has conversational interactions. According to OpenAI, the dialog format enables ChatGPT to respond to follow-up queries, acknowledge its errors, refute false premises, and reject inappropriate requests.

It is claimed that it can respond to all types of writing, including theoretical essays, mathematical solutions, and stories.

## What I asked to Chat GPT
Explain me machine learning in simple words.

![chat gpt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8r9paodn4dbsex1q7vs5.png)

Would it be possible for humans to stay on Mars?


![chat gpt](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e7o2u8dmxmdimhoei0eo.png)

It was fun talking to the chat gpt about various topics.

So it was a quick short blog about my experience with chat gpt.

If you liked it, share it with a friend.
See you.
AZ-400: Configure collaboration and communication
Published: 2022-12-03 17:05:02

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Communicate actionable information by using custom dashboards in Azure DevOps
- Document a project by using tools, such as wikis and process diagrams
- Configure release documentation, including release notes and API documentation
- Automate creation of documentation from Git history
- Configure notifications by using webhooks
AZ-400: Configure activity traceability and flow of work
Published: 2022-12-03 17:01:50

[Return to Exam Guide](https://dev.to/aidutcher/azure-devops-az-400-study-guide-exam-guide-outline-17dm)

- Plan and implement a structure for the flow of work and feedback cycles
- Identify appropriate metrics related to flow of work, such as cycle times, time to recovery, and lead time
- Integrate pipelines with work item tracking tools, such as Azure DevOps and GitHub
- Implement traceability policies decided by development
- Integrate a repository with Azure Boards
Singly Linked List Series: Creating shift() and unshift() methods with JavaScript
Published: 2022-12-03 16:55:40

While continuing to learn data structures and algorithms, I want to continue to share my understanding in case others find it helpful.  Today, I want to share how to create shift() and unshift() methods.  A shift() method removes the first node from the beginning of a Singly Linked List.  Here is my visualization for creating  a shift() method:

![steps to create a shift method](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/z91h3xp2f3r9epz5sbmq.png)

Edge case: you can account for an empty list.  If it is not empty, then follow the steps mentioned above.  A second edge case is to redefine the head and tail if the list becomes empty after multiple shift() method applications.

Here is an example of code for a shift() method:

![image of shift method code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2j3iudqludjyl3fx5y9.png)

An unshift method adds a node to the beginning of a Singly Linked List.  Here is my visualization for creating an unshift() method:

![steps to create an unshift method](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gzy48vk11z4be00uzzd2.png)
![steps to create an unshift method continued](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/opccqpj8s7p41h9qc6nw.png)

Edge case: you can account for an empty list.  If the list is not empty then follow the steps mentioned above.

Here is an example of code for an unshift() method:

![image of unshift method code](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g06elk77wimm8nh9clxg.png)

The time complexity of shift() and unshift() methods for a Singly Linked List is O(1).  No matter the length of the list, it takes the same number of steps to remove from the beginning or add to the beginning of the list.

In the next part of this series, I will share what I have learned about creating a get() method to grab a chosen node, and a set() method to change the value of a chosen node.
Simple steps to publish nuget package
Published: 2022-12-03 16:39:21

TL;DR;

### Create and publish nuget package through dotnet cli ###

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



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



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

### Publish nuget package through GITHUB Actions ###

```
name: Publish nuget package

on:
  push:
    branches: ["main"]
  workflow_dispatch:
  
permissions:
  contents: read

jobs:
    build:
      runs-on: windows-latest
      
      steps:
        - uses: actions/checkout@v3
        
        - name: Setup .NET core
          uses: actions/setup-dotnet@v2
          with:
            dotnet-version: 6.0.*
            
        - name: Build application
          run: dotnet build SecurityCode.Validator --configuration release
          
        - name: package
          run: dotnet pack SecurityCode.Validator --configuration release --output package
          
        - name: publish
          run: dotnet nuget push package\*.nupkg --api-key ${{secrets.NUGET_KEY}} --source https://api.nuget.org/v3/index.json 
            
        
      

```

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


Happy Coding!!!
VSCode: my 5 vital extensions to be productive
Tags: vscode, productivity, webdev, javascript
Published: 2022-12-03 15:55:13

Hi 👋 today I want to share with you 5 extensions that are vital in my daily job.

> I don't like too complex configurations, I like the idea of ​​being able to be productive in any environment and with the standard configuration, but for these 5 VSCode extensions, I made an exception.

### [Import cost](https://marketplace.visualstudio.com/items?itemName=wix.vscode-import-cost)

![ImportCost](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7lgcqz2ydfb3bqtdk4qh.png)

#### In action

![ImportCostFlow](https://citw.dev/_next/image?url=%2fposts%2fimport-cost%2f1quov3TFpgG2ur7myCLGtsA.gif&w=1080&q=75)

Thanks to this plugin I can immediately see how much an import costs me and keep my bundle size under control.

### [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode)

![Prettier](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9h85qerbj7lg2br6n6bj.png)

#### In action

![PrettierInAction](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g94upwd6ixw6ie66krhe.gif)

Prettier is a code formatter that enforces a uniform style, if you have multiple people working on a single project, this is definitely a must have.

### [Peacock](https://marketplace.visualstudio.com/items?itemName=johnpapa.vscode-peacock)

![Peacock](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0pcybqnd5avzl9zvdxja.png)

#### In action

![PeacockInAction](https://raw.githubusercontent.com/johnpapa/vscode-peacock/main/resources/hero.png)

Peacock lets you change the color of your Visual Studio Code environment. You can set a different color for each project to quickly identify which application you're working on.

### [Version Lens](https://marketplace.visualstudio.com/items?itemName=pflannery.vscode-versionlens)

![Vlens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5kbqb44lhlav5s88ql1a.png)

#### In action

![VLensInAction](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n7c8icp70ttsednuha12.gif)

This extension displays information by reading package.json and allows you to update dependencies.

### [GitLens](https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens)

![GitLens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lq1pzunvqbzuzgg6tqxs.png)

I find this extension very useful and _line blame annotation_ feature is really useful in my daily job.

![blame](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ooa2ff01ek1nnghjx95z.png)

😂 Fun fact:
It happens that I'm looking for a piece of code to fix and I see that I'm the author of the problem 😅 😂

![meme](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/zirktpdzcor5ziw3tgtj.png)

---

I am very curious about your favorite extensions, you can make my day with yours. 🚀

You can [follow me on Twitter](https://twitter.com/giorgio_boa), where I'm posting or retweeting interesting articles.

I hope you enjoyed this article, don't forget to give ❤️.
Bye 👋

{% embed https://dev.to/gioboa %}
Help with open graph previews
Tags: help
Published: 2022-12-03 16:25:24

Hey there,

Just a qq if anyone can help. I am looking to build a simple html/css/js one pager and I'd like to embed open graph previews for other sites in it.

Similar to what Forem are [doing here](https://discover.forem.com/) - (these cards are dynamic and update if the original meta tags update)

Anyone have any code examples?

Thanks!
Tailwind CSS tutorial #26: Text Decoration
Tags: webdev, tailwindcss, tutorial, beginners
Published: 2022-12-03 13:54:55

In the article, we will go into detail on how to use `Text Decoration`.

## Text Decoration
**Format**
> `text-decoration-line-{underline|overline|line-through|no-underline}`

| Tailwind Class | CSS Property |
| ------ | ------ |
| `	underline` | ` text-decoration-line: underline;`|
| `	overline` | ` text-decoration-line: overline;`|
| `	line-through	` | ` text-decoration-line: line-through	;`|
| `no-underline		` | ` text-decoration-line: no-underline;`|

Control how text is decorated with the `underline`, `no-underline`, and` line-through` utilities.

## **Code**
```html
 <ul class="container mx-auto divide-y divide-gray-400 divide-dotted" style="font-family: Raleway">
  <li class="flex items-center justify-between px-4 py-2">
    <ul class="underline">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">underline	</div>
  </li>
  <li class="flex items-center justify-between px-4 py-2">
    <ul class=" overline	">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">overline	</div>
  </li>
    <li class="flex items-center justify-between px-4 py-2">
    <ul class=" line-through		">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">line-through		</div>
  </li>
    <li class="flex items-center justify-between px-4 py-2">
    <ul class=" no-underline		">
    <li>Now this is a story all about how, my life got flipped-turned upside down</li>
    </ul>
    <div class="text-xs font-semibold font-mono whitespace-nowrap px-2 py-1 ml-5 rounded text-white bg-pink-500 rounded-2">no-underline		</div>
  </li>
</ul> 
```
**Full code:**
The overall code will be attached to [repo ](https://github.com/codewithshubhi/learn-tailwind-css/blob/main/Text%20Decoration.html)link.

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

**Resources:**
[tailwind.css](https://tailwindcss.com/docs)

Thank you for reading :), To learn more, check out my blogs on [Flex Direction](https://dev.to/shubhicodes/tailwind-css-tutorial-13-flex-direction-i8j), [Hackathons](https://dev.to/shubhicodes/all-about-hackathons-how-to-find-participate-win-42kk) and [Flex Wrap](https://dev.to/shubhicodes/tailwind-css-tutorial-14-flex-wrap-kee).
If you liked this article, consider following me on [Dev.to](https://dev.to/shubhicodes) for my latest publications. You can reach me on [Twitter](https://twitter.com/heyShubhi).

Keep learning! Keep coding!! 💛
Bootcamp: Securing multiparty AI Computation using Conclave SDK
Tags: tutorial, ai, machinelearning, eventsinyourcity
Published: 2022-12-03 15:52:11

Join [R3 Developers](https://developer.r3.com/) to learn how to train a machine learning model without revealing the training data. We will introduce how [Conclave](https://www.conclave.net/) leverages TEE to secure the Training of an AI model. Register for the free Bootcamp [here](https://us06web.zoom.us/webinar/register/WN_hRPEE-OwQeC7mIlre_ql8A).
I passed the CPACC exam
Tags: a11y, career, certificate
Published: 2022-12-03 15:44:02

More than month ago, on October 12, I did the CPACC exam. A few days ago I got the notification that I passed 🥳.

![CPACC badge for successfully passing the exam](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/alfo43pijyzp1jbt8kfv.jpeg)

I am super proud of it. One step closer to become an experienced accessibility developer.

**What‘s next?**

There are two more certificates from [IAAP](https://www.accessibilityassociation.org/s/) which would be interesting and useful in order to work in the field of web accessibility:

- [ADS](https://www.accessibilityassociation.org/s/accessible-document-specialist), to gain knowledge on how to create accessible documents, like word, PDF and epubs, as well as
- [WAS](https://www.accessibilityassociation.org/s/wascertification), which stands for web accessibility specialist, where you have to show experience in creating accessible JavaScript components and how to use screen reader on windows and MacOS.

> These will be my goals for 2023. 😎
Micro frontends
Tags: frontend
Published: 2022-12-03 15:25:01

_**Micro frontends**_ is a software architecture approach that aims to decompose a large, _**monolithic frontend application**_ into smaller, independent components that can be developed, tested, and deployed independently. This approach is similar to the concept of microservices, which decomposes a large, monolithic backend application into smaller, independent services.

One of the main motivations for using _**micro frontends**_ is to improve the maintainability and scalability of frontend applications. <u>By breaking a large frontend application into smaller components, teams can work on different parts of the application in parallel, reducing dependencies and improving collaboration.</u> This can also make it easier to add new features and make changes to the application, as teams can work on individual components without affecting the rest of the application.

Another benefit of micro frontends is that it allows teams to use **_different technologies and frameworks for different components_**. For example, a team working on a user profile component may choose to use React, while a team working on a checkout component may choose to use Angular. This can be beneficial because it allows teams to use the tools and frameworks that are best suited for their specific tasks, rather than being limited to a single technology stack.

Micro frontends also have some challenges and drawbacks. One of the main challenges is coordinating the different components and ensuring that they work together seamlessly. This can require additional effort and coordination, as teams need to ensure that their components are compatible and can communicate with each other.
Day 3 v2: GitHub Action CI for wsblib Python
Tags: python, opensource, beginners, programming
Published: 2022-12-03 10:32:00

---
title: Day 3 v2: GitHub Action CI for wsblib Python
published: true
description: This time it worked
tags: python, opensource, beginners, programming
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
published_at: 2022-12-03 10:32 +0000
canonical_url: https://code-maven.com/github-actions-ci-for-python-wsblib
series: ci-2022-12
---

After the failure to create GitHub configuration for farmworld
I did not know if I should call it a day or try to find something else where I manage to set up GitHub Actions. I went back to [PyDigger](https://pydigger.com/search/has-github-no-ci) and found the [wsblib](https://github.com/firlast/wsblib) Python package where the name stands for **Web Server Base Library**.

It had some tests in the `tests/` folder.

After looking at the test files I saw that they are using [BuPyTest](https://pypi.org/project/bupytest/).
I have not hear about it. I saw that both files were prepared to be executed directly using the following:

```python
if __name__ == '__main__':
    bupytest.this()
```

so I went on running them as `python tests/test_server.py`.

Later, when I went and looked at the [documentation of BuPyTest](https://github.com/jaedsonpys/bupytest/blob/master/README.md) and saw that it can be also used as a command-line tool.

## Stages

First I only configured the CI to run on Ubuntu using Python 3.11.


Then I extended it to run the tests on all 3 operating systems and 3 different versions of Python. That's when I found out that one of the test files consistently fails on Windows and OSX. So I configured the CI that on of the tests files will always run and the other one only when the operating system is Ubuntu Linux.

Finally I switched from running the tests with `python` to running them using `bupytest`.

## GitHub Actions configuration file

This is the most recent version of the file:

```yaml
name: CI

on:
  push:
  pull_request:
  workflow_dispatch:
  schedule:
    - cron: '42 5 * * *'

jobs:
  build:
    strategy:
      fail-fast: false
      matrix:
        runner: [ubuntu-latest, macos-latest, windows-latest]
        python-version: ["3.9", "3.10", "3.11"]

    runs-on: ${{matrix.runner}}
    name: OS ${{matrix.runner}} Python ${{matrix.python-version}}

    steps:
    - name: Checkout
      uses: actions/checkout@v3

    - name: Set up Python ${{ matrix.python-version }}
      uses: actions/setup-python@v4
      with:
        python-version: ${{ matrix.python-version }}

    - name: Install dependencies
      run: |
        pip install -r requirements.txt

    - name: Run tests on every platform
      run: |
        bupytest test  tests/test_server.py

    - name: Run tests only on Linux
      if:  ${{ failure() && matrix.runner == 'ubuntu-latest' }}
      run: |
        bupytest test tests/test_socket.py
```
## Conclusion

Sometimes it is simple to set up GitHub Actions, even with testing frameworks that I don't know yet.