teleren/devto huggingface dataset:
Single, SingleOrDefault, First and FirstOrDefault in LINQ
Tags: csharp, linq, dotnet
Published: 2022-07-12 11:15:47

# Single

- Returns the result only when predicate matches the collection that contains only one matching record.

```csharp
    public List<string> Names = new List<string>() { "Jon", "Amber"};

    public string GetName()
    {
        return Names.Single(n=>n.Equals("Jon"));
    }
```

- Throws error if the collection contains more than one matching data or no matching data.

```csharp
    public List<string> Names = new List<string>() { "Jon", "Amber", "Depp Jon","Heard Amber" };

    public string GetName()
    {
        return Names.Single(n=>n.Contains("Jon"));
    }
```

```csharp
    public List<string> Names = new List<string>() { "Jon", "Amber", "Depp Jon","Heard Amber" };

    public string GetName()
    {
        return Names.Single(n=>n.Contains("ABC"));
    }
```

- **_Loops through all the data of the collection even if it found the match in collection which has impact on performance_**.

# SingleOrDefault

- This is similar to the Single except returning default value when the specified condition not satisfied.

```csharp
    public List<string> Names = new List<string>() { "Jon", "Amber", "Depp Jon","Heard Amber" };

    public string GetName()
    {
        return Names.SingleOrDefault(n=>n.Contains("ABC"));
    }
```

- Returns the **_null_**(default of string type) instead of throwing error.

# First

- Returns the result only when predicate matches the collection even that contains more than one matching record.

```csharp
    public List<string> Names = new List<string>() { "Jon", "Amber", "Depp Jon","Heard Amber" };

    public string GetName()
    {
        return Names.First(n=>n.Contains("Jon"));
    }
```

- Throws error if the collection contains no matching data.

```csharp
    public List<string> Names = new List<string>() { "Jon", "Amber", "Depp Jon","Heard Amber" };

    public string GetName()
    {
        return Names.First(n=>n.Contains("ABC"));
    }
```

- **_Will not loops through all the data of the collection once it found the match in collection thus making this is better than Single in terms of performance_**.

# FirstOrDefault

- This is similar to the First except returning default value when the specified condition not satisfied.

```csharp
    public List<string> Names = new List<string>() { "Jon", "Amber", "Depp Jon","Heard Amber" };

    public string GetName()
    {
        return Names.FirstOrDefault(n=>n.Contains("ABC"));
    }
```

- Returns the **_null_**(default of string type) instead of throwing error.
Limit User Requests - Rate Limiting Laravel
Tags: php, laravel, webdev, programming
Published: 2022-07-12 10:40:01

Today we will learn how to set the user to reach our endpoint how many times per minute correctly in order to protect our application and keep no problems due to the number of requests in excess of the limit and is often used with APIS .
For more information, visit the source :-
https://laravel.com/docs/9.x/routing#rate-limiting
https://www.youtube.com/watch?v=TQSDi3e0TxU

- An example of fetching user data, but the user has the right to call the request three times every minute


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

in RouteServiceProvider.php


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


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

- Here we want to customize a message that appears when user attempts fail


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

- To stop the feature for the time being and make the user free in the number of requests we use the function `` none() ``


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


I hope you benefit from the article and I wish you a happy code.
Codewars Day #1, 5kuy
Tags: javascript, python, codewars, 5kuy
Published: 2022-07-12 10:39:46

