teleren/devto huggingface dataset:
Initialize asynchronous data in XUnit Collections for sharing data between tests
Tags: xunit, testing, nunit, iasynclifetime
Published: 2021-02-24 19:49:07

By its design XUnit doesn't like to share data between tests like NUnit. XUnit has created [Collection Fixtures](https://xunit.net/docs/shared-context#collection-fixture) as a method to share data between your tests and test classes. While this approach generally works I found that almost all the test data I needed to share between tests was created asynchronously! We live in an Asynchronous world now.

If you reference the XUnit link above you'll see that they initialize their example *DatabaseFixture* class like so:

```
public class DatabaseFixture : IDisposable
{
    public DatabaseFixture()
    {
        Db = new SqlConnection("MyConnectionString");

        // ... initialize data in the test database ...
    }

    public void Dispose()
    {
        // ... clean up test data from the database ...
    }

    public SqlConnection Db { get; private set; }
}
```
The problem with the above code is that I can't create test data with an async/await call. There is a fairly easy way around this problem that XUnit should really document. You can derive your *DatabaseFixture* class from  *IAsyncLifeTime* to provide asynchronous lifetime functionality for your test data that can be referenced in every test. To do this you create and destroy all of your test data in the InitializeAsync() and DisposeAsync() methods like so:

```
public class DatabaseFixture : IAsyncLifeTime
{
    // ... create your shared vars here
    
    public async Task InitializeAsync()
    {
        // ... initialize data in the test database and/or use async calls here ...
    }

    public async Task DisposeAsync()
    {
        // ... clean up test data from the database with and use async calls here...
    }    
}
```
Now the above code example only replaces the initial class creation from XUnit. You still need to create an XUnit *CollectionDefinition* and *Collection* with all of your tests as per the examples on the XUnit page.

Note that using the **IAsyncLifetime** derived test class is an **excellent opportunity** to create your own classes to store test data. Try creating a a new class file *MyTestData* to store whatever you need. Could be strings, lists, guids, etc. Then under the class section *// ... create your shared vars here* initialize your class object:

```
public List<MyTestData> _testData { get; set; }
```
You now can use *_testData* to store any type of test data you create and share it with all your tests. Pretty darn awesome.
Three Ways to Decode Text in NLP
Tags: python, datascience, deeplearning, machinelearning
Published: 2021-02-24 19:23:20

One of the often-overlooked parts of sequence generation in natural language processing (NLP) is how we select our output tokens — otherwise known as decoding.

You may be thinking — we select a token/word/character based on the probability of each token assigned by our model.

This is half-true — in language-based tasks, we typically build a model which outputs a set of probabilities to an array where each value in that array represents the probability of a specific word/token.

At this point, it might seem logical to select the token with the highest probability? Well, not really — this can create some unforeseen consequences — as we will see soon.

When we are selecting a token in machine-generated text, we have a few alternative methods for performing this decode — and options for modifying the exact behavior too.

In this article we will explore three different methods for selecting our output token, these are:

> Greedy Decoding
> Random Sampling
> Beam Search

It’s pretty important to understand how each of these works — often-times in language applications, the solution to a poor output can be a simple switch between these four methods.

