teleren/devto huggingface dataset:
Book Club: Grokking Algorithms. 2 Discussion Qs
Tags: discuss, books, algorithms, bookclub
Published: 2023-05-26 13:41:44

---
title: Book Club: Grokking Algorithms. 2 Discussion Qs
published: true
description: Book Club discussion for Grokking Algorithms by Aditya Y. Bhargava
tags: [discuss, books, algorithms, bookclub]
series: book club Grokking Algorithms
---

I'll answer these questions when I've finished the book, but feel free to answer these here or to use them for your own book club.

#### **Grokking Algorithms** An _illustrated_ guide for programmers and other curious people, by Aditya Y. Bhargava

## Discussion Questions

0. The author uses illustrations to explain the topics in the book. Did you find them helpful for your understanding?

0. Has reading this book helped you to explain any of the algorithms or concepts to someone else?

0. Were any of the topics or algorithms frustrating for you? Is there anything you still don't understand?

0. Have you used any of the algorithms in your coding (or another application!) after reading the book? How did the algorithm help you?

0. Is there anything you'd misunderstood about the topics covered before reading the book, that was corrected or clarified in the book?

0. Do you have a favourite algorithm from the book? If so, why? What do you like about it?

0. Is there anything you'll learn more about after reading this book?

0. Would you recommend this book? Who would enjoy reading it?
Book Club: Grokking Algorithms. 1 Welcome
Tags: discuss, books, algorithms, bookclub
Published: 2023-05-26 13:41:34

---
title: Book Club: Grokking Algorithms. 1 Welcome
published: true
description: Book Club discussion for Grokking Algorithms by Aditya Y. Bhargava
tags: [discuss, books, algorithms, bookclub]
series: book club Grokking Algorithms
---

Welcome to this tech book club! I'd love for you to join me reading this title. I've chosen this book after it was recommended to me by Alice, one of my coaches at Makers Academy.

## **Grokking Algorithms** An _illustrated_ guide for programmers and other curious people, by Aditya Y. Bhargava

![puppies](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4shiiny24ibgk9et9ypb.png)
<figcaption>Puppies from chapter 3 copyright Manning Publications, drawn by adit.io</figcaption>

### About the book

>Grokking Algorithms is a fully illustrated, friendly guide that teaches you how to apply common algorithms to the practical problems you face every day as a programmer. You'll start with sorting and searching and, as you build up your skills in thinking algorithmically, you'll tackle more complex concerns such as data compression and artificial intelligence. Each carefully presented example includes helpful diagrams and fully annotated code samples in Python.

