teleren/devto huggingface dataset:
Testing yassgy
Tags: osd600
Published: 2021-11-14 17:01:51

For this post, I would like to talk about testing yassgy (and how difficult it is...).

I have implement very small test cases on a very small part of `yassgy`. Since `yassgy` currently is untestable, and I noticed that refactoring it would a major task, I decided to focus on a really small function of `yassgy`, testing whether a file path refers to a text file.

I used the built-in testing features included in [`cargo`](https://github.com/rust-lang/cargo), by using the `cfg` attribute and prefixing my test functions with the `test` attribute.

For example, let us say we have a file called `complex.rs`, that defines a structure for a complex number:

```rs
#[derive(Debug, Eq)]
struct Complex {
  real: f64,
  imaginary: f64
}

impl Complex {
  fn add(self, rhs: Complex) -> Complex {
    Complex {
      real: self.real + rhs.real,
      imaginary: self.imaginary + rhs.imaginary,
    }
  }
}

impl Add for Complex {
  type Output = Self;

  fn add(self, other: Self) -> Self {
    self.add(other)
  }
}
```

If I wanted to test this structure, I can simply write the following in the same file:

```rs
struct Complex {
} 

// snip

#[cfg(test)]
mod tests {
  use super::*;

  #[test]
  fn add_two_complex_numbers() {
    let a = Complex { real: 1.0, imaginary: 1.0 };
    let b = Complex { real: 1.5, imaginary: 2.3 };
    let expected = Complex { real: 2.5, imaginary: 3.3 };
    assert_eq!(a + b, expected);
  }
}
```

And thus, we have implemented the first test case!
This test case can be easily run in the command line with `cargo test`.

We can also implement a second test case, where we test the subtraction of two complex numbers, and, because we are not supporting a `Sub` operation, the test case would fail!

## Test cases for `yassgy`

The test cases for `yassgy` were pretty simple, focused on the function that tests whether a file path refers to a text file.

Writing a few test cases helped me to realize test cases define a specification of your program, and they count in some way as documentation of your program. Thus, testing provide several benefits that outweigh the maintenance costs of the code.
Best Coding Resources
Tags: codenewbie, tutorial, beginners, programming
Published: 2021-11-14 15:55:17

### E-Learning Websites

- [W3School](https://www.w3schools.com/)

- [freeCodeCamp](https://www.freecodecamp.org/)

- [GeeksforGeeks](https://www.geeksforgeeks.org/)

- [Udacity](https://www.udacity.com/)

- [Udemy, Inc.](https://www.udemy.com/)

- [Codecademy](https://www.codecademy.com/)

- [Coursera](https://www.coursera.org/)

- [Khan Academy](https://www.khanacademy.org/)

- [edX](https://www.edx.org/)

### Q/A Websites

- [Stack Overflow](https://stackoverflow.com/)

- [Quora](https://www.quora.com/)

- [Reddit](https://www.reddit.com/)

- [CodeProject](https://www.codeproject.com/)

- [Programmers Heaven](https://programmersheaven.com/)

- [Coderanch](https://coderanch.com/)

- [FindNerd](https://findnerd.com/)

- [Chegg](https://www.chegg.com/)

### Challenge Websites

- [Codewars](https://www.codewars.com/)

- [HackerRank](https://www.hackerrank.com/)

- [Topcoder](https://www.topcoder.com/)

- [Coderbyte](https://coderbyte.com/)

- [HackerEarth](https://www.hackerearth.com/)

- [Leetcode](https://leetcode.com/)

- [CodeChef](https://www.codechef.com/)

- [CodinGame](https://www.codingame.com/)

- [Edabit](https://edabit.com/)

- [Codeforces](https://codeforces.com/)

- [SPOJ](https://www.spoj.com/)

### YouTube Channels

- [Derek Banas](https://www.youtube.com/c/derekbanas)

- [The Net Ninja](https://www.youtube.com/c/TheNetNinja)

- [Programming with Mosh](https://www.youtube.com/c/programmingwithmosh)

- [Code with Harry](https://www.youtube.com/c/CodeWithHarry)

- [Neuralnine](https://www.youtube.com/c/NeuralNine)

- [Telusko](https://www.youtube.com/c/Telusko)

- [Edureka](https://www.youtube.com/c/edurekaIN)

- [freeCodeCamp](https://www.youtube.com/c/Freecodecamp)

- [Corey Schafer](https://www.youtube.com/c/Coreyms)

- [Thenewboston](https://www.youtube.com/user/thenewboston)

- [Traversy Media](https://www.youtube.com/c/TraversyMedia)

- [ProgrammingKnowledge](https://www.youtube.com/c/ProgrammingKnowledge)

### Programming Apps

- [SoloLearn](https://www.sololearn.com/home)

- [Programming Hero](https://www.programming-hero.com/)

- [Mimo](https://getmimo.com/)

- [Programming Hub](https://programminghub.io/)

- [Code Hub](https://www.codehub.gr/)

- [Grasshopper](https://grasshopper.app/)

- [Enki](https://www.enki.com/)

- [Encode](https://upskew.com/)

- [Codecademy](https://www.codecademy.com/)

- [DataCamp](https://www.datacamp.com/)

---

## Let's connect!

You can follow me on [Twitter](https://twitter.com/MrDanishSaleem), [LinkedIn](https://www.linkedin.com/in/mrdanishsaleem/) & [GitHub](https://github.com/mrdanishsaleem/)

If you like this post. Kindly support me by [Buying Me a Coffee](https://www.buymeacoffee.com/mrdanishsaleem)

![Buy Me a Coffee](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v0ikih5nlsqs0oops11e.png)
3 Simple Python Exercises
Tags: python, webdev, beginners, programming
Published: 2021-11-14 16:59:30

Hi guys!

In this post we will be looking into a few simple python exercises or challenges that will be very useful in strengthening your concepts.

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

## Exercise - 1 
**Find the number of upper case and lower case letters in a string.**
For this challenge, we will loop through a string and count the number of upper and lower case letters in it. Then when all the characters have been checked, we will output the numbers.
We will use the string 'The Dev Community is Amazing'.

```python
Text = "The Dev Community is Amazing"
#Variables to store the number of upper and lower case
UpperCase = 0
LowerCase = 0
#loop through the string
for i in Text:
    #check for upper case
    if i >= "A" and i <= "Z":
        UpperCase += 1
    #check for lowercase
    elif i >= "a" and i <= "z":
        LowerCase += 1
#print the final number.
print("UpperCase letters:",UpperCase,"and LowerCase letters:", LowerCase)
```
The output for this string will be:
```
UpperCase letters: 4 and LowerCase letters: 20
```

##Exercise - 2

**Write the multiplication table of a number to 5**
In this one, we will write the multiplication table of any number input by user.

```python
#user input
Number = int(input("Enter a number: "))
#loop from 1 to 5 and write the multiplication for each
for i in range(1,6):
    print(Number, "*",i,"=", Number*i)
```
####Output:
```
Enter a number: 5
5 * 1 = 5
5 * 2 = 10
5 * 3 = 15
5 * 4 = 20
5 * 5 = 25
```

##Exercise - 3

**Find the number of even numbers in a given range**
For this one, we will take a range of numbers from the user and give the number of even numbers in that range.

A number is even if its remainder is 0 when it is divided by 2.

```python
#user inputs the range
Number1 = int(input("Enter starting number: "))
Number2 = int(input("Enter last number: "))
#Store number of even numbers
Even = 0
#check each number in range
for i in range(Number1,Number2+1):
    #check if number is  even
    if i % 2 == 0:
        Even += 1

print("Number of even numbers are:",Even)
```
####Output:
```
Enter starting number: 1
Enter last number: 4
Number of even numbers are: 2
```

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

These were the 3 simple python exercises every beginner should try to strengthen their concepts and get some useful practice

I hope you all found them useful.
Check out my other [tutorials](https://owlcation.com/stem/reactCounter) on [hubpages](https://hubpages.com/@salehmubashar).
Also follow me on [twitter](https://twitter.com/SyntaxE85827144).
> Like my work? Buy me a coffee!

<a href="https://www.buymeacoffee.com/salehmubashar" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/default-orange.png" alt="Buy Me A Coffee" height="41" width="174"></a>

Until next time,
Cheers :)
The wrong and right way to make a link look like a button
Tags: css
Published: 2021-11-14 16:57:55

There's definitely a right way and a wrong way of doing this. Probably more than one wrong way, but any way that means only the link is clickable, is the wrong way.

## Example
{% codepen https://codepen.io/nicm42/pen/oNeaMLe %}

In the CodePen above are two links that look like buttons. If you hover over the first one, you only get the hand cursor and the link at the bottom of your browser when you're over the link. On the second one, you get the hand and link at the bottom of your browser when you hover over the button.

## Why does this matter?

It matters to me because it makes me think I'm going mad or there's something wrong with my computer. It looks like you should be able to click anywhere on the button, so I do. And then wonder why nothing happens.

In case you think my example is too contrived, here's a real world example that I took a screenshot of. This is from an email about my TV licence.

![button1.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636908427899/kH11b7FqR.png)

![button2.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1636908438971/iERrB0KOW.png)

## Solution

Add all the CSS you need to make the link look like a button to the link element itself. The only CSS I have on my second link in the CodePen at the top is:

```css
.link {
  padding: 2em 3em;
  background-color: pink;
  color: black;
}
```
The background colour makes it look like a button, and I made the text colour black, so it's not a horrible clash with the default blue link colour.

The padding then makes it bigger - otherwise the pink would be around just the text. I went for something reasonably big so it's easy to see what's happening. The padding effectively means that the link takes up more space and the background colour is an indication of how much space the link is taking up. And means that clicking anywhere on the 'button' will be like clicking on the link.
HacktoberFest 2021
Tags: hacktoberfest, opensource, github, flutter
Published: 2021-11-14 16:56:05

Hacktoberfest'21 is my second hacktoberfest but it's the first time I post on dev.to. I really enjoyed the contribution I made to the open-source community (even if there were small).

This year I was working on a mobile application with flutter (since I'm starting to learn it). The experience I got was very good and I suggest to every one to participate at hacktoberfest.

The experience building the mobile app was so good that I will continue to contribute to the project.

Can't wait for next year, who knows, next year I might even be a contributor and not only a participant :)
Cloud AI
Published: 2021-11-08 12:21:15

Google Launches Cloud AI platform to simplify machine learning development service designed to deploy robust, repeatable AI pipelines along with monitoring, auditing, version tracking, and reproducibility in the cloud. Google’s pitching it as a way to deliver an “easy to install” secure execution environment for machine learning workflows, which could reduce the amount of time enterprises spend bringing products to production.

“When you’re just prototyping a machine learning model in a notebook, it can seem fairly straightforward. But when you need to start paying attention to the other pieces required to make a [machine learning] workflow sustainable and scalable, things become more complex,” wrote Google product manager Anusha Ramesh and staff developer advocate Amy Unruh in a blog post. “A machine learning workflow can involve many steps with dependencies on each other, from data preparation and analysis, to training, to evaluation, to deployment, and more. It’s hard to compose and track these processes in an ad-hoc manner — for example, in a set of notebooks or scripts — and things like auditing and reproducibility become increasingly problematic.”

AI Platform Pipelines has two major parts: (1) the infrastructure for deploying and running structured AI workflows that are integrated with Google Cloud Platform services and (2) the pipeline tools for building, debugging, and sharing pipelines and components. The service runs on a Google Kubernetes cluster that’s automatically created as a part of the installation process, and it’s accessible via the Cloud AI Platform dashboard. With AI Platform Pipelines, developers specify a pipeline using the Kubeflow Pipelines software development kit (SDK), or by customizing the TensorFlow Extended (TFX) Pipeline template with the TFX SDK. This SDK compiles the pipeline and submits it to the Pipelines REST API server, which stores and schedules the pipeline for execution.
Modularize ASP.NET DI configurations using Autofac
Tags: dotnet, autofac
Published: 2021-11-14 16:27:29

---
title: Modularize ASP.NET DI configurations using Autofac
published: true
description: Describes a method to modularize .NET service registrations using Autofacs Module
tags: dotnet, autofac
lastmod: '2021-11-14T16:19:26.640Z'
---

When working on a monolith in ASP.NET the `Startup.cs` tends to get messy as more and more services are added.

Nevertheless, with the Microsoft.Extensions.DependencyInjection being the new and good default for libraries to provide means for configuration, I want to use these extension methods to setup my dependency injection container of choice, which is [Autofac](https://autofac.org).

## Modularizing the configuration in Autofac

Autofac always provided means to easily modularize its configuration using `Module`s.

Basically you add a new class inheriting from Module and override `Load`.

```csharp
public class AModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        builder.RegisterType<MyType>();
    }
}
```

Then you are registering the module in the configuration.

```csharp
builder.RegisterAssemblyModules(typeof(Startup).Assembly); // Register all modules in assembly
builder.RegisterModule(typeof(AModule)); // Register single module
builder.RegisterModule<AModule>(); // Register single module using generics
```

## Integrating Microsoft.Extensions.DependendyInjection registrations with Autofac Modules

Autofacs integration with Microsofts DependencyInjection (https://github.com/autofac/Autofac.Extensions.DependencyInjection) adds an `PopulateServices` extension that allows to add all services in an IServiceCollection to the Autofac configuration.

When adding Autofac to an ASP.NET application this method is used at the end to integrate the `Microsoft.Extensions.DependencyInjection` services into Autofac.

```csharp
public static void Populate(
            this ContainerBuilder builder,
            IEnumerable<ServiceDescriptor> descriptors)
```

This method can also be used in modules to add additional services to the container in a modular fashion. Here an example for a ValidationModule that adds `FluentValidation` to the application:

```csharp
public class ValidationModule : Module
{
    protected override void Load(ContainerBuilder builder)
    {
        var services = new ServiceCollection();
        
        services.AddFluentValidation(fv => fv.RegisterValidatorsFromAssembly(ThisAssembly));

        builder.Populate(services);
    }
}
```

This method allows you to use extension methods provided by libraries for an easier integration into the .NET ecosystem in a modular, clean way located close to the code that needs it.

## Conclusion

I have shown how I integrate Autofacs Module configuration with `Microsoft.Extensions.DependencyInjection`. 

I use this method to modularize the configuration for my monolithic applications.

How are you managing your growing Startup.cs? Have you found another way to manage your dependencies in a better way?
Installing Ubuntu 20.04 [Desktop]
Published: 2021-11-13 12:10:43

Installing Ubuntu is a very simple task if the steps are followed correctly.
**Listed below are steps to be followed to install Ubuntu on Windows**
-The first step is to download  VirtualBox. <https://www.virtualbox.org/>
Go to the above link and click on the download icon.
-once download icon is clicked we will be able to see different download options. For windows you can click on the 'Windows hosts' option and the download would start.
-If the download is completed you can click 'next' on the the slides that show up unless there is something particular you would want to change. At the end click on the 'install' button.
-Next step is to install Ubuntu
<https://ubuntu.com/>
The above link will direct you to the download link. Here select Ubuntu desktop and download the latest version.
-Now go to your VirtualBox and click on 'New' to create a virtual machine. Here select type as Linux and version as Ubuntu (64 bit).
-In the next step select your RAM. Then create a virtual hard disk(as hard disk file type you can select ' VirtualBox disk image' and storage type as dynamically allocated). Then we allocate file size.
-Now you can change the settings in the VirtualBox. Go to storage and under controller IDE select empty. Now at the optical drive select choose a disk file and attach the Ubuntu ISO file we downloaded earlier. Click on 'OK'.
-Now to start the VirtualBox simply select your virtual box name and click start. Here you have to select your ISO file.
-Now select Install Ubuntu and then choose language and keyboard layout and then continue. next select normal installation and check the third party software for graphics box then continue and select installation type.
-Next we select our location and then create a username and password. Once the installation process is complete click restart. Now choose your username and enter your password.
 *You have successfully installed Ubuntu*
Have you tried the GitKraken CLI feature yet?
Published: 2021-11-14 16:14:38

For those of you who don't know yet about GitKraken, it's an awesome Git GUI client which has an abundance of neat features which facilitate your git workflow, increase productivity, offer clean repository visual overview, save time and make you feel legendary. You can learn more about it [on their webpage](https://www.gitkraken.com/git-client), or you can check out [my post](https://dev.to/damjand/gitkraken-the-tool-i-can-t-git-without-74j) about it.

Its latest feature is called GitKraken CLI and it integrates a git terminal inside the client. This allows for the developers who are keen on using the terminal for git commands to be able to continue using the terminal for their git workflow while still being able to keep an eye on the visual element of the repository. 

With GitKraken's stunning, modern and colorful UI you are able to preview the commit and branch history while working in the CLI. This allows you to synchronize your command workflow with the visual aspect of the current state of the git repository. The command line is shipped with many helpful features in itself such as a diff view, history & blame view and autosuggest.

Make sure to check it out if you haven't already as well as GitKraken's Git GUI client. It is free to download for any platform, though it also includes pro and enterprise plans which include many other integrations too.
I made a neovim plugin
Tags: vim, linux
Published: 2021-11-14 16:07:39

---
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/res8g0l0e9xjibxrfuhi.jpg
published: True
tags:
- vim
- linux
title: I made a neovim plugin
---

I've slowly adding more and more lua functions into my neovim configuration, and recently I noticed a pattern for a class of functions that reach out to run shell commands that can be abstracted away.

{% youtube 8m5ipBuopPU %}

## Telegraph.nvim

Check out the project [readme](https://github.com/WaylonWalker/Telegraph.nvim) for the most up to date details on the plugin itself.

## Motivation

I want a simple way to make remaps into shell commands that can open new tmux windows, popups, or just run a command with context from the editor.

For example I want to make remaps to do things like open the current file in lookatme.

``` vim
# vim :terminal
nnoremap <leader>s <cmd>Telegraph pipx run lookatme {filepath} --live-reload --style gruvbox-dark<cmd>

# tmux session
nnoremap <leader><leader>s <cmd>lua require'telegraph'.telegraph({cmd='pipx run lookatme {filepath} --live-reload --style gruvbox-dark', how='tmux'})<CR>

# tmux popup
nnoremap <leader><leader>S <cmd>lua require'telegraph'.telegraph({cmd='pipx run lookatme {filepath} --live-reload --style gruvbox-dark', how='tmux_popup'})<CR>
```

The main goal here is that remaps become one liners that can just be put directly in my `init.vim` without creating a whole new lua module for each
shell command I want to bind.

## how

`telegraph` takes in a `how` argument to determine where to tun the command.

* `term`(default) runs command in the built in terminal
* `tmux` runs command in a new tmux session and joins it.
* `tmux_popup` runs command in a tmux popup window.
* `tmux_popup_session` runs command in a tmux session and displays it in a popup
* `subprocess` runs command in a subprocess

## Format strings

The current set of format strings that can be used with telegraph.  Placing these in braces `{}` within your command will get rendered into something with context from the editor.

* `cword` - the current word under the cursor
* `cWORD` - the current BIG Word under the cursor
* `cline` - the current line under the cursor
* `filepath` - the filepath of the current file
* `filename` - the filename of the current file
* `parent` - the parent directory of the current file
* `current_session_name` - name of the current tmux session
* `cwd` - the current working directory

## Give it a ⭐

Check out the [repo](https://github.com/WaylonWalker/Telegraph.nvim) and give
it a star if its something that interests you.
GameOff #3 - SFX and grenade launcher!
Tags: github, gamedev, unity3d, devjournal
Published: 2021-11-14 16:04:20

Few days more and next update. We have new music and sounds for weapons so game is much more dynamic now. We had small issue with animating baseball bat because of wrong setup with rigidbody. Thankfully friend helped me to solve the problem and now you can smash bugs by swinging bat! ;D

The next step will be to work on initial arena and add mesh for character. For now, this is how the game looks like:

{% youtube 7okCPIrp_N4 %}
Swap layout with Dribbble
Published: 2021-11-14 15:49:21

I will use:

* [Vitejs](https://vitejs.dev/)
* [Reactjs](https://v3.vuejs.org/)
* [React router dom](https://reactrouter.com)
* [TailwindCSS](https://tailwindcss.com/)

<img src="https://raw.githubusercontent.com/Rezvitsky/swap-react-experiment/main/preview.webp?token=AF6OYWTLKWJ4QVBEZCOHDL3BSEXEC" />

Repo: https://github.com/Rezvitsky/swap-react-experiment