{% medium https://towardsdatascience.com/the-three-decoding-methods-for-nlp-23ca59cb1e9d %}
Flutter+Dart Frontend <-->Golang Backend API
Tags: flutter, go, api, dart
Published: 2021-02-24 19:10:45

In Part-1/2 of this series, we are going to implement a Golang API server that caters to HTTP GET requests from clients. We will create a hypothetical store with products carrying attributes: Name, Price, and Count. A valid HTTP GET request gets a response with a list of products.

In Part-2/2 of this series, we are going to develop a Flutter App that will execute API calls to the server. The fetched data in JSON format from the server will be displayed using ListView. 

{% youtube PCoF1a2cugs %}

{% youtube ezl4w4xDXAo %}

I hope you enjoyed this post. I would appreciate your feedback/suggestions/comments in the comment section below.

Thanks.

### Follow Me :
[YouTube CodeFuture](https://www.youtube.com/channel/UCMat0Hlx67xwLrhIKRWMjEw) , [Twitter](https://twitter.com/Code9Rrr)

### Link to GitHub : 


[Source Code](https://github.com/rrrCode9/FlutterGolangAPI)
How I learnt from Machine Learning Flashcards
Tags: machinelearning, ai, computerscience, datascience
Published: 2021-02-24 19:09:59

So after facing a lot of problem in learning Machine Learning, I started contemplating on how to make the whole learning experience great. Then I came across the concept of Active Recall and Flashcards. So I thought of making Machine Learning Flashcards for our personal use. 

But soon I found that the problem I was trying to solve is a very common problem among students and learners. So I thought of creating this ML flashcards product for our fellow students in universities and anyone else who is trying to learn Machine Learning.

Last week Me and Ankit wrapped it's preparation. We created the first set of ML Flashcards. We also finished building the website, sorted out the hosting and started running it. After this we enabled pre-orders on the product page for the early birds and also rolled out discount coupons for them.

And I am ecstatic to say that we got our first 50 paying customer. A total of 5k views on our product page with less that 40% bounce rate according to google analytics. We have our first few buyers from Spain, USA and India.

Out product got featured on the Product hunt and received a positive feedback from the Product Hunt community. We also received 20 sales through Product Hunt as well. We are using the community to get honest feedback on our product and make sure we keep improving.

If you have started learning machine learning and want some something that help you memorize the concept then this is for you!!


![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hrahn1q5orqvb36jkyj5.png)

Check:  mlcards.xpertup.com


These are deck of flashcards with basic machine learning concepts to help you learn and revise fast and efficiently using one of the most scientific ways to learn, i.e ACTIVE RECALL.


Topics Covered in Flashcards:
-----------------------------
1. AI vs Machine Learning vs Supervised Learning vs Unsupervised Learning vs Reinforcement Learning
2. Machine Learning Pipeline
3. Supervised Learning Flow
4. Unsupervised Learning Flow
5. Reinforcement Learning Flow
6. Linear Regression
7. Logistic Regression
8. Support Vector Machine
9. KNN Classifier
10. Naive Bayes Classifier
11. Decision Tree 
12. Random Forest
13. Ensemble Method
14. K-Means Clustering
15. Perceptron
16. Activation Function
17. Model Fitting
18. Bias and Variance
19. Bias-Variance Tradeoff
20. Data Splitting
21. K-Fold Validation
22. Data Augmentation
23. L1 / L2 Regularization
24. Principal Component Analysis
25. Confusion Matrix

Download it now from mlcards.xpertup.com


Hope these ML Flashcards will be helpful for you as well. Do let me know your feedback so that we can improve our next version.
5 Awesome Navigation Bar Design | Rustcode
Tags: codepen, webdev, html, css
Published: 2021-02-24 18:25:22

![5 Awesome Navigation Bar Design](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77sy82sz8bnfca0aaft3.jpg)

## 1. One Page Navigation Css Menu
{% codepen https://codepen.io/uiswarup/pen/NPZKRN %}

## 2. Offcanvas Sidebar Menu With A Twist
{% codepen https://codepen.io/uiswarup/pen/LERvpM %}

## 3. Circle Menu
{% codepen https://codepen.io/uiswarup/pen/vLoyOb %}

## 4. Fullscreen Flexbox Overlay Navigation
{% codepen https://codepen.io/uiswarup/pen/gPWxXJ %}

## 5. menu with awesome hover
{% codepen https://codepen.io/uiswarup/pen/dyyqaGR %}

If you want more article related to web development please go to [RustcodeWeb](https://rustcodeweb.blogspot.com/).
Type error in python
Tags: python
Published: 2021-02-24 18:23:24

in python, You can not concatenate two types of data.
suppose you are want to concatenate an integer value to a string value.
string = "hello earth"
number = 404
print(string + 'how are you' + 'your server error number is' + number)
the result will be a type error

now, you think about how to concatenate different types of data !!
in python, have a simple way to solve this problem.
you can solve this problem by converting the data.
suppose, you have two types of data number and string
number = 14644
string = 'anything'
convert_number_as_a_string = str(number) //converting number to string by str method.
print('hey number' + number + 'hey string' + string) //wow it's work now

but I think this is the weird way.
there has another easiest way to solve this problem.
 f-string can solve this problem 

number = 11544
string = 'anything'
result = f"its number {number}. its string {string}" 
print(result)

woow..it's work.
can't believe it?
just open your code editor or ide and try this / practicing this.

this is my first post in dev. pardon me, if I did any mistake.
note -- English is not my native language so normally you've could get a grammatical error. 

tanks for reading..
React - create simple animated progress bar
Tags: react, webdev, javascript, tutorial
Published: 2021-02-24 18:18:21

Hello! 👋 😊

Today I want to show you a simple animated progress bar that I recently made in React.

Before we start, I would highly recommend you to check out runnable example for the solution on our website:
[React - create simple animated progress bar](https://dirask.com/posts/jMmZaj)

Final effect of this post:
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ga60kt6deqmfvkcz9v9h.png)


Below I present you my solution for a simple progress bar with some styling 📊🎨. 

In this solution I use:

- `useState` hook to store the progress bar's state,
- content `width` measured in percents according to the container - that trick lets us display progress from 0% to 100% in an easy way,
- some example buttons that trigger `setProgress()` method to demonstrate how the progress bar works (animation between switching has a nice effect).

Practical example:
```jsx
import React from 'react';

const containerStyle = {
  	border: '1px solid silver',
  	background: '#ededed'
};

const contentStyle = {
  	background: '#00cc00',
  	height: '24px',
  	textAlign: 'center',
  	lineHeight: '24px',
  	fontFamily: 'sans-serif',
  	transition: '0.3s'
};

const ProgressBar = ({progress}) => {
  	const state = `${progress}%`;
    return (
      <div style={containerStyle}>
        <div style={{...contentStyle, width: state}}>
          {progress > 5 ? state : ''}
        </div>
      </div>
    );
};

const App = () => {
  const [progress, setProgress] = React.useState(25);
  return (
    <div>
      <ProgressBar progress={progress} />
      <br />
      <div>
        <button onClick={() => setProgress(0)}>0%</button>
        <button onClick={() => setProgress(5)}>5%</button>
        <button onClick={() => setProgress(15)}>15%</button>
        <button onClick={() => setProgress(50)}>50%</button>
        <button onClick={() => setProgress(75)}>75%</button>
        <button onClick={() => setProgress(100)}>100%</button>
      </div>
    </div>
  );
};

export default App;
```
You can run this example [here](https://dirask.com/posts/jMmZaj)

Let me know what you think in the comment section! 😊💬
_____________
## Write to us! ✉
If you have any problem to solve or questions that no one can answer related to a React or JavaScript topic, or you're looking for a mentoring write to us on [dirask.com -> Questions](https://dirask.com/questions)
Welcome Thread - v113
Tags: welcome
Published: 2021-02-24 18:09:35

---
title: Welcome Thread - v113
published: true
description: Welcome to DEV! A thread of hellos and intros.
tags: welcome
canonical_url: 
---

![Oh hi](https://media.giphy.com/media/dVA9c3Ey7rCr6/giphy.gif)

### Welcome to DEV!

1. Leave a comment below to introduce yourself! You can talk about what brought you here, what you're learning, or just a fun fact about yourself.

2. Reply to someone's comment, either with a question or just a hello. 👋 

**Great to have you in the community!**
Hosting GitLab with Reclaim Cloud
Published: 2021-02-24 18:07:02

Git is an interesting thing -- when most people think about git, they associate it with GitHub, and I can't really fault them for that, since it's the service that made git so popular amongst developers. But fewer people know that you can actually host your own git server yourself -- one that doesn't rely on a commercial service like GitHub to store your code for you.

I set out to host my own GitLab instance to figure out what the hype was all about. Would it really be that much better to host my own git server? Would the benefits of doing so outweigh the benefits of keeping all my code on GitHub and possibly having GitHub go down and lose all my git repositories? I was about to find out.

I initially tried to host GitLab on my personal server - a Dell Poweredge server I keep under my bed with a 12-core Xeon and 128 gigs of RAM - because of my tendency to avoid paying for cloud services where possible. However, after 12 hours of struggling to get GitLab working over two days, I called it quits and coughed up the $50 for Reclaim Hosting and Reclaim Cloud accounts -- I hope they're paying you a commission for getting us to pay them, Professor Ollendyke. 

I used the domain name I once registered and have since kept ahold of - penst.at - to get my own custom GitLab server set up. Reclaim Cloud did most of the deployment work for me, with me just sitting around bored most of the time other than making it provision custom SSL certs for me and making sure the docker containers didn't have any catastrophic failures. In the end, I was left with a shiny new GitLab instance - albeit on an ugly port 4848 (why can't they be normal and use normal ports?) - and began by pushing the CMPSC 132 code I use to tutor people onto the GitLab instance. I was quickly able to create and configure a repository and push all the files to it, and I realized that GitLab is pretty cool indeed.

I quickly make the repo private - no academic integrity issues please - and began exploring the rest of GitLab. It's really a cool service - I might have to keep this instance up and keep playing with it. It bears further investigation when I'm not busy trying to deploy Grav this week and use HAXcms and moar-sarcasm - stay tuned for a post on that, I guess.

Oh, and watch my video, please thanks: https://youtu.be/W8Xw49orW-Q
Introducing: Glitter!
Tags: github, git, rust
Published: 2021-02-24 17:33:25

Hey folks! I've been hard at work programming my first commercial package. 

This package is called `glitter`. A hyper-fast way of executing git commands.

Currently, glitter is available on Scoop. Install it with `scoop install glitter`, or, clone the repo and run `cargo install --path .` to install it.

## So what is glitter?

Glitter is the git-companion you've longed for. Fast, efficient, written in Rust and super friendly errors. What more could you need in a friend? 😃

## But.. how do I use it?

The config lives in a file called a `.glitterrc` (this is customisable!) and is a simple JSON structure. See all available keys [here](https://github.com/Milo123459/glitter/blob/master/docs/index.md).

If you have a question, please don't hesitate to make a discussion on the [repo](https://github.com/Milo123459/glitter)

Let me know of some feedback in the comments, hope you have a great day!
Stocking A 5 Gallon Starter For Betta Fish
Published: 2021-02-24 17:29:22

At your house, betta fish go after commercial betta pellets composed of wheat flour, fish meal, mashed shrimp meal, bloodworms, shrimp, and vitamins. In addition to this, your fish can eat daphnia, brine shrimp, mosquito larvae, and frozen or live bloodworms.

Because Bettas can be shy, they appreciate floating plants, which might be purchased at most of the local fish shops. These will help to block some in the light and provide shady areas. Generally speaking, dimmer lighting tends to make more calm and fewer stressed out fish. As such, the lowest wattage light bulb must be used for lighting the betta tank [betta fish for sale](https://bettafish.top). Keep the tank's light on for eight or less hours every day. A timer might help achieve this.

Avoid putting your fish bowl in sunshine or nearby the vents inside a room which could change the temperature of water higher or lower. Putting them in sunshine can freak out the Bettas.

A small filter is better used to assist in keeping the water clean. A very small Aquaclear or equivalent power filter on its lowest flow setting is adequate. As mentioned, Bettas aren't particularly strong swimmers because of their long, droopy fins. As such, Betta tanks should only have minimul water movement, and also the flow from the filter will probably be enough to keep the water oxygenated. In a smaller bowl, a filter may 't be possible, whereby the smallest available air pump with air stone can be employed to keep a bit of water movement but is not a complete requirement. A small heater of 50 watts is usually recommended as well, as the river temperature should be kept around 75 degrees fahrenheit roughly. That's right, whilst they are sold in cups without any heaters, Bettas must be kept in heated water.

10. Although it is possible to't keep two or male Bettas together, you can however put one male Betta by female Bettas but sometimes you will need to be careful as well, because this can also attack other female Bettas together.
Systemd Timers as a Cron Alternative
Tags: systemd, linux, systems
Published: 2021-02-24 17:01:28

Today I want to write about Systemd timers, I recently had to convert sketchy `While True` scripts to systemd timers, and the performance improvement was a huge plus point.

Yes I get it people hate systemd, it may not be perfect but it definitely works for this particular use case. It is however, quite intimidating at first since there are so many options, and you also need to create two files per use-case.

So let me break it down, You need to create a *service file* and a *timer file*, you can also use template files, however that is out of the scope of this article.

So let's get started.

First, open up your terminal or text editor and paste.
```
[Unit]
Description=Runs a command and logs to journalctl
Wants=randomprogram.timer

[Service]
Type=oneshot
ExecStart=python -c 'print("Hello world")'

[Install]
WantedBy=multi-user.target
```
Save this file in `/etc/systemd/system/randomprogram.service`
Lets break this down
* Description - This contains generic information
* `Wants=randomprogram.timer` - As per the Systemd manual, units listed in this option will be started if the configuring unit is
basically if you start the service with `systemctl start randomprogram.service` the timer will also be started.
* `Type=oneshot` - There are a lot of different types you can specify here(simple, exec, forking, oneshot, dbus, notify or idle). Reading `man systemd.service` would be far better here.
* `WantedBy=multi-user.target` - This is equivalent to runlevel 2 in sysvinit.


After we finish this, its now time to create a timer service. Save this file in `/etc/systemd/system/randomprogram.timer`
```
[Unit]
Description=Runs timer program systemd journal
After=httpd.service
Requires=randomprogram.service

[Timer]
Unit=randomprogram.service
#OnCalendar=*-*-* *:*:12
OnUnitActiveSec=12s
AccuracySec=1us

[Install]
WantedBy=timers.target
```

Lets break this down again. I'll take the new options.

* `After=httpd.service` - Start the timer after httpd.service this was for my use case
* `Requires=randomprogram.service` - If this unit gets activated, the units listed will be activated as well.
* `OnCalendar=*-*-* *:*:12` - The format for this is
_DayOfWeek Year-Month-Day Hour:Minute:Second_ where DayOfWeek can be omitted, this will run at the 12th second for every minute(like cron), however the dev's here needed it to run every 12 seconds.
* `OnUnitActiveSec=12s` - Defines a timer relative to when the unit the timer unit is activating was last activated.
* `AccuracySec=1us` - Specify the accuracy the timer shall elapse with. Defaults to 1min(we needed high accuracy too...)

A detailed documentation on Systemd Timers is present [here](https://wiki.archlinux.org/index.php/Systemd/Timers)

And now `systemctl start randomprogram.timer` 
![Journalctl logs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrfnofzfnp2565f4igyl.png)

That's it folks, I'm pretty sure there are a lot of things you can do with systemd, but I'm still learning and there is a lot of things I still don't know. So feel free to drop a comment about this post.
What are some things you wish you had known when you started learning Rust?
Tags: discuss, rust, beginners
Published: 2021-02-24 16:56:17

Hello!
I am giving a talk at my college to introduce Rust to some people. Most of them have not used it or even heard of it,  so it is aimed to cover only the basic introduction of Rust.

I would like to know your opinions on the following, so I can try and make the introduction better for them.

* What similarity/ies did you find in Rust and some other language you know ?
* What are some features of Rust you wish you had known / had more emphasis, when you started learning Rust? (good or bad)

For me, I wish I knew how expressible and powerful match expressions can be. Even though I knew match expressions, it took some time before I really grasped how much powerful and expressive they can be, combined with Enums or ranges.

I also wish I had learnt threading with a bit more emphasis, I know one of the goals of Rust is to make Secure multi-threading easier, but I wish I had seen some more examples of really how much Rust makes it simple to introduce multi-threading as well as make sure its correct/you don't shoot yourself in foot.

So, please share your thoughts if possible, in the comments.
Thank you! :)
The most useful VS Code extensions for web developers
Tags: webdev, programming, discuss, vscode
Published: 2021-02-24 16:51:45

How are you, web devs? Is everything all right? I suggest you look at my list of useful extensions for productive development.


### 1. [Auto Rename Tag](https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag)
Many code editors have their advantages. For example, WebStorm automatically renames paired tags. Unfortunately, VS Code does not have such a feature.
- **Downloads: 4713000+**

### 2. [Bracket Pair Colorizer 2](https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2)
This extension allows matching brackets to be identified with colours. The user can define which characters to match, and which colours to use.
- **Downloads: 2141000+**

### 3. [JavaScript (ES6) code snippets](https://marketplace.visualstudio.com/items?itemName=xabikos.JavaScriptSnippets)
The most useful extension for frontend developers. It has a lot of truly needed snippets. The full list is available on the extension page.
- **Downloads: 4900000+**

### 4. [Live Server](https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer)
Allows you to automatically view changes on the page after saving. You do not need to update the page separately.
- **Downloads: 10041000+**

### 5. [Snippet Creator](https://marketplace.visualstudio.com/items?itemName=ryanolsonx.snippet-creator)
Quickly create a snippet. While creating, it auto-detects which language you're using.
- **Downloads: 6600+**

<br>
Here is my own list of extensions that I use. Like and comment and follow my [Github](https://github.com/Ra1nbow1) <3