teleren/devto huggingface dataset:
Customizing API Resource Pagination Structure
Tags: laravel, eloquent, apiresource, pagination
Published: 2024-04-21 20:00:56

We have been in the same boat, trying to figure out customizing the pagination structure that was returned from the resource or resource collection. Records are wrapped in `data` key with additional `links` and `meta` that might be unnecessary or want to modify for a different scenario.

Before Laravel 10, you need extra steps to create base resource class that extends `JsonResource`, modify the `collection` method from the `JsonResource` and stuffs. Check [this](https://github.com/laravel/framework/discussions/41513#discussioncomment-2382958) github discussion to modify the structure.

Starting from Laravel 10, there is a method called `paginationInformation` that can customize pagination data structure. All you have to do is define the method on the resource collection and modify the structure.

As [docs](https://laravel.com/docs/10.x/eloquent-resources#customizing-the-pagination-information) per se

This method will receive the `$paginated` data and the array of `$default` information, which is an array containing the `links` and `meta` keys:

```php
public function paginationInformation($request, $paginated, $default)
{
    $default['pagination']['current_page'] = $default['meta']['current_page'];
    $default['pagination']['last_page'] = $default['meta']['last_page'];
    $default['pagination']['per_page'] = $default['meta']['per_page'];
    $default['pagination']['total'] = $default['meta']['total'];

    unset($default['links']);
    unset($default['meta']);
}
```

The JSON response structure will be
```json
{
    "data": [
        {}, 
        {}
    ],
    "pagination": {
        "current_page": "",
        "last_page": "",
        "per_page": "",
        "total": ""
    }
}
```

You may create a base class, define the function and extends the class from resource collection class to prevent code duplication.

```php
<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\ResourceCollection;

class BaseResourceCollection extends ResourceCollection
{
    public function paginationInformation($request, $paginated, $default)
    {
        $default['pagination']['current_page'] = $default['meta']['current_page'];
        $default['pagination']['last_page'] = $default['meta']['last_page'];
        $default['pagination']['per_page'] = $default['meta']['per_page'];
        $default['pagination']['total'] = $default['meta']['total'];

        unset($default['links']);
        unset($default['meta']);

        return $default;
    }
}
```

```php
<?php

namespace App\Http\Resources;

use Illuminate\Http\Request;

class UserCollection extends BaseResourceCollection
{
    public function toArray(Request $request): array
    {
        return parent::toArray($request);
    }
}
```

Happy Tinkering ✌️
Whatsapp +15715412918 THE MOST FASTEST AND TRUSTED BITCOIN RECOVERY COMPANY / ADWARE RECOVERY SPECIALIST
Published: 2024-04-21 19:35:17

WhatsApp info: +1 (571) 541‑2918

Website info: www.adwarerecoveryspecialist.expert

Telegram info: @AWARE_RECOVERY_SPECIALIST


So, I thought I was going to ride the Bitcoin wave to financial freedom, only to get caught in a rip current of scams and fraud. Welcome to the wild world of Bitcoin investment, where promises of quick riches can quickly turn into financial nightmares. I took the plunge, invested my hard-earned cash into Bitcoin, and thought I was on my way to becoming the next crypto millionaire. The scammer, with their slick talk and promises of guaranteed returns, reeled me in faster than I could say "blockchain." But then reality hit like a ton of digital bricks. I realized I had been duped, my funds vanished into the murky depths of the crypto abyss, and I was left feeling like a Bitcoin beginner all over again – broke and bewildered. In swoops ADWARE RECOVERY SPECIALIST  like a digital superhero, ready to rescue me from the clutches of the scammer and help me reclaim what's rightfully mine. With their expertise and savvy skills, they're here to turn the tables on those cyber villains. I handed over the reins to ADWARE RECOVERY SPECIALIST, crossing my fingers and hoping for the best. With a mix of anticipation and skepticism, I watched as they delved into the depths of the digital underworld to track down my lost funds.  Through a meticulous process of verification and investigation, ADWARE RECOVERY SPECIALIST left no digital stone unturned. Every virtual breadcrumb was followed, every cyber trail was pursued, until the scammer's digital footprints led straight to the pot of Bitcoin gold. With a solid plan in place, ADWARE RECOVERY SPECIALIST sprung into action. They employed their recovery strategy like a well-oiled machine, executing precise maneuvers to outsmart the scammers and secure my funds back into my digital wallet. In the end, I emerged victorious, a savvy Bitcoin investor once again – thanks to the efficient services of ADWARE RECOVERY SPECIALIST. ADWARE RECOVERY SPECIALIST is to be contacted by the information above:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ozv7znj2jsusp8lcck7.jpg)
Domino tiling library
Tags: math, javascript, datascience
Published: 2024-04-22 06:18:53

---
title: Domino tiling library
published: true
date: 2024-04-21 19:30:00 UTC
tags: ['math', 'javascript', 'datascience']
canonical_url: https://dawidrylko.com/domino-tiling-library/
cover_image: https://dawidrylko.com/static/1520745f1a464adec2d546d8b861fac5/92575/domino-tiling-library.webp
---

Projekt "Domino tiling" został odseparowany do osobnego repozytorium na GitHubie. Znajdziesz tam algorytmy, benchmarki oraz testy. Zapraszam do testowania oraz zgłaszania propozycji nowych funkcjonalności.

**[Czytaj dalej](https://dawidrylko.com/domino-tiling-library/).**
Lessons for me on leadership, from a film about apes
Tags: nontech, musings
Published: 2024-04-21 19:25:13

![](https://cdn.swish.ink/caf2243d-94c4-49d1-9204-11e4c63a6b5f/media/caesar-apes.png)

Watching *Dawn of the Planet of the Apes* gave me some thoughts about dictatorship, and more broadly, leadership. Mostly regarding at work, but also in other areas of my life. These are things that are also present in the real world, but somehow, it took a movie on apes for me to grasp them.

Dictators \(both Caesar and Koba\) *take* power. They don't wait around for a consensus that they're the leader. They take decisions, and you must accept it \(or take a chance and rebel\). This—taking one\-sided decisions—is something I suck at. I always try to be "reasonable" and listen to others' opinions. This is nice \(it makes me a great colleague\) but makes me poor in situations where consensus is unclear, or where strong leadership is needed.

This assumption of power is connected to confidence. For it to work, the dictator must not entertain doubt within themselves. They must believe completely in the legitimacy of their rule. For Caesar and Koba to be effective, they couldn't afford to have moments of repentance. No impostor syndrome. No wondering, "Who even gave me the right to be in charge? What if these people realize I'm no more special than they are?" Nope, you move forward. Even when you seize power via a coup, you must not doubt that you're right.

Dictators create their own authority. Sometimes through fear, sometimes through respect.

I think that these things are why dictatorship works, and also why it doesn't work. A dictator is always taking a gamble. Sure, they don't depend on consensus, but that also means consensus could someday overthrow them. Or another dictator could rise against them.

Translating this to my work \(and life\): I'm often reluctant to *take* power. I'm fine with being appointed or elected to lead, but I rarely decide to be in charge of others. I'd rather do shit myself than ask people over whom I have no explicit authority \(eg superiors, peers, even juniors that don't explicitly report to me\) to do it. But that's because I play it safe. I don't like taking a gamble, taking the risk of people refusing to cooperate or my leadership being questioned or my decisions backfiring. This is something I should improve on.

My ability to listen to others' opinions is gold, and I should not lose it. But at the same time, I should be ready to matter\-of\-factly take decisions when needed, and not always shy away.

**Postscript**: Interestingly, the feedback I got in my last peer review kinda amounted to this. Positive feedback talking about how I'm a great engineer and teammate, and critical feedback saying I could improve in confidence. It makes sense now.
AWS Cloud Practitioner Certification
Published: 2024-04-21 17:03:26




**AWS  Cloud Practitioner Certification**
Preparing for practitioner certifications could be harder than imagined...

Nobody talks about how much time and dedication these exam preparations can take. So in this article I will be talking about the strategies which I used and also how I got overwhelmed and stuck in the middle of the preparations!!!

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



#Let's break this problem down into parts.

**Dedication & Consistency**

_"Being consistent means dedicating yourself to your goals and staying focused on the things and activities to achieve them."_

So, dedicate your time and then be consistent as without consistency nothing will work.

**AWS official website / AWS Educate**

AWS Educate is open to any individual, regardless of where they are in their education, technical experience, or career journey.

If you’re overwhelmed by too many choices when it comes to learning about the cloud, AWS Educate is here to help. Cloud beginners like you are invited to check out their free, self-paced online training resources and labs designed to help you learn, practice, and evaluate your cloud skills without having to create an Amazon account.

**AWS Cloud Practitioner Essentials** - Sign up for this course and go through this very detailed and super engaging videos by AWS trainers, It will give you an Idea that what exactly you all have to study for this examination.

https://explore.skillbuilder.aws/learn/course/134/aws-cloud-practitioner-essentials


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




**WAIT!!! WAIT!!! WAIT!!!**

don't forget to go through exam guide first, to get the better understanding of the exam.

https://d1.awsstatic.com/training-and-certification/docs-cloud-practitioner/AWS-Certified-Cloud-Practitioner_Exam-Guide.pdf

**Power of writing down everything you Learn**

Writing about what you learn helps in retaining the information for a longer time. The process of translating thoughts into words engages multiple cognitive faculties, reinforcing memory.

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



_don't forget to share the notes!!! ;)_



**Practice Test**

Must buy any practice test before appearing for exam, as it is highly important to check your knowledge before taking the real exam.

there are many practice test available online, you can check and go through them to gain confidence.

**My free course**

I have created a course for the beginners which is available for free on Udemy.

But you need to learn more than this course, as it is designed only for beginners with easy explanation.

https://www.udemy.com/course/aws-from-scratch/?referralCode=40A977B050DB8C662410

**GOOD LUCK!!! HAPPY LEARNING!!!**
Stream Video from Raspberry Pi Camera to YouTube Live
Tags: youtube, python, raspberrypi, coding
Published: 2024-04-21 18:52:05

{% embed https://www.youtube.com/watch?v=OcrY1MCQJkQ %}

Learn how to easily stream video from your Raspberry Pi to YouTube live in Python in a few simple steps. By the end of this video, you will be able to have a publicly viewable live stream with a simple hardware setup.
Before reading the remainder, be sure to subscribe and support the channel if you have not!

**Subscribe:**
Youtube

**Support:**
https://www.buymeacoffee.com/mmshilleh

## Step 1-) Library Setup

Run the following commands in a terminal on Raspberry Pi
sudo apt install python3-picamera ffmpeg

## Step 2-) Code Setup

Now that you have the libraries you can go ahead and create a Python file and substitute this code.

```
import subprocess
from picamera import PiCamera
from time import sleep



## Author: Mahmood Mustafa Youssef Shilleh
## DONATE AT: https://buymeacoffee.com/mmshilleh

# Set up camera constants
RESOLUTION = (640, 480)  # Can be adjusted based on your needs
FRAMERATE = 24           # Adjust this based on your camera's capabilities

# YouTube Stream URL and Key
YOUTUBE_URL = "rtmp://a.rtmp.youtube.com/live2"
YOUTUBE_KEY = "<key>"  # Replace with your actual YouTube stream key

# Construct the FFmpeg command for streaming
stream_cmd = f'ffmpeg -ar 44100 -ac 2 -acodec pcm_s16le -f s16le -ac 2 -i /dev/zero -f h264 -i - -vcodec copy -acodec aac -ab 128k -g 50 -strict experimental -f flv {YOUTUBE_URL}/{YOUTUBE_KEY}'

# Initialize the camera
camera = PiCamera(resolution=RESOLUTION, framerate=FRAMERATE)
camera.start_preview()
sleep(2)  # Camera warm-up time

# Start the streaming subprocess
stream_pipe = subprocess.Popen(stream_cmd, shell=True, stdin=subprocess.PIPE)

# Start recording and streaming
camera.start_recording(stream_pipe.stdin, format='h264')

try:
    while True:
        sleep(60)
except KeyboardInterrupt:
    # Stop recording upon receiving a keyboard interrupt (Ctrl+C)
    camera.stop_recording()

# Clean up the resources
stream_pipe.stdin.close()
stream_pipe.wait()
camera.close()
The only thing you need to do is substitute your streaming key, which you can get from YouTube when you start a live stream.
Screenshot 2024-04-20 at 10.12.56 PM.png
```

**Conclusion:**

That should be all you need to stream to YouTube live! Hope you got it working. If you did, please subscribe to the channel or consider donating at the buymeacoffee link above. Thanks.
Reverse Engineering: A Comprehensive Exploration
Tags: engineering, architecture
Published: 2024-04-21 18:42:54

## **Introduction**

Reverse engineering is an intriguing and methodical approach to understanding the inner workings of a product or system. It’s akin to solving a puzzle by examining the completed picture to deduce how the pieces fit together. This practice is not only about disassembly and analysis; it’s a gateway to innovation, allowing us to replicate, improve upon, or even circumvent existing designs.


## **The Core Principles**

The essence of reverse engineering lies in its systematic deconstruction. It involves:

- Identifying the product’s purpose and functionality.
- Disassembling it to examine its components.
- Analyzing each part to understand the product as a whole. This process is driven by curiosity and the desire to learn, often leading to significant breakthroughs in technology and design.


## **Ethical and Legal Landscape**

Navigating the ethical and legal aspects of reverse engineering is crucial. Practitioners must respect intellectual property rights while leveraging this technique for legitimate purposes such as compatibility, interoperability, and security analysis.


## **Advanced Tools and Techniques**

The modern reverse engineer’s arsenal includes a variety of sophisticated tools:

**- Software Analysis:** Disassemblers like IDA Pro, debuggers such as GDB, and decompilers for various programming languages.
**- Hardware Inspection:** Precision measuring instruments, 3D scanners, and electron microscopes for detailed examination.


## **Real-World Applications**

Reverse engineering is not confined to one industry or purpose. It’s employed in:

**- Cybersecurity:** To dissect malware and fortify defenses.
**- Manufacturing:** For competitive analysis and product improvement.
**- Legacy Systems:** To maintain and update outdated technology.


## **Insightful Case Studies**

The article could delve into specific instances where reverse engineering made a significant impact. For example, the reverse engineering of a popular operating system for enhanced security features, or the analysis of a vintage car engine for restoration purposes.


## **Conclusion**

Reverse engineering is a testament to the relentless human pursuit of knowledge. It’s a discipline that fosters innovation, safeguards digital infrastructure, and drives competitive intelligence. As we continue to push the boundaries of technology, reverse engineering will remain a cornerstone of technological evolution.

I’ve added more technical details and expanded on the applications and case studies to provide a richer understanding of the topic. If you have specific areas you’d like to focus on or any other adjustments in mind, feel free to let me know!
Elevate Your Web Design with Codepem's CSS Gradient Generator
Tags: gradientgenerator, rgb, webdev, beginners
Published: 2024-04-21 18:38:52

Are you tired of struggling to create eye-catching gradient backgrounds for your web projects? Say goodbye to tedious manual coding and hello to effortless gradient generation with Codepem's [CSS Gradient Generator](https://codepem.com/css-generator/gradient-generator)!

Our tool empowers developers of all skill levels to easily create stunning gradients that will elevate the visual appeal of any website. Whether you're a seasoned developer looking to streamline your workflow or a beginner eager to add professional flair to your projects, our CSS Gradient Generator is the perfect solution.

**Here's why developers love our tool:
**
Easy to Use: Our user-friendly interface makes it simple to customize gradients to your exact specifications. No more wasting time tweaking code – with just a few clicks, you can create gradients that perfectly complement your design aesthetic.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6fp1kn2mmqxjffscrj0z.png)
**Versatile Options**: Choose from linear, radial, or conic gradients to achieve the desired effect for your website backgrounds. Experiment with different color combinations, angles, and positions to [create gradients](https://codepem.com/css-generator/gradient-generator) that stand out from the crowd.
**Instant CSS Code**: Once you've created the perfect gradient, our generator automatically generates the corresponding CSS code for you. Simply copy and paste the code into your stylesheet, and you're ready to go!
Download Gradient Images: Need gradient images for your projects? With our tool, you can easily download gradient images in PNG or JPEG format. Share them with colleagues or use them to enhance your website designs – the possibilities are endless.
Don't settle for bland, uninspired website backgrounds. Take your web design to the next level with Codepem's CSS Gradient Generator. Try it now and see the difference it can make in your projects!
axis 0 && 1
Published: 2024-04-21 18:20:56

pandas da axis=1 anlamı sutunların birleşmesi yani yatay şekilde birleşir. Yatay birleşme kısaca birleştiği zaman yatay'a doğru genişle. Dikey birleşmeden kasıt ise aşşağa doğru genişlemek. 

pandas ta Axis=0 demek ise dikey olarak birleşir yani satır olarak  birleşir, genişler demektir. 

numpy da da bu dediklerimiz tam tersi anlamda olur.
Do not use <div> in React😎😯👩‍💻
Tags: react, beginners, javascript, fragments
Published: 2024-04-21 18:16:33

**Howdy People,**😍🙋‍♀️
I'm on this fantastic journey where I'm exploring new & fun concepts of **React**. 
This concept of **Fragments** sounds like the perfect 
**<u>SHORTCUT</u>** ever 🤣😂

![Fragments](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fkmdyirz4afdifmxjnq5.gif)


We all use `<div>` everytime when we work in html to make containers or wrap elements inside one element.🥱😴

In React JSX, 
To return multiple components or elements we have to wrap & group all the elements inside a wrapper like div.

But in most of the cases that div is not required at all & it takes an extra space in the DOM but still we have to use it because that's how React works.
So, react introduced a new feature in **`React 16.2`** which are **React Fragments** 🤑🤑🤑
![Fragments](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cdarf1heiwhytctnq4w4.gif)



Now **React Fragments** works exactly like Div, you can wrap or group multiple elements with Fragments.

```
return(
    <React.Fragment>
        <MyComponent1 />
        <MyComponent2 />
        <MyComponent3 />
    </React.Fragment>
)
```

Also you can use Fragments shorthand **(<> </>)** instead of **React.Fragment**,
example :
```
return(
    <>
        <MyComponent1 />
        <MyComponent2 />
        <MyComponent3 />
    </>
)
```

## But why to use Fragments?? 🤔🤔🤔


**Fast**
Div element creates a node in DOM & occupy some space, but Fragments doesn't do any of this.


**Less cluttered DOM**
Having many nested div makes the DOM large & hard to read or debug but with Fragments, DOM becomes a little easy to look at and debug.

Okay Bye, Hope you liked this shortcut of mine!!
Feel free to add comments & hit likes.
🫡👌⭐💛👍
Manual Test Case Part 2
Published: 2024-04-21 17:58:09

Q2. Suppose you are a software tester and you are assigned to test a new mobile app that

has just been developed. The app has three different user roles: basic user, premium user,

and admin user. You have been given the following three test scenarios to execute:

Basic users can only access limited features of the app, while premium users can access all features. Admin users have access to advanced settings and can perform all actions.

• Users should be able to create and delete their accounts successfully. Passwords must meet the required complexity standards and users should receive a confirmation email upon successful account creation.

• Users should be able to navigate through the app seamlessly without any crashes or

performance issues. The app should also display appropriate error messages when a user

attempts to perform an action they are not authorized to perform.

For each of the test scenarios, describe the steps you would take to test them and the expected results

Ans: I've attached the results in the form of sheet
Please verify it

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