## Name Kata
[Pete, the baker](https://www.codewars.com/kata/525c65e51bf619685c000059)

## Details

Pete likes to bake some cakes. He has some recipes and ingredients. Unfortunately he is not good in maths. Can you help him to find out, how many cakes he could bake considering his recipes?

Write a function cakes(), which takes the recipe (object) and the available ingredients (also an object) and returns the maximum number of cakes Pete can bake (integer). For simplicity there are no units for the amounts (e.g. 1 lb of flour or 200 g of sugar are simply 1 or 200). Ingredients that are not present in the objects, can be considered as 0.

```
# must return 2
cakes({flour: 500, sugar: 200, eggs: 1}, {flour: 1200, sugar: 1200, eggs: 5, milk: 200})
# must return 0
cakes({apples: 3, flour: 300, sugar: 150, milk: 100, oil: 100}, {sugar: 500, flour: 2000, milk: 2000})
```

## My Solutions

### Python

```
from typing import List

def cakes(recipe: List[str], available: List[str]) -> int:
    try:
        return int(min([available[x] / recipe[x] for x in recipe]))
    except:
        return 0
```

### JavaScript

```
const cakes = (recipe, available) => {
  var availableIngredients = []
  for(var key in recipe) {
    if (available[key] != undefined && available[key] / recipe[key] >= 1 ) {
      availableIngredients.push(available[key] / recipe[key])
    } else {
      return 0
    }
  }
  
  return ~~Math.min.apply(null, availableIngredients)
}
```
Comment apprendre python en 2022 ?
Tags: python
Published: 2022-07-12 10:29:41

Vous avez beaucoup de tâches fastidieuses et répétitives au travail ? Vous voulez être capable de faire des choses plus efficacement ? Python peut vous aider !

Python est l’un des langages de programmation les plus utilisés. Apprendre à coder avec [Python est une compétence très recherchée](https://jeuxwiki.com/telecharger-gta-5-ppsspp-iso-android/) dans beaucoup de métiers. Et pas uniquement pour les développeurs logiciels à temps plein. Tout le monde peut apprendre !

Python vous permet d’automatiser des tâches comme envoyer des emails ou écrire dans des fichiers... Tout ça pour vous aider à terminer des tâches plus efficacement.

Ce cours s’adresse aux personnes qui n’ont jamais vu une ligne de code ou qui n’ont [jamais entendu parler de Python](https://jeuxwiki.com/telecharger-pes-2023-ppsspp-iso-psp-android-francais/). Nous allons avancer ensemble pas à pas de façon amusante et facile à comprendre. Je sais ce que ça fait d’être intimidé par le code ou de n’y rien comprendre. Je veux donc m’assurer que personne ne ressente la même chose. 

Dans ce cours, vous allez enregistrer des informations en tant que données en Python. [Vous allez contrôler la logique](https://jeuxwiki.com/telecharger-ppsspp-gold-apk-pour-android-gratuitement/) dans votre code avec des conditions, des boucles et des fonctions. Vous allez aussi automatiser la récupération de données à partir du web avec les packages Requests, Beautiful Soup et CSV dans le processus appelé extraction de données web. Vous allez beaucoup apprendre et vous passerez un bon moment !
Python Dumb Finder🐍
Tags: beginners, python, tkinter, showdev
Published: 2022-07-12 10:26:59

Hello Guys!🤞🏼

After a while, I wrote a dumb finder program that written by Python just for FUN!!😂

**What is your idea to improve our Dumb finder program?🤔**


`#------------ * Start coding * -----------
from tkinter import *
from tkinter import messagebox
from random import randint
#Importing needed packages

my_window = Tk()
#Create an instance of window

my_window.geometry("350x200")
#Set the geometry of the window

my_window.title("Dumb Finder")
#Window title

text = Label(my_window, text="Are You Dumb?" , font=("Hobo Std",14,"bold")).pack(pady=50)
#define a label(text) 

def no_changer():
    random_x = randint(0,150)
    #gives random x for no button
    random_y = randint(0,150)
    #gives random y for no button
    no_btn.place(x=random_x, y=random_y)
    #place no button by random-generated x , y

def yes_alert():
    messagebox.showinfo("Dumb Founded!", "I KNOW <3")
    #show message
    my_window.quit()
    #close window after clicking Ok
    
no_btn = Button(my_window, text= "No" , width=5 , font=30, command=no_changer)
#define No button and send to no_changer function

no_btn.place(x=100, y=100)
#place no button in x=100 , y=100

yes_btn = Button(my_window, text= "Yes" , width=5 , font=30, command=yes_alert)
#define Yes button and send to yes_alert function

yes_btn.place(x=200, y=100)
#place Yes button in x = 200 , y=100

my_window.mainloop()
#stay on my_window until manually close program

#------------- * End of code * -----------
#------------- ** Code by @fawlid ** -----`
AWS Learning Series #1- Cloud computing 101
Tags: aws, cloud, career
Published: 2022-07-12 10:21:49

**"Cloud Computing"** is the need-based provision of IT resources via the Internet at usage-based prices. Instead of purchasing, owning, and maintaining physical data centres and servers, you can access technology services such as compute, storage, and databases on-demand through a cloud provider like Amazon Web Services (AWS).

**Key advantages:**
	Agility
	Elasticity
	Cost savings
	Go-global in minutes (Worldwide deployments in mins)
	Metered billings (Pay-as-you-go)

**Types of Cloud computing:**
	Infrastructure as a Service (IaaS)
	Platform as a Service (PaaS)
	Software as a Service (SaaS)


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

It’s very good feel that if you are going to learn leading cloud provider AWS. They are the leader in Cloud computing because of:
	Largest community of customers and partners
	Greatest functionality
	Highest level of security
	Shortest innovation cycles
	Proven operational expertise

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

Gartner Research positions AWS in the Leaders quadrant in the new 2021 Magic Quadrant for Cloud Infrastructure & Platform Services (CIPS) report. CIPS are defined in the context of this "Magic Quadrant" as "standardised, highly automated offerings in which infrastructure resources (e.g. compute, network and storage resources) are supplemented with integrated platform services".

**Global Infrastructure AWS**
The AWS Global Cloud Infrastructure is the most secure, extensive, and reliable cloud platform, offering over 200 fully featured services from data centres globally. Whether you need to deploy your application workloads across the globe in a single click, or you want to build and deploy specific applications closer to your end-users with single-digit millisecond latency, AWS provides you the cloud infrastructure where and when you need it.

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

AWS has the most extensive global cloud infrastructure. No other cloud provider offers so many regions and Availability Zones, all characterized by low latency, high throughput and a highly redundant network. AWS is available in 84 Availability Zones within 26 geographic regions worldwide. In addition, 24 additional Availability Zones and 8 additional AWS regions in Australia, Canada, India, Israel, New Zealand, Spain, Switzerland and the United Arab Emirates (UAE) are planned. The AWS Regions and Availability Zones model is recommended by Gartner as a best practice for running enterprise applications that require high availability.

**Key benefits of using AWS:**
	Security
	Availability
	Performance
	Global footprint
	Scalability
	Flexibility
	Cost savings
	Improved Disaster recovery
	Flexibility in Subscription options 
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fcb851lop8nps12e0ze3.png)
Why Avoid Late Variables in Dart ??
Tags: flutter, dart, programming, beginners
Published: 2022-07-12 10:21:08

## 𝗛𝗼𝘄 𝗟𝗮𝘁𝗲 𝗩𝗮𝗿𝗶𝗮𝗯𝗹𝗲𝘀 𝗰𝗮𝗻 𝗯𝗲 𝗩𝘂𝗹𝗻𝗲𝗿𝗮𝗯𝗹𝗲? 
 
Instance fields can be initialized in 4 ways: 
1. At the point of protestation 
2. In a constructor argument using **'this'** 
3. In the constructor’s initializer list before the law in braces starts.
4. Anywhere Differently 

 
4 is problematic since the preface of null safety. By the time the constructor body( the law in braces) starts, the object must be completely initialized so each of its fields are usable. So if it isn't initialized in _1, 2, or 3,_ it fails to collect. 
𝐖𝐞 𝐜𝐚𝐧 𝐟𝐢𝐱 𝐭𝐡𝐢𝐬 𝐛𝐲' 𝐥𝐚𝐭𝐞' 𝐤𝐞𝐲𝐰𝐨𝐫𝐝.😃 
 
It literally means “ **I'll initialize it latterly** ”. And you got no error. 
.
.
.
## ⚠️ 𝐁𝐮𝐭 𝐡𝐞𝐫𝐞 𝐚𝐫𝐞 𝐭𝐡𝐞 𝐫𝐞𝐚𝐬𝐨𝐧𝐬 𝐰𝐡𝐲 𝐬𝐡𝐨𝐮𝐥𝐝 𝐰𝐞 𝐬𝐡𝐨𝐮𝐥𝐝 𝐚𝐯𝐨𝐢𝐝 𝐥𝐚𝐭𝐞 𝐯𝐚𝐫𝐢𝐚𝐛𝐥𝐞𝐬:

𝟏- 𝐍𝐨 𝐜𝐨𝐦𝐩𝐢𝐥𝐞 - 𝐭𝐢𝐦𝐞 𝐜𝐡𝐞𝐜𝐤 𝐟𝐨𝐫 𝐢𝐧𝐢𝐭𝐢𝐚𝐥𝐢𝐳𝐚𝐭𝐢𝐨𝐧 
 
Still, you only know this at runtime when the program fails, If you forget to initialize a late variable. Basically, you say “ Trust me to initialize d ever before it's read for the first time ”. So the compiler skips the initialization check and inserts a runtime check. 

-
-
-
-
𝟐- 𝐑𝐮𝐧𝐭𝐢𝐦𝐞 𝐜𝐡𝐞𝐜𝐤𝐬 𝐚𝐫𝐞 𝐬𝐤𝐢𝐩𝐩𝐞𝐝 𝐚𝐭 𝐡𝐢𝐠𝐡𝐞𝐫 𝐨𝐩𝐭𝐢𝐦𝐢𝐳𝐚𝐭𝐢𝐨𝐧 𝐥𝐞𝐯𝐞𝐥𝐬 
 
There's a stir to allow skipping the initialization checks in some shapes. This may beget segfault which is harder to probe than an ordinary exception. 

-
-
-
-
𝟑- 𝐓𝐚𝐤𝐞𝐬 𝐦𝐨𝐫𝐞 𝐦𝐞𝐦𝐨𝐫𝐲 
 
Your program needs to know if a late variable has been initialized or not. For this, the compiler frequently creates a retired internal variable that takes memory. 

-
-
-
-
𝟒- 𝐀𝐝𝐝𝐢𝐭𝐢𝐨𝐧𝐚𝐥 𝐫𝐞𝐚𝐝 𝐚𝐧𝐝 ‘ 𝐢𝐟 ’ 𝐛𝐞𝐟𝐨𝐫𝐞 𝐞𝐚𝐜𝐡 𝐫𝐞𝐚𝐝 
 
Every time you read a late variable the program must insure it's initialized, so a redundant check is added. 

-
-
-
-
𝟓- 𝐀𝐝𝐝𝐢𝐭𝐢𝐨𝐧𝐚𝐥 𝐰𝐫𝐢𝐭𝐞 𝐛𝐞𝐟𝐨𝐫𝐞 𝐞𝐚𝐜𝐡 𝐰𝐫𝐢𝐭𝐞.
 
Every time you write to a late variable the program sets the internal flag to note that it's initialized. 

-
-
-
-
Hopefully, that helped. Did it? 😃 
 
------------------------------ 
 Follow for further 👇 
 
 **[Areeba Farooq](https://dev.to/areedev)**
Why Anonybit, Why Now
Published: 2022-07-12 10:16:08

[Anonybit](https://anonybit.io/) protects your privacy and secures your assets with game-changing decentralized biometrics. Decentralization of data is key for maintaining personal privacy, data protection and digital security. Yet, today’s solutions fall short. Centralized databases are prone to hacks and device-based solutions leave gaping security holes that fraudsters exploit. Anonybit goes to the root of the problem – how biometric data is stored and managed. Instead of building higher walls around centralized databases or storing biometrics on devices only to use passcodes as a fallback, we ask, what if there was no data to find? What if there was no biometric template to store? Welcome to Anonybit. The world’s first FULLY decentralized biometrics, where personal privacy meets digital security. Hope this answers [why Anonybit, why now](https://anonybit.io/blog/whyanonybit).
Video Game DB PostgreSQL
Tags: sql, beginners, programming, python
Published: 2022-07-12 09:56:56


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

Recently I've been spending some time working with PostgreSQL. While I have had experience building databases within Microsoft Excel, it's been an eye opener to see how everyday sites I use at work and home communicate with an underlying database. As a start to understanding how to build a proper database schema and automate data input into my database, I built a sample database for GameCube/PS2/Xbox games as well as a python script to automate the entry of my dataset rather than writing several insert clauses. I'd love to hear any feedback about how I could improve my schema. The SQL file and python script can be found below for those interested;

https://github.com/Dwayne-Lacey/VideoGameDatabase
All About CSS Box Model
Tags: webdev, css, beginners, codenewbie
Published: 2022-07-12 09:52:53

**CSS** has many advanced concepts which can be daunting for a beginner but understanding them becomes a little bit easier if the basics are clear in your head and Box Model in CSS is an important concept when working with design and layout of webpages.
In this article I will be talking about the components involved in box model and few pointers to keep in mind.

## Introduction
'Box Model' represents the container that wraps around every HTML element. All the elements are essentially rendered as rectangular boxes by the browser rendering engine . For styling purposes , it is necessary to understand the four parts(areas) that makes up the Box Model - margins , borders , padding and content area.

![Parts of Box Model](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4amvvl9ra7h2uey83nzz.png)
 
Let us now learn more about these 4 areas in a little detail.

### 1. Content Area
This area contains the actual content of the element such as text , image. 

### 2. Padding area
This area is the space between the 'real' content and borders around the element.

### 3. Border area
A border is used to enclose the content and padding of the element. 

### 4. Margin area
Margin is generally used to clear out the area outside the border . It gives space between elements ouside border.

<u>The Box Model can be accessed via chrome dev tools.</u>

To learn more about css check out my personal favorite resource [w3schools](https://www.w3schools.com/css/default.asp)

Thankyou for reading . Happy Learning!
Increment ++ and Decrement -- Operator explained in simple way
Tags: beginners, tutorial, programming, java
Published: 2022-07-12 09:33:36

In this article, you will learn about the increment operator ++ and the decrement operator -- .

In programming (Java, C, C++, JavaScript etc.), the increment operator ++ decrement operator -- are used.

**Increment operator (++) or Decrement operator (--)** --> This operators increase the value of variable by 1 or decrease the variable by 1.
For eg
```
int a = 5;
a++; //output will be 6
int b = 5;
a--; //output will be 4
```

> These operators are further divided into 
> 1) Prefix increment/decrement (++a/--a)
> 2) Postfix increment/decrement (a++/a--)

1) **Prefix increment/decrement operator** --> The ++ and -- are placed before number, first evaluate the value and then performs the work.
For eg 

```
int a = 5;

System.out.println(++a); // here the new value is evaluated that is + so value will be 6 and output will be 6

System.out.println(a);   // output will be 6 because there is no further work to perform.
```
--------------------------------------------------------------------------------

2) **Postfix increment/decrement (a++/a--)** --> In this work is perform first, and then evaluate the value.
for eg 

```
int a = 5; 

System.out.println(a++); // Here work is perform what work?

the work is to print  the value of a that is 5, after that the value will be evaluated to 6 
i.e is a + 1 = 6; 5 + 1 = 6;
```
When you print value of ` a ` for second time then output will show 6;

```
int a = 5;
System.out.println(a++); //output will be 5
System.out.println(a);   // after incrementation of a the value will be 6 and it will printed as a output.
```

Let's take another example to understand in java programming language

```
class Operator {
    public static void main(String[] args) {

        int a = 5, 
        System.out.println(a++); // 5 will be output 
        System.out.println(++a); // 7 will be output
        System.out.println(a);   // 7 as it is 
        System.out.println(--a); // 6 because of subtraction
        System.out.println(a--); // 6 will be output
        System.out.println(++a); // 6 will be output
    
    }
}
```

**1** In `System.out.println(a++); // 5 will be output` here first 5 will be printed and then ++ of 5 will happen so now new value of `a` will be 6.

**2** In `System.out.println(++a);` the value of `a` will be 7 because of addition ++a it is because addition is performed, after that 7 will be output.  

**3** In `System.out.println(a);`   // 7 as it is value from previous.

**4** In `System.out.println(--a);` the value will be 6 because -- of _7-1=6_ i.e. value is 6

**5** In `System.out.println(a--); // 6 will be output` because first print value of `a` and then do subtraction i.e. _6-1=5_. When new print command for value `a` will be printed then 5 will be displayed.

**6** In `System.out.println(++a); // 6 will be output` because ++a i.e. first do addition of _5+1=6 _and print value of a which is 6.
Get notified in Microsoft Teams
Tags: javascript, webdev, programming, microsoft365
Published: 2022-08-22 09:33:22

---
title: Get notified in Microsoft Teams
published: true
date: 2022-07-12 09:08:04 UTC
tags: javascript,webdev,programming,microsoft365
canonical_url: https://blog.mastykarz.nl/notified-teams/
---

![Get notified in Teams](https://blog.mastykarz.nl/assets/images/2022/07/banner.png)

How many different apps do you use at work? How hard is it for you to stay up-to-date on what's going on in all of them? I bet the answers are _a lot_ and _hard_. If your organization is on Microsoft 365, there's a better way, though. Hear me out.

If your organization is on Microsoft 365, you're probably using Microsoft Teams. Most likely you use it for chat and video calls. Probably you use it to communicate with your colleagues and work together on files. Did you know though, that you can extend Teams with custom apps? Did you know, that these apps can help you stay up-to-date on what's going on in your organization?

Since you're already using Microsoft Teams for work, why not turn it into a personal HQ and have it deliver all important updates to you? The easiest way to do it is using **notification bots**. Notification bots are nothing more than a piece of code running in the cloud. They communicate with services that you want to monitor and send you a message to Teams when there's something that you should know. Because notification bots are registered with Microsoft Teams, they can send you [Adaptive Cards](https://adaptivecards.io/) that communicate updates in a user-friendly way and go way beyond plain text.

Building notification bots isn't hard. Especially, if you're using the recently released Teams Toolkit. Teams Toolkit offers you a template to build a notification bot. All you have to do is add the code to monitor changes and send a message to Teams. Teams Toolkit will help you test the bot and deploy it, and you'll be able to do all that in minutes.

My colleague, Garry Trinder, made a video that shows you how to create a notification bot using Teams Toolkit step by step.

<iframe width="560" height="315" src="https://www.youtube.com/embed/SJKM98Gpjkg" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>

Have a look at it and give it a try yourself. Even if you might not need it right now, it's totally worth the few minutes you'll spend and show it to your colleagues.

1. Check out Garry's video
2. [Build a notification bot using Teams Toolkit](https://docs.microsoft.com/microsoftteams/platform/sbs-gs-notificationbot?tabs=vscode)

When you're done, leave a comment and let me know how it went. Looking forward to hearing from you.