teleren/devto huggingface dataset:
It's Prisma Time - Aggregate and GroupBy
Tags: javascript, typescript, database, orm
Published: 2022-01-18 08:44:57

Welcome back Folks 👋 
Today we are seeing how to aggregate and group data.

Let's start from the first one.
To aggregate data in Prisma you have to use the [aggregate](https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#aggregate) method.
Using this method, you can aggregate data of type number, and you can do these operations:
- max
- min
- count
- sum
- avg

_N.B. I won't spend time explaining what these operations do because I think their names speak for themselves_

Therefore, let's give an example to see the aggregate method at work.
```ts
const aggregate = await prisma.author.aggregate({
  _avg: {
    age: true,
  },
  _max: {
    age: true,
  },
  _min: {
    age: true,
  },
});
```
As you can see, in this example, we aggregated the authors and we got as result the authors' ages average, the age of the older author and the age of the younger author. The result is composed in this way:
```ts
{
    _avg: {
        age: true;
    };
    _max: {
        age: true;
    };
    _min: {
        age: true;
    };
}
```
In addition, the aggregate method allows us to use these operations:
- where
- orderBy
- take
- skip 
- cursor

So as you can immagine, you can filter and sort your data before aggregate them.
I think this feature might be clear that way, so let's move on to the groupBy feature.

The [groupBy](https://www.prisma.io/docs/reference/api-reference/prisma-client-reference#groupby) feature allows us to group data by one o more fields.
Let’s see an example to start
```ts
const commentsGroupByPost = await prisma.comment.groupBy({
  by: ["postId"],
  _count: {
    authorId: true,
    _all: true,
  },
  orderBy: {
    _count: {
      authorId: "desc",
    },
  },
  having: {
    authorId: {
      _count: {
        gt: 1,
      },
    },
  },
});
```
In this example, we grouped the comments by post, and after that, we counted the number of comments with the author and the number of comments for that post.
Moreover, we sorted the result by the authors' count and, using the having option, we took only the posts that have at least a comment with an author.
As you can see, this method is not difficult to use and understand. _It's also possibile to filter the data with the `where` option._

I think for today that's all.
We saw how to aggregate and how to group data using Prisma and, if you want to deepen, the prisma team created this [video](https://www.youtube.com/watch?v=BdlCPdPaorY) to explain better the groupBy feature.

In the next article we will see how to run our queries under transaction, but for today it's time to close 😃 

See you soon guys 
Bye bye 👋 

_To show the code of this article in action follow this [link](https://github.com/puppo/it-s-prisma-time/tree/11-grouping-and-aggregate)_
I have curated 84+ high quality tools to use in 2022
Tags: showdev, webdev, tooling, productivity
Published: 2022-01-18 08:37:48

developers tools fatigue is a real struggle! 😪

when starting any new project or building a new website/app or SaaS you have to go through a long list of GitHub stared libraries or a huge browser bookmark just to find out that you don't really know what you have to type in search or find what you are looking for.

---

**Tools overload**
most lists out there just put everything under the sun from tools and services just to bombard developers with even more tools.

instead of solving the issue of searching fatigue they make it worse. I don't need a 2000+ list of tools I just need 6 tools suggestions max for each use case whether that to build a specific feature or part of a website.

---


**Not another generic list**
this is not another unopinionated list of tools.
this list gives recommendations based on real experience using the suggested tools so you will find small notes for each tool like "expensive" | "bad docs" and other observations from my own experience to help you make a better decision faster when choosing any tools off the list.

---

**Why this list?**
💎 only handpicked quality tools
📦 10+ categories
🔍 searchable & filterable
♻ frequently updated

there's even a white noise audio player that you can use to relax while picking your favorite tool ;)

😻 just launched [DevBox on Producthunt](https://www.producthunt.com/posts/devbox-84-curated-webdev-resources)
🔗 and here is the list [direct link](https://intab.io/resources)

hope you find this useful!

![DevBox Tools List Screenshot](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tj2wbvacbdxcof7p375q.png)
What are the different data types present in JavaScript?
Tags: javascript, node, webdev, beginners
Published: 2022-01-18 08:25:11

![banner](https://images.unsplash.com/photo-1526374965328-7f61d4dc18c5?ixlib=rb-1.2.1&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=1470&q=80)

To know the type of the value/variable, we can use the `typeof` operator


### Primitive Types
- **String**

A string is represented by the series of characters enclosed by double/single quotes
```js
const name = "SnowBit"
const favLang = "JavaScript"
```
- **Integer**

It represents a number that can be written with or without a decimal
```js
const age = 18
const price = 24.02
```
- **Boolean**

It is a logical entity that has only two values: `true` and `false`, basically, booleans are used for conditional operations
```js
const access = true
const isAdmin = false
``` 
- **Undefined**

When a variable is declared but not assigned, the value of that variable is `undefined`

- **Null**

It represents invalid or non-existent value
```js
const api = null
```
***
Thank you for reading, have a nice day!
- Follow me on Twitter - [@codewithsnowbit](https://twitter.com/codewithsnowbit)
- Subscribe me on YouTube - [Code With SnowBit](https://www.youtube.com/channel/UCNTKqF1vhFYX_v0ERnUa1RQ?view_as=subscriber&sub_confirmation=1)
![Have a nice day.png](https://media1.giphy.com/media/dxP4KodrzNRL91Gkyy/giphy.gif?cid=ecf05e47oy2662od7onakbpjjmfizbw8i5shlaingerfzyhk&rid=giphy.gif&ct=g)

Cover Photo by <a href="https://unsplash.com/@orwhat?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Richard Horvath</a> on <a href="https://unsplash.com/s/photos/data?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Unsplash</a>
Free Weather APIs
Tags: coding, api, beginners, programming
Published: 2022-02-01 11:56:52

---
title: Free Weather APIs
published: true
date: 2022-01-18 08:18:28 UTC
tags: coding,api,beginner,programming
canonical_url: https://javascript.plainenglish.io/free-weather-apis-98ed9035a954
---

#### A list of best free weather API

![](https://cdn-images-1.medium.com/max/1024/1*ckAe6sHAZ25VYGvzxpdIYA.png)
_Designed with canva_

I enjoy developing side projects to gain new skills or simply to play with what is available. I was working on a weather information app last week and had to use weather APIs. I’ve compiled a collection of free (but restricted) weather APIs. These APIs provide sufficient capacity to test and construct an app to learn something.

Previously, I constructed a Python program that did not require any API calls. It collects information from Google searches. You may learn more about [Smart Weather Information App Using Python](https://python.plainenglish.io/smart-weather-information-app-using-python-a185b3025c93?source=your_stories_page----------------------------------------).

Let’s go back to the matter at hand, so I’ll present the best free weather APIs accessible.

### Open Weather Map

![](https://cdn-images-1.medium.com/max/1024/1*APok4MXyxazcfVNbJaZrDw.png)
_Open Weather Map_

With open weather map APIs, you can instantly obtain weather data for any region! Simply by providing your email address and begin utilizing minute forecasts, hourly predictions, historical data, and other weather data in your applications for free. [sign up](https://home.openweathermap.org/users/sign_up)

Open weather map’s free plan includes —  **60 calls** /minute with **1,000,000 calls** /month. Which I think is more than enough to test any application.

[Checkout open weather map pricing](https://openweathermap.org/price)

![](https://cdn-images-1.medium.com/max/982/1*CzmSEegOdF4p6y---e9OBw.png)
_https://openweathermap.org/price_

[Read full stroy here](https://javascript.plainenglish.io/free-weather-apis-98ed9035a954)


---

Follow me on [Twitter](https://twitter.com/harendraverma2)
Linear Gradient Animation in CSS
Tags: html, css, tutorial
Published: 2022-01-18 08:11:52

Hey **fellow creators**

You can’t really create a *hover animation between two linear gradients in CSS*, but there’s a way around it... Let’s learn what it is in less than a minute!
 
![Gradient animation](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k43mbwcu9acx0fotemau.gif)

If you prefer to watch the video **version**, it's right here :

{%youtube YDQUH6LICk0%}

&nbsp;
##1. The HTML structure.
Create a card with a title:
```html
<div class="card">
      <div class="layer"></div>
      <h1>São Paulo</h1>
</div>
```

&nbsp;

##2. Style the card.

&nbsp;
Give the card a width and a height, center it and its content and add a background:

```css
.card {
  width: 400px;
  height: 400px;
  border-radius: 25px;
  margin: 100px auto;
  position: relative;
  z-index: 1;
  background: linear-gradient(to right, #2193b0, #6dd5ed); 
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
}

.card h1 {
  color: #f1f1f1;
  font-size: 50px;
  text-transform: uppercase;
}
``` 

&nbsp;
Create a new layer with the pseudo-element *after*:
```css
.card::after {
  content:"";
  width: 100%;
  height: 100%;
  border-radius: 25px;
  background: linear-gradient(to right, #8a2387, #e94057, #f27121);
  position: absolute;
  z-index: -1;
  opacity: 0;
  transition: opacity 0.4s ease-in-out;
}
``` 
It will take up the whole size of the card but with a new color. It will be located between the content and the container. It has no opacity for now.

&nbsp;
Finally, add a different opacity to the pseudo element when you hover the card:
```css
.card:hover::after {
  opacity: 1;
}
```


&nbsp;
Now you have a transition between your two linear gradients! Check out [source code](https://www.ui-delivery.com/Gradient Animation) here to see the final outcome!

&nbsp;
Come and take a look at my **Youtube channel**: https://www.youtube.com/c/TheWebSchool

*See you soon!*

Enzo.
Today's Fun Joke For Developers - Daily Developer Jokes
Tags: jokes, dailydeveloperjokes
Published: 2022-01-18 08:00:15

---
title: "Today's Fun Joke For Developers - Daily Developer Jokes"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e12591e45d64.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Why didn't the `<div />` get invited to the dinner party?

___A:___ Because it had no class!
 -->
#19 - Binary Addition CodeWars Kata (7 kyu)
Tags: javascript, webdev, tutorial, programming
Published: 2022-01-18 07:58:03

##Instructions

Implement a function that adds two numbers together and returns their sum in binary. The conversion can be done before, or after the addition.

The binary number returned should be a string.

**Examples:**
> (Input1, Input2 --> Output (explanation)))
> 1, 1 --> "10" (1 + 1 = 2 in decimal or 10 in binary)
> 5, 9 --> "1110" (5 + 9 = 14 in decimal or 1110 in binary)

---

##My solution:

```javascript
function addBinary(a,b){
  return (a+b).toString(2)
}

```


##Explanation
First I just summed the  numbers and after that I just converted it to string with a 2 parameter so it would only be 0 and 1 (binary code)

---

**Did you like this solution? 👇🤔**

[My Github](https://github.com/Cesardlr)
[My twitter](https://twitter.com/cesar__dlr)
[Solve this Kata](https://www.codewars.com/kata/551f37452ff852b7bd000139)
For Loop through an array in backward direction in JavaScript
Tags: javascript, sh20raj, tips, array
Published: 2022-01-18 07:35:20

There are several methods to loop through the array in JavaScript in the reverse direction:

# **1. Using reverse for-loop**

The standard approach is to loop backward using a for-loop starting from the end of the array towards the beginning of the array.

```
var arr = [1, 2, 3, 4, 5];
 
for (var i = arr.length - 1; i >= 0; i--) {
    console.log(arr[i]);
}
```

# **2. Using `Array.prototype.reverse()` function**

We know that `forEach` goes through the array in the forward direction. To loop through an array backward using the `forEach` method, we have to reverse the array. To avoid modifying the original array, first create a copy of the array, reverse the copy, and then use `forEach` on it. The array copy can be done using slicing or ES6 Spread operator.


```
var arr = [1, 2, 3, 4, 5];
 
arr.slice().reverse()
    .forEach(function(item) {
            console.log(item);
});

```
Alternatively, you can use the [Object.keys()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys) method to get keys:

```
var arr = [1, 2, 3, 4, 5];
 
Object.keys(arr).reverse()
        .forEach(function(index) {
            console.log(arr[index]);
});
```
# **3. Using Array.prototype.reduceRight() function**

The `reduceRight()` method executes the callback function once for each element present in the array, from right-to-left. The following code example shows how to implement this.

```
var arr = [1, 2, 3, 4, 5];
 
arr.reduceRight((_, item) => console.log(item), null);
```

That’s all about looping through an array backward in JavaScript.

Source :- https://www.techiedelight.com/loop-through-array-backwards-javascript/
How to pass text as input in a POST request body with Jax-RS
Tags: java, rest, codever, snippets
Published: 2022-01-18 07:28:35


Use `MediaType.TEXT_PLAIN` in the `@Consumes` annotation and then you have access to the text content as string

```java
    @POST
    @Path("organisation")
    @Consumes(MediaType.TEXT_PLAIN)
    @ApiOperation(value = "Create bookmark from text")
    @ApiResponses({
            @ApiResponse(code = 201, message = "Bookmark successfully created.", response = Bookmark.class),
            @ApiResponse(code = 403, message = "Forbidden")
    })
    public Response createBookmark(@ApiParam("Bookmark") String boookmark, @Context UriInfo uriInfo) throws JAXBException {
        Bookmark created = bookmarkService.createBookmarkFromString(bookmark);
        UriBuilder builder = uriInfo.getAbsolutePathBuilder();
        builder.path(created.getUuid().toString());
        return Response.created(builder.build()).build();
    }
```

> Shared with :heart: from [Codever](https://www.codever.dev/snippets/606c2030c6a18456bf09aa8f/details). Use :point_right: [**copy to mine**](https://www.codever.dev/snippets/606c2030c6a18456bf09aa8f/details) functionality to add it to your personal snippets collection.
Convert Keys in Json to Snake Case
Tags: python, json, beginners, tutorial
Published: 2022-01-18 07:22:44






```python
import re

def convert_to_snakecase(original_dict):
    
    transformed_dict = {}
    array_items = []
    if not isinstance(original_dict, list):
      for k in original_dict.keys():
          value = re.sub(r'(?<!^)(?=[A-Z])', '_', k).lower()
          if not isinstance(original_dict[k], list):
              if isinstance(original_dict[k], dict):
                  transformed_dict[value] = convert_to_snakecase(original_dict[k])
              else:
                  transformed_dict[value] = original_dict[k]
          else: 
          
              array_items = []
              for i in range(len(original_dict[k])):
                  if isinstance(original_dict[k][i], dict):
                      array_items.append(convert_to_snakecase(original_dict[k][i]))
                      transformed_dict[value] =  array_items
                  else:
                      transformed_dict[value] = original_dict[k]
    else:
        array_items = []
        for item in original_dict:
          array_items.append(convert_to_snakecase(item))
        transformed_dict.update(array_items)
    return transformed_dict

```
Daily tools for Office
Tags: beginners, javascript, programming, productivity
Published: 2022-01-18 07:22:43

There is a story behind every project.

Recently I learn some coding using Youtube tutorials and was thinking to start some projects.

I started thinking about any idea which is already not developed.
I got some ideas through google but sadly my mind can't think of any idea which is already not developed. 

And my coding skills are not strong that I can develop any AI Application which already does not exist.


So instead of creating any new applications. 

I started to build the common things which can help in the day-to-day tasks.

The idea was to build a small-small feature which will be handy for the office employees.


And I end developing the **Ezytool**

URL - [ezytool.com](https://ezytool.com/)

It would be great if someone can give me feedback or any popular feature which needs to be implemented.


The sole purpose of this website is to help people without any **Ads or limitations**.
Speed up Windows for heavy development.
Tags: programming, javascript, flutter, productivity
Published: 2022-01-18 06:55:29

Hey everyone, This is [Akash](https://github.com/BLUE-DEVIL1134).
I am a **[windows](https://windows.com/)** user, ofc, my PC is too noob for `Linux`.
From time-to-time, my pc gets slow AF, so I have some hacks to fast it up and clean memory.

## My PC Specs
![My PC Specs](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/32mw0cce0ojbp21v2wiw.png)

> Well, the specs might be less, but works just fine after my hacks.

### Step 1
- Press `Win` + `R`.
- Type `temp` and click on `OK`.
- Select all with `Ctrl` + `A`.
- Press `Ctrl` + `Shift` + `Del`.

> This will clear your temp cache and free up memory and disk.

* Now, Repeat the step with `%temp%` and `prefetch`.
![%temp%](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/l556sycdwjni6493u2g8.png)
![Prefetch](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lrow6tg6qf8mlqbay8d2.png)
 
### Step 2
- Press `Ctrl` + `Shift` + `Esc`, To Open `Task Manager`.
- Goto the `Startup` tab.
- Disable all the **Enabled** Apps.
![Task Manager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rvu4z36utfa8npbwyivs.png)

### Step 3
- Keep `C:` drive (OR your `OS` Drive) as clean as possible.
![File Manager](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hdweey9k4hab4kikihmp.png)

## Finally, Let's Sum Up
- Repeat `Step 1` everyday when you start your PC/Laptop.
- Regular `Shutdown`'s also keeps your processor cool. (Not applicable on laptops by office )
![Laugh](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xdm64ickp841e37tetiz.png)

> These steps can be very helpful for webdevs and flutter devs..
Android Components with Examples

Tags: career, programming, android, tutorial
Published: 2022-01-18 06:48:53

## What are Components

App components are the essential building blocks of an Android app. Each component is an entry point through which the system or a user can enter your app. Some components depend on others. All the components are coupled together in a file name `AndroidMenifest.xml` which tells how they are going to interact with each other.

## Type of Components

- Activities
- Services
- Broadcast Receivers
- Content Provides

## Detail Explanations

### Activities
Activity is screen what you see and interact with on your phone. For example, when you open WhatsApp you see activity. Now you click on a chat you see another activity. You can create an activity with build-in class `Activity` or `AppCompatActivity`
#### Code snippet 
- Activity

```
public class MainActivity extends Activity {
}
``` 

- AppCompatActivity

```
public class MainActivity extends AppCompatActivity {
}
``` 

### Services
A service is a general-purpose entry point for keeping an app running in the background for running multiple tasks in the background.  It is a component that runs in the background to perform long-running operations or to perform work for remote processes. For example, a service might play music in the background while the user is in a different app, or it might fetch data over the network without blocking user interaction with an activity. You can create your service with built-in class `Service`
#### Code snippet 

```
public class CustomService extends Service {
}
``` 

### Broadcast Receivers
Broadcast Receivers enables the system to deliver events to the app outside of a regular user flow, allowing the app to respond to system-wide broadcast announcements. For example, you can fire broadcast when you receive a message, you receive a call, you turn on airplane mode.

There are two kinds of Broadcast Receivers.

- **Static Broadcast Receivers:** These types of Receivers are declared in the manifest file and works even if the app is closed.
- **Dynamic Broadcast Receivers:** These types of receivers work only if the app is active or minimized.
#### Code snippet 
```
public class MyReceiver  extends  BroadcastReceiver {
   public void onReceive(context,intent){}
}
``` 

### Content Providers
A content provider manages a shared set of app data that you can store in the file system, in a SQLite database, on the web, or on any other persistent storage location that your app can access. Through the content provider, other apps can query or modify the data if the content provider allows it.
#### Code snippet 

```
public class MyContentProvider extends  ContentProvider {
   public void onCreate(){}
}
```