- Published by [Manning](https://www.manning.com/books/grokking-algorithms) where you can see the entire book for **free**.
- Take 40% off Grokking Algorithms. Just enter code **ytbhargava** into the discount code box at manning.com.

### About the Author

> **Aditya Bhargava** is a Software Engineer with a dual background in Computer Science and Fine Arts. He blogs on programming at [adit.io](adit.io).

## Reading Information

The book has 11 chapters and approx 221 pages.
My copy is the 2016 paperback edition.
Each chapter has approx 4 sections, each with exercises to reinforce the content covered, and a recap of the key points in each chapter.

Code examples (in several programming languages) and illustrations are on [GitHub](https://github.com/egonschiele/grokking_algorithms)

Animations from the book are on [YouTube](https://www.youtube.com/watch?v=oo_sb4luiPo)
Sap Software
Published: 2023-05-26 13:41:07

SAP (Systems, Applications, and Products) is a multinational software corporation renowned for its enterprise resource planning (ERP) solutions. SAP offers a wide range of software products that cater to diverse business needs. In this article, we will explore the fundamentals of [SAP software](https://www.dglitservices.com/service/sap-software-and-services/), delve into its various products, discuss how SAP programs work, examine the capabilities of SAP ERP, and highlight some essential SAP tools.
Guest Post Sites List 2023
Published: 2023-05-26 13:08:35


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/org41nhiqpx1mj99xisz.jpg)
https://www.vaca-ps.org/blogs/54294/The-Benefits-of-Using-Eco-Friendly-Materials-for-Custom-Shirt
https://indibloghub.com/profile/davidk
https://articleswing.com/?p=3476&preview=true
https://www.hashtap.com/@david.k/why-custom-mailer-boxes-are-a-must-have-for-your-business-bGg7j4oWz2Mq
https://cynochat.com/read-blog/62228
https://www.theworknplay.com/Blogs
https://getrotation.com/?p=18352&preview=true
https://www.gotrendingnews.com/submitted-guest-post/?success=1&post_id=1994
http://bedfordfalls.live/read-blog/38624
https://stompster.com/read-blog/116638
https://www.mymeetbook.com/read-blog/20495
https://customboxesrange.hashnode.dev/innovative-design-ideas-for-custom-eyeshadow-boxes
https://customboxesfor.shopping-wiki.com/7792422/custom_face_mask_boxes_for_every_scenario
https://www.truthsocialviet.com/read-blog/36989
https://blooder.net/read-blog/18281
https://highfinews.com/?p=9902
https://www.khedmeh.com/wall/blogs/post/26899
https://lacidashopping.com/2023/05/26/custom-lip-balm-boxes/
https://droidt99.com/read-blog/85868
Critter Corner #2 - Share Your Beloved Animal Friends! 🐾
Tags: discuss, watercooler, codenewbie
Published: 2023-05-26 13:08:09

---
title: Critter Corner #2 - Share Your Beloved Animal Friends! 🐾
published: true
description: Biweekly pet thread to share your animal companions.
tags: discuss, watercooler, codenewbie
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-05-19 17:12 +0000
---
Hello, wonderful DEV community! It's been a month since we kicked off our initiative to bring more animal companions into our midst, and we want to give a shoutout to all those who have already participated. We appreciate your contributions, and the adorable snapshots you shared have certainly brought smiles to our faces!

While the response to our new weekly series has been heartwarming, we'd love to see even more of your furry, feathered, and scaly friends gracing our community. After all, there's nothing quite like the charm and joy that animals bring into our lives.

By sharing snapshots of your cherished animal friends, you not only make [Sloan](https://dev.to/sloan) incredibly happy but also help create a more vibrant and inclusive community for everyone. We can't wait to see what furry, feathery, and scaly adventures await us! 📸🐶🐦🦎

And hey, if you do happen to know any sloths looking for a job, please do send them our way. Sloan is patiently waiting to make some new friends who can match their unique pace and personality.

Share your beloved animal friend's photo in the comments below and let's make DEV a welcoming haven for all creatures great and small!
Enhancing Laravel Commands: Parameterized Inputs and Custom Output Formats [4/4]
Tags: webdev, php, laravel, codenewbie
Published: 2023-05-26 13:02:17

So far, so good. It gives us some insights into the current state of our gating system, but not much more. Since we've come this far, we might as well take one step further and incorporate two crucial aspects of commands: the ability to pass parameters. Once we have this functionality in place, the console kernel becomes equally powerful as the web kernel, granting access to all infrastructure and data layers, just as you would normally have.

What we do is pass a username to the command and then examine each gate for the retrieved user. We mark, in an additional column, whether the user can pass it or not, indicating a green "pass" or a red "restricted".

Try to and identify the new code additions. I’ll give you a hint: start with the command signature. Feel free to comment if you have any questions. And, most importantly, have fun!

```
<?php

namespace App\Console\Commands;

use Illuminate\Console\Command;
use Illuminate\Contracts\Auth\Access\Gate;
use App\Models\User;

class CheckGates extends Command
{
    protected $signature = 'gate:check {username}';
    protected $description = 'Check access of user for all defined gates in Laravel';

    protected $gate;

    public function __construct(Gate $gate)
    {
        parent::__construct();
        $this->gate = $gate;
    }
    protected function getClosureContents(\Closure $closure)
    {
        $reflection = new \ReflectionFunction($closure);
        $closureCode = file($reflection->getFileName());

        $startLine = $reflection->getStartLine();
        $endLine = $reflection->getEndLine();

        $contents = array_slice($closureCode, $startLine - 1, $endLine - $startLine + 1);

        return implode('', $contents);
    }
    public function handle()
    {
        $username = $this->argument('username');
        $user = User::where('username', $username)->first();

        if (!$user) {
            $this->error("No user found with username: $username");
            return;
        }

        $gates = $this->gate->abilities();
        $self = $this;

        $tableData = array_reduce(array_keys($gates), function ($carry, $key) use ($gates, $user, $self) {
            $value = $gates[$key];
            $hasAccess = $this->gate->forUser($user)->check($key);

            $carry[] = [
                'Gate Name' => $key,
                'Access' => $hasAccess ? '<fg=green>Pass</>' : '<fg=red>Restricted</>',
                'Closure Contents' => $self->getClosureContents($value),
            ];

            return $carry;
        }, []);

        $this->table(['Gate Name','Access', 'Closure Contents'], $tableData);
    }
}
```
How to use the PHP Reflection API for Inspecting Closure Contents [2/4]
Tags: programming, tutorial, api, php
Published: 2023-05-26 12:53:52

The Reflection API in PHP is a set of classes that allow you to introspect your code. It provides the ability to retrieve detailed information about classes, methods, properties, and functions at runtime, such as their names, parameters, and modifiers (like public, private, protected), among other things. It's commonly used for advanced tasks like building development tools, debuggers, or components for a dependency injection container.

Closures (or anonymous functions) in PHP are considered "black boxes" because they encapsulate their behavior and environment when defined. This means that their internal variables and code can't be directly accessed or inspected from the outside like regular variables - you can only interact with them through their inputs and outputs. When you try to dump a closure with `var_dump()`, `print_r()`, or Laravel's `dd()`, you don't see the actual PHP code inside the closure. This is why you need tools like the Reflection API to inspect their contents.

```
$getClosureContents = function(\Closure $closure)
{
    $reflection = new ReflectionFunction($closure);
    $closureCode = file($reflection->getFileName());

    $startLine = $reflection->getStartLine();
    $endLine = $reflection->getEndLine();

    $contents = array_slice($closureCode, $startLine - 1, $endLine - $startLine + 1);

    return implode('', $contents);
}
```
What we're doing here is pretty simple: We find the exact PHP file that has the closure, read the content of this file, get all the lines from the start to the end, and put the function back together as a multiline string. But this process would not be possible without the useful features of PHP's Reflection.
```
$closureContents = array_map($getClosureContents, $gates);
```
Will put out: 
```
[
     "viewHorizon" => """
               Gate::define('viewHorizon', function ($user) {\n
                   return in_array($user->email, [\n
                       //\n
                   ]);\n
               });\n
       """,
     "viewTelescope" => """
               Gate::define('viewTelescope', function ($user) {\n
                   return in_array($user->email, [\n
                       //\n
                   ]);\n
               });\n
       """,
   ]
```
Now we are able to: [Create a Laravel Command to Display All Authorization Gates Similar to route:list](https://dev.to/graffino/create-a-laravel-command-to-display-all-authorization-gates-similar-to-routelist-34-3558)
Any Cat
Tags: python, programming
Published: 2023-05-26 12:52:14

Any Cat is a simple, text-based game where you can battle two cats against each other. https://learnaboutcat.com/category/facts-about-cat/
The game is easy to learn but difficult to master, and it can be played by people of all ages.
Any Cat is a great way to pass the time, and it's also a lot of fun.
So why not give it a try? You might just find your new favorite game.

import random

class Cat:
    def __init__(self, name, color):
        self.name = name
        self.color = color
        self.hp = 100
        self.atk = 10
        self.defence = 5

    def attack(self, opponent):
        opponent.hp -= self.atk

    def defend(self, damage):
        self.hp -= damage

    def is_alive(self):
        return self.hp > 0

def main():
    # Create two cats
    cat1 = Cat("Carl", "blue")
    cat2 = Cat("Doug", "grey")

    # Start the game
    while cat1.is_alive() and cat2.is_alive():
        # Choose a random cat to attack
        attacker = random.choice([cat1, cat2])
        defender = cat1 if attacker == cat2 else cat2

        # Attack the defender
        attacker.attack(defender)

        # Defender defends
        defender.defend(attacker.atk)

    # Announce the winner
    if cat1.is_alive():
        print("Cat1 wins!")
    else:
        print("Cat2 wins!")

if __name__ == "__main__":
    main()


This game is very simple, but it can be easily modified to make it more complex. For example, you could add more cats, different types of attacks, or different levels of difficulty.
How to List All Authorization Gates in Your Laravel Application [1/4]
Tags: webdev, laravel, php
Published: 2023-05-26 12:50:25

While Laravel doesn't provide an Artisan command specifically for listing gates, there's a valid reason for this. The need to inspect these gates doesn't arise frequently. If such a situation does occur, you can rely on the ol’ debugging tools.

But for now I need to put together something quick and explore my options. That’s a job for the tinker command  which allows us to evaluate PHP and Laravel code on-the-fly and see the results immediately, which can be incredibly useful in our scenario. 

When it comes to what you can do with the Gates class,  although the available methods are not explicitly exposed in the official Laravel documentation, contracts and facades serve as excellent sources of documentation for what you can accomplish with them.

Here, I am retrieving all the defined abilities and listing their names to provide a quick overview.

```
use Illuminate\Contracts\Auth\Access\Gate;

$gates = app(Gate::class)->abilities();
echo implode("\n", array_keys($gates));
```
What the abilities method gives us is an associative array with key names and the corresponding closures - because that's how gate-based authorization works in Laravel. Gates provide a simple, Closure (a type of anonymous function in PHP) based approach to authorization.

```
[
  "viewHorizon" => Closure($user) {#446 …4},
  "viewTelescope" => Closure($user) {#449 …4},
]
```
For now, we'll output a list with all their names. Helpful? A bit, yes - I can now at least know what to search for and inspect in my codebase. Should we be able to take a quick look at the contents as well? Well, the whole closure aspect of it requires some extra tinkering before we can look under their hood.
Guest Post
Published: 2023-05-26 12:48:44

https://digiwebglobal.com/everything-you-need-to-know-about-choosing-the-right-custom-lotion-boxes/
https://b.cari.com.my/home.php?mod=space&uid=2591259&do=blog&id=421541
https://www.muzzmagazines.com/2023/05/26/custom-face-mask-boxes/
https://dfiestayaccesorios.com.mx/everything-you-need-to-know-about-choosing-the-right-custom-cosmetic-boxes/
https://www.bloghalt.com/?p=22664&snax_post_submission=success
https://moxn5ycafzg.com/?p=3267&preview=true
https://losanews.com/custom-eyeliner-boxes/
https://edtechreader.com/?p=38800&preview=true
https://olascar.com/?p=9409
https://picukipro.com/?p=8184
https://postinghead.com/?p=14085&preview=true
https://www.ideasforusa.com/?p=7402
https://ravibarot.com/everything-you-need-to-know-about-choosing-the-right-custom-lip-gloss-boxes/
https://codegammy.com/custom-lipstick-boxes/
https://midbee.com/read-blog/810
https://cytacik.pl/cytaty/72373/custom-mascara-boxes/
https://ertaza.com/read-blog/8205
https://readnewsblog.com/everything-you-need-to-know-about-choosing-the-right-custom-perfume-boxes/
https://justreadings.com/?p=4244&preview=true
https://www.businessmagazine.org/?p=35023&preview=true
Performance na validação de e-mail em .NET
Tags: dotnet, email, regex, performance
Published: 2023-05-26 12:44:33

Todo dev, desde o iniciante até o sênior, já fez uma validação de e-mail, seja em .NET ou em sua linguagem. E Sempre utilizamos a expressão regular para isto.. Não é mesmo?

O .NET vem aprimorando e trazendo novas funcionalidades a cada versão. Você conhece a `System.Net.Mail`?

No .NET há diferentes maneiras, incluindo `Regex, EmailAddressAttribute, RegularExpressionAttribute , MailAddress` ou usando bibliotecas externas

**System.Net.Mail**

Você sabia que pode utilizar o construtor `MailAdress` que se encontra na biblioteca `System.Net.Mail`'

Ela segue o padrão RFC 2822 de padrão de envio de mensagem, o E-mail.

**Utilizando System.Net.Mail**
Basta dar um using de System.Net.Mail e utilizar método abaixo:

> public bool CheckEmail_MailAddress() =>
>             MailAddress.TryCreate("marcio.kgr@gmail.com", out var _);

**Benchmark**

A pergunta é, se vale a pena utilizar ele ao invés da forma convencional utilizando a expressão regular.

Vamos ao resultado do Benchmark utilizando .NET 7

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

Veja que dependendo da forma de utilização da expressão regular, ela pode ser muito mais performática.

**Considerações**

Levando em conta a complexidade de trabalhar com Expressão regular e performance do que o .NET já entrega na biblioteca, é muito interessante a sua utilização

Links: [Github ValidacaoEmailBenchmark](https://github.com/marciokgr/ValidacaoEmailBenchmark)
How to Install Magento 2 on AWS
Tags: magento, magento2, magento2tutorial
Published: 2023-05-26 12:23:06

Greetings, dear readers! I'm thrilled to share with you some valuable insights on **_How to Install Magento 2 on AWS_**. Magento is a powerful open-source eCommerce platform that enables businesses of all sizes to effortlessly build and manage their online stores. AWS, on the other hand, is a versatile cloud computing platform offering a wide array of services and tools for efficient application running and infrastructure management.

If you're new to the realms of eCommerce and cloud computing, setting up Magento 2 on AWS might seem overwhelming. But fret not! With the right guidance and support, this process can be made simple and straightforward. In this comprehensive guide, I'll take you through each step, starting from provisioning the necessary AWS resources, configuring the server, and finally installing Magento 2 itself.

Whether you're an experienced developer, a small business owner, or simply an eCommerce enthusiast, this guide caters to your unique needs and requirements. By the end of this tutorial, you'll have a fully functional Magento 2 installation up and running on AWS, ready for you to build and manage your online store like a pro!

For more information , please visit this :- **_[https://webguru.dev/how-to-install-magento-2-on-aws-amazon-web-services/](https://webguru.dev/how-to-install-magento-2-on-aws-amazon-web-services/
)_**
Elevate Your Brand with Custom Packaging Solutions from California's Bes
Published: 2023-05-26 12:23:02

https://www.simplenshort.com/2023/05/26/custom-apparel-boxes/
https://blogports.com/?p=48907&preview=true
https://readnewsblog.com/what-are-the-advantages-of-using-eco-friendly-custom-apparel-boxes/
https://spectrumdigi.com/custom-apparel-boxes/
https://recipesarticle.com/what-are-custom-bubble-mailers-and-how-do-they-differ-from-regular-mailers/?snax_post_submission=success
https://dfiestayaccesorios.com.mx/how-to-choose-the-right-size-custom-bubble-mailers-for-your-products/
https://www.shvong.com/dispose-of-custom-bubble-mailers-in-responsible-way/
https://whatstrending.pro/?p=2942
https://ertaza.com/read-blog/8152
https://nvweekly.co.uk/?p=2222
https://www.muzzmagazines.com/2023/05/26/what-are-the-advantages-of-using-custom-chipboard-boxes/
https://b.cari.com.my/forum.php?mod=viewthread&tid=5178588&extra= 
https://theamberpost.com/post/what-printing-and-customization-options-are-available-for-custom-chipboard-boxes
https://www.elephantjournal.com/2023/05/what-are-custom-cube-boxes-and-how-are-they-used-in-packaging/
https://findtec.co.uk/index.php/2023/05/26/custom-cube-boxes/
https://blogspotgroup.com/2023/05/26/how-can-custom-printing-enhance-the-look-of-custom-cube-boxes/
https://stompster.com/read-blog/116676
https://writeupcafe.com/benefits-of-using-custom-die-cut-boxes-for-packaging/
https://ifvod-tv.net/?p=237&preview=true
https://payrchat.com/blogs/434/how-do-custom-die-cut-boxes-impact-sustainability-efforts-in-packaging
The Best Icon Library for Web Development
Tags: webdev, javascript, web, programming
Published: 2023-05-26 12:16:59

This library is lite and easy to use. It offers a wide range of icons covering various categories such as communication, devices, social media, and more. The library aims to provide a simple and efficient way to include icons in your projects without relying on external resources or complex dependencies.

In this article, I will show you https://icones.js.org/ the best Icon library that I am using. That library is called Icones.js . Icones.js is a lightweight JavaScript library that provides a collection of customizable, vector-based icons that can be easily used in web applications. It offers a wide range of icons covering various categories such as communication, devices, social media, and more. The library aims to provide a simple and efficient way to include icons in your projects without relying on external resources or complex dependencies.

Read the Original Blog Here: https://www.jenuel.dev/blog/The-Best-Icon-Library-for-Web-Development
Introduce new type using a function return type
Tags: typescript, utility
Published: 2023-05-26 12:05:31

In TypeScript, you can introduce a new type using the `type` keyword or using an interface. If you want to define a new type based on a function return type, you can use the `ReturnType` utility type.

Here's an example:

```typescript
function calculateSum(a: number, b: number): number {
  return a + b;
}

type SumResult = ReturnType<typeof calculateSum>;

const result: SumResult = 5;
console.log(result); // Output: 5
```

In this example, we have a function `calculateSum` that takes two numbers and returns their sum. We can use the `ReturnType` utility type to capture the return type of the function, which in this case is `number`. Then, we create a new type `SumResult` based on the return type of `calculateSum`.

You can use the `SumResult` type to declare variables, function return types, or any other place where a type is expected. In this case, we assign the value `5` to a variable `result` of type `SumResult`, which is `number`, and then print it to the console.

This way, you can introduce a new type based on a function's return type using the `ReturnType` utility type in TypeScript.
Seeking for Help
Published: 2023-05-26 11:34:54

I am a student practicing on Yml. Please I a trying to create a manifest in Kubernetes. I wrote this and it says my line 10 is having issues 
kind: Service
apiVersion: v1
metadata:
   name: myappsvc
   namespace:dev
Spec:
 type: ClusterIP
 ports:
 - port:80
   targetport:8080      this is line 10
  Selector:
     app: myapp
error: error parsing svc.yml: error converting YAML to JSON: yaml: line 10: did not find expected key. I need help