teleren/devto huggingface dataset:
Three means and big bases
Tags: perl, python, theweeklychallenge
Published: 2022-03-27 10:50:19

## Weekly Challenge 157

I'm back after the three week hiatus!

[Challenge](https://theweeklychallenge.org/blog/perl-weekly-challenge-157/), [My solution](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-157/sgreen)

## TASK #1 › Pythagorean Means

### Task

You are given a set of integers.

Write a script to compute all three [Pythagorean Means](https://en.wikipedia.org/wiki/Pythagorean_means) i.e Arithmetic Mean, Geometric Mean and Harmonic Mean of the given set of integers.

### My solution

This is a relatively straight forward task. The Wikipedia page provides the necessary formulas and we can use the `sum` `reduce` and `lambda` functions to calculate the required figures. Finally we use the `round` function to print the results to one decimal place.

The Perl code is similar to the Python version, except we use the product() method in List::Utils. Python's math.product is only available for Python 3.8+

One thing to note is if the sum of integers is 0, a division by zero error might occur when calculating the harmonic mean. I'm not catching this and let the error pass to the user.

### Examples

```
$ ./ch-1.py 1 3 5 6 9
AM = 4.8, GM = 3.8, HM = 2.8

$ ./ch-1.py 2 4 6 8 10
AM = 6.0, GM = 5.2, HM = 4.4

$ ./ch-1.py 1 2 3 4 5
AM = 3.0, GM = 2.6, HM = 2.2
```

## TASK #2 › Brazilian Number

### Task

You are given a number `$n` > 3.

Write a script to find out if the given number is a Brazilian Number. A positive integer number `N` has at least one natural number `B` where `1 < B < N-1` where the representation of `N` in base `B` has [the] same digits.

### My solution

This was an interesting task. We can't convert numbers into a different base simply by using letters and numbers. For example 1282 is 22 in base 640, but how would you express 639 in the same base?

For this task I considered a value having the same digits even if the number itself has different digits. For example, 925 is express as (25)(25) in base 36.

The guts of this task is to convert the number `n` in base 10 to a specified base, which I have called `b`. The function is called `same_digits`. I take the modulus (remainder) of `n` and `b` and make this value `d`. I then do an integer division and repeat this process comparing that `n % b` is `d`. I return `False` if any digit isn't the same, or `True` if they all are.

Then it's just a matter of having a loop from 2 to `n - 2`, and calling the `same_digits` function for each base. If there is a match, I print `1` (and the base), or `0` otherwise.

The Perl code is a transliteration of the Python code.

### Examples

```
$ ./ch-2.py 6
0

$ ./ch-2.py 7
1 (base 2)

$ ./ch-2.py 8
1 (base 3)
```
The easiest way to upload your own pip package to pypi.org
Tags: python, package, pip, github
Published: 2022-03-27 10:20:52

Python's package choice is a selling point of it. Yet the package management `pip` can be quite tricky for starters with issues like `env`, version number, etc.

To publish a package using `pip` to `pypi.org` is not easier at all, due to the complicated and unintuitive process.

The good news is, we have now have a wonderful `template` to work with and the powerful `GitHub Action` to help.

## Use a template

First, you should download this repo:
https://github.com/chaosprint/setup.py

Some things to do:
- change the name of `mypackage` to `YOUR-PACKAGE-NAME`
- Edit the `core.py` to fit your need
- Edit the `setup.py` based on the comment inside

## Use GitHub

Now create a new GitHub repo.
Upload your package and double check the license, readme, version number, author, etc.

### Create a new action

After you upload your code, click `Action` on your repository.

Choose `Publish Python Package`.

Change the `__token__` to your username on pypi.org (you should have registered one).

Then, commit it.

### Create a secret in your repo settings

> Settings -> Secrets -> New repository secret

key: PYPI_API_TOKEN
value: YOUR_PASSWORD_FOR_PYPI

### Finally
Create a release. Then the project will be built and uploaded to pypi automatically.
Pretending to be a tradesman 🕵️‍♂️
Tags: discuss, watercooler
Published: 2022-03-27 10:14:18

Being an IT professional lends itself a particular tract of logic shared with other problem solvers, is it any wonder then that some of us love DIY?

In the past year I have expanded my hobbies from just Coding and 3D modelling to:

- Trains!
- Woodworking!
- 3D CAD
- Maker
- Gardener / Landscaping

And to the point in question, I join groups on Facebook and use my skills from each to maximum effect, coding calculators for trains, functions for solving woodworking, 3D gardening designs etc, but then talking to the pros I'm a little embarrassed to say I'm actually a developer, I even have a tradesman coat when I go shopping so I look more the part, it's my ForgeRock (where I work) coat, but to most people it's a brick layit company for example 😂

I guess as an engineer I'm also pretending
Why Podcast Apps have no comment section?
Tags: podcast
Published: 2022-03-27 10:03:07

---
title: Why Podcast Apps have no comment section?
published: true
description: podcast discussion
tags: podcast
//cover_image: https://direct_url_to_image.jpg
---

I find it weird that audio only podcast apps have no comment section like for example videos on youtube or vimeo, I find this a good idea to have a discussion under the podcast but it is weird to me that no App has this yet, I really think if nobody does this I will create my own App but I wanted to hear more opinions about it here on DEV, so what do you all think?
how to send more than one parameter in array format
Tags: fastapi
Published: 2022-03-27 09:46:31

Hi

I have made one generalised query function, where i will sent table name and  where clause, depending on the requirement.
but i'm facing issue while sending more than one params in where clause in array/object format.
please find my general function below:

def get_records(db: Session, table_name : str, where_class , limit: int)
    return db.query(table_name).having(where_class).limit(limit).all() 


My router file code below:
@router.get("/price/")
async def read_all_price(limit: Optional[int] = None, db: Session = Depends(get_db_con)):
    result = format_result('fail', 'no records found', 'price_list', [])

    Where = {status:1,product_id:2 }
    records_list = crud.get_records(db, Price, Where, limit)
    if records_list is not None:
        result = format_result('success', 'records found', 'price_list', records_list)
    return result
How to send mail in laravel 9
Tags: laravel, php, tutorial, beginners
Published: 2022-03-27 09:44:52

## Send MAIL In Laravel 9

Today I am going to explain how you can send MAIL using SMTP in Laravel 9.

## Laravel UI Installation.
After [Installing Laravel 9](https://dev.to/techtoolindia/laravel-9-installation-j0d) we will open the code in Editor.

## Step - 1
Open `.env` file and change the MAIL Provider SMTP Details

```php
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
```
You can use [MailTrap](https://mailtrap.io/) to generate basic SMTP Details and test your email faeture.

## Step - 2
Now Generate the email class by running command
```php
php artisan make:mail TestEmail
```

this command will generate the file in `app/Mail/TestEmail.php`

Open the file and update the code below.
```php
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class TestEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $mailData;
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($mailData)
    {
        $this->mailData = $mailData;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Test Email')->view('email.test');
    }
}
```

## Step - 3
Now Let's create a blade view file, for that let's create `email` folder first inside `resources/view`.

Now create a `test.blade.php` file inside email folder and paste the code below.

```php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Test Email</title>
</head>
<body>
    <h1>Test EMAIL</h1>
    <p>Name: {{ $mailData['name'] }}</p>
    <p>DOB: {{ $mailData['dob'] }}</p>
</body>
</html>
```

## Step - 4
Now create a route to send email put the code below to `routes/web.php` 

```php

use App\Mail\TestEmail;
use Illuminate\Support\Facades\Mail;

Route::get('send-email', function(){
    $mailData = [
        "name" => "Test NAME",
        "dob" => "12/12/1990"
    ];

    Mail::to("hello@example.com")->send(new TestEmail($mailData));

    dd("Mail Sent Successfully!");
});
```

Now visit to `/send-email` in browser it should send the email to inbox.

The Email Will look like.

![EMAIl INBOX](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7q6ngakjk6a3dy823emc.png)

The complete Tutorial is below in the video.

{% youtube WU4_HzTa6PM %}

If you face any issue while installing, please comment your query.

Thank You for Reading

Reach Out To me.
[Twitter](https://twitter.com/techtoolindia)
[Instagram](https://www.instagram.com/techtoolindia/)
[TechToolIndia YouTube Channel](https://www.youtube.com/channel/UCOy6o08Yn9DtXMKqxhD9ivA)
How to send email in laravel 9 ?
Tags: laravel, email, webdev, beginners
Published: 2022-03-27 09:35:28

## Send MAIL In Laravel 9

Today I am going to explain how you can send MAIL using SMTP in Laravel 9.

## Laravel UI Installation.
After [Installing Laravel 9](https://dev.to/shanisingh03/how-to-install-laravel-9-25c4) we will open the code in Editor.

## Step - 1
Open `.env` file and change the MAIL Provider SMTP Details

```php
MAIL_MAILER=smtp
MAIL_HOST=mailhog
MAIL_PORT=1025
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
```
You can use [MailTrap](https://mailtrap.io/) to generate basic SMTP Details and test your email faeture.

## Step - 2
Now Generate the email class by running command
```php
php artisan make:mail TestEmail
```

this command will generate the file in `app/Mail/TestEmail.php`

Open the file and update the code below.
```php
<?php

namespace App\Mail;

use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Mail\Mailable;
use Illuminate\Queue\SerializesModels;

class TestEmail extends Mailable
{
    use Queueable, SerializesModels;

    public $mailData;
    /**
     * Create a new message instance.
     *
     * @return void
     */
    public function __construct($mailData)
    {
        $this->mailData = $mailData;
    }

    /**
     * Build the message.
     *
     * @return $this
     */
    public function build()
    {
        return $this->subject('Test Email')->view('email.test');
    }
}
```

## Step - 3
Now Let's create a blade view file, for that let's create `email` folder first inside `resources/view`.

Now create a `test.blade.php` file inside email folder and paste the code below.

```php
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Test Email</title>
</head>
<body>
    <h1>Test EMAIL</h1>
    <p>Name: {{ $mailData['name'] }}</p>
    <p>DOB: {{ $mailData['dob'] }}</p>
</body>
</html>
```

## Step - 4
Now create a route to send email put the code below to `routes/web.php` 

```php

use App\Mail\TestEmail;
use Illuminate\Support\Facades\Mail;

Route::get('send-email', function(){
    $mailData = [
        "name" => "Test NAME",
        "dob" => "12/12/1990"
    ];

    Mail::to("hello@example.com")->send(new TestEmail($mailData));

    dd("Mail Sent Successfully!");
});
```

Now visit to `/send-email` in browser it should send the email to inbox.

The Email Will look like.

![EMAIl INBOX](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7q6ngakjk6a3dy823emc.png)

The complete Tutorial is below in the video.

{% youtube WU4_HzTa6PM %}

If you face any issue while installing, please comment your query.

Thank You for Reading

Reach Out To me.
[Twitter](https://twitter.com/shanisingh03)
[Instagram](https://www.instagram.com/shanisingh03/)
[TechToolIndia YouTube Channel](https://www.youtube.com/channel/UCOy6o08Yn9DtXMKqxhD9ivA)
How did I build 🏗️my first 🗄️API with MongoDB and Next.js?
Tags: nextjs, node, mongodb, api
Published: 2022-03-27 09:25:15

By the way, I am a frontend developer🧑🏿‍💻, I always love to use APIs and work with them.
but the project that I was wanted to build API is like Apple's 🍎 Store,
and this gave me the will to build an API and release it,
A few weeks ago I completed working with my [`Clone Of Twitter Project`](https://cloneoftwitter.vercel.app/), where I had used **Firebase **as a database,
but now I wanted to push myself and use **MongoDB **as a database.

After thinking a while I start with the project's building 
## Open source Apple Store API.

using [`Next.js API  Routes`](https://nextjs.org/docs/api-routes/introduction) it has become very easy to manage the backend.
I make simple routing and pages so if the comes to this page will be provided with other these data.

***`BaseUrl`*** : ***`https://oas.vercel.app/api`***


## /all
>***baseUrl***  **`/all`**
![ThanosInfinityWarGIF.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1648372357113/ppMRhMDha.gif)

> it provides all the data from the database, from all the categories without filteration. 😊

## /category/:category
>**baseurl** **`/category/iphone`**

![PhirHeraPheriBCategoryKeCClassLogGIF.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1648372488221/OaCAq-_gL.gif)
> here you can add category for your output. and result will be from that category only.
> example: + `/category/watch`
>          + `/category/iphone`
>          + `/category/macbook`
>          + `/category/airpods`
>          + `/category/ipad`

## /series/:series
>**baseurl** **`/series/MacBook Air`**
>🧑‍💻every product has series name such as iPhone 13 has series name such as iPhone 13, under  iPhone 13 two products come iPhone 13 & iPhone 13 mini.
>>They are `case sentitive` 😓 so iphone_13, iPhone_13 won't work ❌,
>correct way /series/iPhone 13 ✅
>without `%20`
### /:_Id
>**baseurl** **`/6228d7ac2e00fb1164b2df27`**

![DoYouHaveIdWhoAreYouGIF.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1648372547581/l97LZe9DU.gif)

> for getting results realted to single product the /:_Id is used.
> example: /6228d7ac2e00fb1164b2df27,
> these are id sentitive `fetch` with their respective id's.😅
```json
{
    "data": {
        "_id": "6228d7ac2e00fb1164b2df27",
        "product_name": "MacBook Pro",
        "product_price": {
            "IN": 109000,
            "US": 999,
            "GBP": 899
    },
    "product_description": "Id culpa aliquip ipsum excepteur sunt incididunt laboris magna incididunt nostrud.",
}
}
```

![CatDrivingGIF.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1648372243149/d0jF7wOOl.gif)

### This is how I worked 💪🏾on routing/ and requests.
 use this project and let me how was it, I'll your projects' in the featured section.

## Share 🤝🏾 you ideas thought's regarding this I try to implement that.
![BusinessmenHandshakeGIF.gif](https://cdn.hashnode.com/res/hashnode/image/upload/v1648371967433/mc6skAG7h.gif)

Connect with on
Twitter  : [`@AbhayPrajapati_`](https://twitter.com/AbhayPrajapati_/)
Github : [`@theabhayprajapati`](https://github.com/theabhayprajapati)
👋🏾
Recursive replace input value with process environment values in console
Tags: rucken, environment, replace, shell
Published: 2022-03-27 09:18:02

Often you need to change part of the value of an environment variable to another variable

I made a utility for such a replacement

## Links

https://www.npmjs.com/package/rucken - npm package

https://github.com/rucken/rucken - source code

https://github.com/rucken/rucken/blob/develop/libs/rucken/tests/e2e/env-replacer.spec.ts - e2e test

## Example of usage

Create env file
_example.env_
```env
VAR1=var1${VAR2}
VAR2=var2$var3
var3=VAR3$NO_REPLACE
```

Load file to current environment
> export $(cat ./example.env)

We derive the variable VAR1 in the usual way
> echo $VAR1

Result
```sh
var1${VAR2}
```

And now we will display the variable through the utility
> echo $(npx -y rucken env-replacer $VAR1)

Result
```sh
var1var2VAR3$NO_REPLACE
```
Docker Images Vs Container - Difference
Tags: docker, devops, kubernetes, cloud
Published: 2022-03-27 08:49:59

Before actually learning docker we have to understand the difference between containers and images. People still get confused between them and unable to explain if someone ask with clarity so let me clarify the difference between these two.

In one line **"Docker images are read-only templates used to build containers. Containers are deployed instances created from those templates."**

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

1. **Container** is a running environment for an **image**. Theoretically container is a part of container runtime.

2. **Images** are just templates, you cannot start or run them. What you can do is use that template as a base to build a container.

3. Container has application image that runs the application like redis, postgres, chef, ubuntu etc and also file system where it can save log file and configuration files like environment variables.
![Docker cont](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/19l4rgfvpuxboly6rga7.png)

4. Containers are the organizational units and one of the Docker basics concepts. When we build an image and start running it; we are running in a container.

5.  When you run a containerized environment, you essentially create a read-write copy of that filesystem (docker image) inside the container. This adds a container layer which allows modifications of the entire copy of the image.
![Container layer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/18yqslqzdqfa7eki3tvy.png)
 
6.  The container analogy is used because of the portability of the software we have running in our container. We can move it, in other words, “ship” the software, modify, manage, create, or get rid of it, destroy it, just as cargo ships can do with real containers

When talking about the difference between images and containers, it isn’t fair to contrast them as opposing entities. Both elements are closely related and are part of a system defined by the Docker platform.
Rtp Slot Hari ini
Tags: rtpslothariini, rindu4d, judionline, slotonline
Published: 2022-03-27 08:38:22

Bingung cari Rtp slot hari ini dengan tingkat kemenangan tertingi? Ingin mencoba aplikasi-aplikasi yang memberikan bocoran Rtp slot hari ini tapi gak tau mau coba dimana?? 

Tidak perlu khawatir karena hanya di <a href="https://167.172.100.107/?ref=winrate98/" target="_blank">RINDU4D</a> 
anda bisa mendapatkan informasi Rtp slot hari ini terjitu dan terakurat karena member kami bermain dan mengalaminya secara langsung loh! Nah berikut adalah beberapa pilihan permainan untuk anda yang sedang mencari slot rtp tertinggi.

1.Gates Of Olympus 97.84%
2.Starlight Princess 97.16% 
3.Sweet Bonanza 96.77%
4.Sweet Bonanza Xmas 96.71%
5.Aztec Gems96.51%
6.Joker Jewels 97.13%
7.Lions Megaways  97.25%
8.Big Juan 96.88%
9.Wild West Gold 95.77%
10.Fruit Party 2 96.71%

Apa arti <a href="https://167.172.100.107/?ref=winrate98/" target="_blank">Rtp slot hari ini </a> ?

RTP slot adalah nilai persentase pengembalian uang di semua uang yang dipertaruhkan oleh pemain dari waktu ke waktu. Dengan kata lain RTP disebut juga sebagai salah satu kemampuan dari game slot dalam memberikan kembali uang kepada pemain pada saat kalah.

IKUTI KESERUAN EVENT TERBAIK DARI RINDU4D

🔥 EVENT SETIAP SABUT & MINGGU 🔥
🎰 UNTUK NEW MEMBER 20 GET 40 TO X1 (Boleh buyspin)
🎰 UNTUK OLD MEMBER 50 GET 75 TO X3 (Boleh buyspin)

DAFTAR SEKARANG JUGA DI <a href="https://167.172.100.107/?ref=winrate98/" target="_blank">RINDU4D</a> ?
DevSahaaya: Resources for Javascript Developers
Tags: javascript, node, react, webdev
Published: 2022-03-27 08:30:59

I have created a site which has resources for Javascript developers. The reason why I created this one is to find right resources. I used to bookmark lot of resources in chrome but it is hard to find resources in that bookmark list. 

Link to site: https://devsahaaya.vercel.app/

Once I started working on this, I choose Next.JS to build this app because I wanted to learn building an app with Next.JS and Markdown files. 

I will be adding some more resources in the future. Comment down below if you have any suggestion.

Source code: https://github.com/Ranganath-MD/Dev-Sahaaya
Open Source is more than open-source.
Tags: opensource
Published: 2022-03-27 08:13:01

If you are reading this article, you should already have some idea about Open Source software. Is that idea suggesting the code of the software to be available? Let's examine how well your idea fits the definition of Open Source.

Maybe it is not a bad idea to look back a bit and see how this term came to the scene. Much earlier and in the mid-1980s, the Free Software definition was introduced. Though the definition was about four essential freedoms of the software user (to use, study, modify, and share), many people were taking the "Free" as free of cost.

This confusion along with a few other motivations led to another term to get into the scene at the end of the 1990s: Open Source. Open Source came to achieve some goals including removing confusion about the "Free" part of the Free Software idea. The Open Source Definition (OSD) listed ten criteria for a software to be called Open Source:

1. Free redistribution
2. Include source code
3. Allow derived works
4. May protect the integrity of the author's source code
5. No discrimination against persons or groups
6. No discrimination against fields of endeavor
7. Distribution of license
8. Not be specific to a product
9. Not restrict other software
10. Technology-neutral

Interestingly, the availability of the source code is not the first criterion but the second. This simply means software that only shares the source code and does not comply with the rest of the nine criteria, is not Open Source software. Such software is called Source Available.

In this regard, having access to lots of JavaScript code doesn't mean they are Open Source. Releasing a code without explicitly mentioning the license (approved by OSI) means it is not Open Source software. Again: "Open source doesn't just mean access to the source code. The distribution terms of open-source software must comply with the" ten criteria mentioned above.

Next time you hear Open Source, remember that:

```
Open Source > open source
```