teleren/devto huggingface dataset:
Our way: Eloquent
Tags: laravel, codestyle, php
Published: 2023-10-12 03:05:02


👉 Go to [Summary](https://dev.to/robsontenorio/or-way-laravel-code-guidelines-7p0)

> There is no wrong or right way, there is our way.
>
> -- Someone 


.
.
.

### One method per line


**WTF!?**

```php
User::with('some')->whereHas('thing')->where(...)->orderBy(...)->get()
```


**Nice!**

```php
User::query()
  ->with('some')
  ->whereHas('thing')
  ->where(...)
  ->orderBy(...)
  ->get()
```

**Nice!**

```php
// No problem if it is short
User::where('age', 18)->first();
```

.
.
.
## The `scopeXXXX()`

**WTF!?**

```php
$activeUsers = User::where('active', true)->get()

// Same `active` logic
$activeAgedUsers =  User::query()
   ->where('active', true)
   ->where('age', '>=', 60)
   ->get();

// Same `active` and `age` logic
$activeAgedMaleUsers =  User::query()
   ->where('active', true)
   ->where('age', '>=', 60)
   ->where('gender', 'male')
   ->get();
```

**Nice!**

```php
$activeUsers = User::active()->get();
$activeAndAgedUsers = User::active()->aged()->get();
$activeAgedMaleUsers = User::active()->aged()->male()->get();


public function scopeAged(Builder $query): Builder
{
   return $query->where('age', '>=', 60);
}

public function scopeMale(Builder $query): Builder
{
   return $query->where('gender', 'male');
}

public function scopeActive(Builder $query): Builder
{
   return $query->where('active', true);
}
```


.
.
.

## The `count()`

**WTF!?**

```php
// It loads ALL rows in memory, then count.
User::get()->count();
```

**Nice!**

```php
// Count inside database
User::count();
```

.
.
.

## The `lazy()`

**WTF!?**

```php
// It loads ALL rows in memory, then starts loop
User::query()
   ->get()  // <-- here
   ->foreach(...);    

```

**Nice!**

```php
// Do it only if you really need to check ALL rows
// It loads chunked results and start loop immediately 
User::query()
   ->lazy()   // <-- here
   ->foreach(...);    
```

**Nice!**

```php
// 99% of time you need this
User::query()->paginate(50);
```



.
.
.


## The `when()`

**WTF!?**

```php
$results = User::where(...);

if($condition1){
   $results = $results->where('active', true);
}

if($condition2){
   $results = $results->where('age', '>=', 18);
}


return $results->get();

```

**Nice!**

```php
return User::query()
      ->when($condition1, fn($query) => $query->where('active', true))
      ->when($condition2, fn($query) => $query->where('age', '>=' 18))
      ->get();

```
Hacktoberfest Pledge 2023 🥇
Tags: hacktoberfest23, programming
Published: 2023-10-12 03:04:42

I'm thrilled to be a part of the DEV community and participate in Hacktoberfest 2023! I'm Yaduttam, and I'm eagerly looking forward to this exciting event. My primary goal during this Hacktoberfest is to delve into various technologies and expand my knowledge base. Whether I'm contributing to existing projects, initiating new ones, or simply absorbing the wealth of knowledge from this fantastic community, I'm fully prepared to make the most of this month. Together, let's transform Hacktoberfest 2023 into a month of significant growth, continuous learning, and impactful contributions! 🚀🌟
Building Raspberry Pi Paper Cyberdeck
Tags: raspberrypi, cyberdeck, computerscience, cseducatio
Published: 2023-10-12 02:56:47

## Introduction

Are you looking for a fun and educational project to engage your coding club members? Building a "Raspberry Pi Paper" computer is an exciting endeavor that combines coding, electronics, and crafting. 


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

In this article, we'll guide you through the process of creating a simple yet functional Raspberry Pi-powered paper computer that can be a fantastic hands-on learning experience for middle and high school students.


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

## Materials Needed

Before you start, gather the following materials:

1.	Raspberry Pi 400
2.	MicroSD card (8GB or larger)
3.	LCD screen
4.	HDMI cable 
5.	USB PowerBank (to make it portable)
6.	Power supply USB cable
7.	A piece of flexible cardboard
8.	Assorted craft supplies (markers, colored paper, glue, scissors, etc.)


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

Let's do first a quick test with the case. Connect the LCD panel to the Raspberry Pi 400 computer using the HDMI cable and then power on the entire assembly.

If everthing works, you can start designing a case around these components using thing cardboard.

## Designing the Paper Computer

1.	Measure and cut the cardboard into a size that fits the Raspberry Pi and screen comfortably.
2.	Design the layout of your paper computer. You can use markers, colored paper, and other craft supplies to make it visually appealing.
3.	Cut holes in the board to accommodate the Raspberry Pi 400 keyboard and screen.
4.	Attach the Raspberry Pi 400 and screen securely to the board using glue or double-sided tape.
5.	Connect the screen to the Raspberry Pi 400 using the HDMI cable
6.	Connect the USB power bank using the USB cable
7.	Decorate your paper computer with creative elements like labels and graphics. 
8.	Ensure that all the components are neatly arranged and the cables are organized.



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

This is the back of the computer. You can use shorter cables for a more aesthetic look.

## Use a code editor

1.	Open [codeguppy.com](https://codeguppy.com) in a browser on the new Raspberry Pi paper computer
2.	Code a small program
3.	Currently the UI of codeguppy.com is not optimized for small and ultrawide screens but also this computer is not for real coding.

![](img/img04.jpg)

![](img/img05.jpg)

## Conclusion

Building a "Raspberry Pi Paper" computer in your coding club is a fantastic way to introduce students to coding, electronics, and creative design. So, grab your Raspberry Pi 400 and the other supplies, and start building your own paper computer today!

---

Article reposted from: https://codeguppy.com/blog/building-a-raspberry-pi-paper-computer-in-your-coding-club/index.html
Scrape unstructured data and transform to structured
Published: 2023-10-12 02:47:34

I am a newcomer in need of some guidance. I am currently working on scraping mobile plans from various operators in a specific country using BeautifulSoup and Requests. The data on the web is mostly presented as texts in a card format. After scraping all the raw texts, I employ regular expressions to extract key details such as price, internet quota, call quota and other info. 

The challenge I am facing is that the data is incredibly unstructured, and I cannot obtain the expected data. I managed to scrape all the text in the web page, but after applying regex, the data are very messy (each row have only a single data). I would greatly appreciate any help, suggestions or insights from the community. I attached the image of messy data that I mentioned above: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/e3mjl31qbsit9qyv04ip.png)
Prototype In Javascript
Tags: prototype, prototypechaining, javascript, interview
Published: 2023-10-12 02:43:45

**Prototype**

Prototypes are the mechanism by which JavaScript objects inherit features from one another.

In class based languages we have a class which contains all the properties and methods defined inside the class.

When the object of the class is created the newly created object has the access to the properties and the public methods defined inside the class.

Prototype is very similar to the class which acts as the blueprint of the JavaScript objects.

The newly created JavaScript object has access to all the properties and methods of the prototype from which the object is created in addition to its own properties and methods.

Also due to the dynamic nature of the JavaScript we can not only add properties to an object dynamically but we can also add properties to the prototype object which would mean adding a property or behavior to the base class at runtime so that all the newly created objects have access to the properties added dynamically to the prototype object.

```js
// creating an object constructor
function Employee(name, age) {
  this.name = name;
  this.age = age;
}
//creating an object of type Employee
let Employee1 = new Employee("John", 32);
let Employee2 = new Employee("Mary", 32);

console.log(Employee1);
console.log(Employee2);

//adding property to Employee1 instance dynamically
// it will be available only for this Employee1
Employee1.sports = "Cricket";

//adding property to the prototype of the Employee
//this would add the gender property to all the
//existing object instance of the Employee object
//and would initialize it to null
Employee.prototype.gender = null;

// although Employee3 is created with name and age
// initialized but the gender property would also
//be attached to it and assigned as null because
//of the above mentioned line of code.
let Employee3 = new Employee("Anna", 26);

console.log(Employee1, Employee2, Employee3);

```

Prototype Chaining
Prototypes are the means of inheritance in JavaScript. The prototype of an object would also have a prototype object. This continues until we reach the top level when there is no prototype object.

This is called prototype chaining or prototype chain in JavaScript.

The properties defined on the prototype objects are also accessible to the object instance. And this is the reason why we are able to access properties which we have not defined explicitly on an object since those are accessible by inheritance through the prototype chaining.

When we try to access any property of an object it is first checked in the own property of the object.

If the property does not exist in the own property then the prototype object is scanned for that property. This continues until we get the property we are accessing or we reach at to the end of prototype chain giving undefined.

```
console.log(Employee1.__proto__);
console.log(Employee1.__proto__.__proto__);
console.log(Employee1.__proto__.__proto__.__proto__);
```
Commuting level up
Published: 2023-09-28 13:16:44

Just a collection of stuff for that 1% growth

SEP-OCT
- DitalOcean article: [What is Kubernetes?](https://www.digitalocean.com/community/tutorials/an-introduction-to-kubernetes)
- YT: [Cache systems Every Dev Should know](https://youtu.be/dGAgxozNWFE?si=ceqDUQcGu75yJUpj)
- YT: [System Design for Beginners Course](https://youtu.be/m8Icp_Cid5o?si=vGFAdpLLVe12oKoN) 
- YT: [Google system design interview: Design Spotify](https://youtu.be/_K-eupuDVEc?si=8F9OK-RAq6rFBQs0)

- YT: [Basic system design for Uber](https://youtu.be/R_agd5qZ26Y?si=hAHqMT40Li7yyvRFw) 
- DitalOcean article: [SQLite vs MySQL vs PostgreSQL](https://www.digitalocean.com/community/tutorials/sqlite-vs-mysql-vs-postgresql-a-comparison-of-relational-database-management-systems)

- YT: [Top 6 Popular API Architecture Styles](https://www.youtube.com/watch?v=4vLxWqE94l4&ab_channel=ByteByteGo)

- YT: [I built the same app 3 times| which python Framework is best? Django vs Flask vs FastAPI ](https://youtu.be/3vfum74ggHE?si=QkuFhLxCYU5h9wmu) 
- YT: [I've been using Redis wrong this whole time... ](https://youtu.be/WQ61RL1GpEE?si=tGph0xclZ-Ohbrvx)
10 Features Driving Your Chrome Extension Development
Tags: webdev, javascript, frontend, programming
Published: 2023-10-12 02:11:15

Chrome extensions are mini-apps that can greatly enhance your browsing experience by adding new functionalities and features to your browser. They're versatile, easy to create, and can be a fantastic way to learn web development. In this article, we'll explore ten compelling features that will drive your motivation to learn Chrome extension development.

### 1. **Customization**: 

Chrome extensions provide a customizable experience. You can tailor them to suit your needs, whether it's improving productivity, enhancing security, or simplifying daily tasks.

### 2. **Accessibility**: 

Chrome extensions make web accessibility easier. You can create tools to help users with disabilities navigate the web more effectively, ensuring a more inclusive online experience.

### 3. **Interactivity**: 

Extensions can interact with web pages, allowing you to modify content, automate repetitive tasks, or even create interactive games. The possibilities are endless.

### 4. **Security**: 

Chrome extensions can bolster your online security. You can develop extensions that protect against phishing, malware, or other potential threats, keeping you and your data safe.

### 5. **Data Management**: 

Extensions enable you to better manage your data. You can build tools for saving, organizing, or exporting web content, helping you stay organized.

### 6. **User Interface Enhancement**: 
You can develop extensions that enhance the user interface. Custom themes, interface improvements, and redesigned menus are just a few possibilities.

### 7. **Notifications**: 

Extensions can deliver notifications directly to your browser, whether it's the latest news, email alerts, or reminders. You won't miss important updates.

### 8. **Productivity Boost**: 

Chrome extensions can be productivity superheroes. They can automate repetitive tasks, track your time, or provide quick access to essential information, making you more efficient.

### 9. **Integration**: 

Extensions can integrate with external services and APIs. You can create connectors that sync data or perform actions with your favorite apps and websites.

### 10. **Learning Opportunity**: 

Lastly, developing Chrome extensions is an excellent way to learn web development. You'll gain hands-on experience with HTML, CSS, JavaScript, and Chrome's extension APIs, all of which are valuable skills for broader development projects.

### Conclusion:

Chrome extension development offers a multitude of features and functionalities that can enhance your web experience and improve your web development skills. Whether you're looking to customize your browsing, boost productivity, or gain a deeper understanding of web technologies, the world of Chrome extensions has something for everyone. So, dive in, explore these features, and let your Chrome extension development journey begin. It's a path filled with creativity, learning, and the potential to make the web a better place.
I COMMIT-ED Go Github?
Tags: programming, python, productivity, github
Published: 2023-10-12 02:07:28

Ever heard of that awesome 90's kid shows called Power Rangers? Where they had these awsome Dino-robots called Dinozords which were like Tyrannosaurus, Mastodon, Triceratops, Sabertooth Tiger, and Pterodactyl, then at the end they had to come to gether and had like a combination of a giant mega robot? A **MEGAZORD**, no no no it's a **DINO MEGAZORD!** yeah that one. Well that's how it felt like working on this lab this week. We need to focus on Rebase, commit ammend and squash. I guess we can call it refactoring.

So here's the thing I was lucky enough to learn this this earlier this week due to some problem that i ended up making and made a whole mess!! I had to request and close like 2/3 PR because of it.  Sad part is the issue wasn't even that hard.

## HERE WE GO AGAIN!
So let's start first with the main issue [Clean up code](https://github.com/movesthatmatter/movex/issues/85) this was simple enough remove the unused commented out code. Okay here me out the reason I took this was because I had like **7** PR at the time and I wanted to slowdown a bit. So I fixed the code and requested the first [PR](https://github.com/movesthatmatter/movex/pull/89#event-10622417062) I finished it quickly but then they asked me to do sign the commit. So I did that before but this time it wasn't working so I kept comitting and comitting and then suddenly I had to close it and created a second [PR](https://github.com/movesthatmatter/movex/pull/93#event-10623283810) same thing happened and on the final [PR](https://github.com/movesthatmatter/movex/pull/107#issuecomment-1758523944) thank goodness it finnaly worked I ended up multiple commit. the way I did it was I searched online how to not mess with the branch so I encountered rebase i thought I was going to use it for this PR but nope! I had to go and study cherry-pick which was basically choosing a commit from one branch and applying it to another.

## Where was I?
Oh yeah going back to the lab I cleaned the code up and made a global function, after woking on multiple big projects I decided to that Waypoint was really really messy so I cleaned up the code enhanced a few things. downgraded the line of codes so atleast it's much better to understand and finally was able to rebase and and squash 4 commits into 1 and made the whole thing better.
Project 1
Published: 2023-10-12 02:05:07

I had a few issues with this project. Some were in my control but others were not. One issue I had was with my IDEA when trying to work in the Team 3 Repo on my local machine. For some reason, I couldn't run any of the java files in the repo and couldn't see if my test files were working. Luckily, I was able to work with Barry and find a workaround, and I'm also going to meet with him on the weekend to set up my IDEA properly. 
Another issue was my own fault in that I started communicating late because of my other classes. However, once I established the communication, I was able to have effective communication with Danny and Barry. Moving forward, I'm going to make sure I'm proactive with the communication and more reliable. 
One thing I enjoyed about this assignment was looking at an already-built library and trying to find edge cases to test. It was an interesting experience and one that students don't normally get to do. It was also a fun challenge to fully comprehend the code without comments.
Unlocking Lambda's Full Potential: How to Resolve Layer Size Limits and Optimize Your Serverless Experience!
Tags: lambda, aws, tensorflow, s3
Published: 2023-10-12 01:57:21

A while ago me and my team were facing some issues regarding the limit size of the layer in our lambda apps, it was because the library that we used are to big for layer to handle. As you can see in bellow image the size that you can uploaded is only 262 MB.


![layer size](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/s4q2oa67kjk170xh0crk.jpg)

At that time we were using tensor library and its related library to be used in our project because we were aiming to build an artificial intelegence apps using that lib. For your information before you go dive into this article you should know that not all project are applicable using lambda, for alternative you can use ECS or some kind of docker, but for our project we want to make pricing as efficient as possible, because when you use a service such as ECS you will be billed monthly, it was so much different than lambda which was billed for every access that was hit by apps by user.

Here i will list and explain what did we do in order to fix that issue.

## we choose which library that we need and eliminate the rest

We are successfully optimized it and shrink it size by a half, but we still haven't succeed, so we go to the next step. 

![List of lib](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mtvw1ty93bad4fd2jzss.png)

## We uploaded the whole project into AWS S3

And dont forget to reshape your project to be applicable in the lambda, make its format into lambda style, dont make it as python project only *example, for example you change its main function name into 

 `def lambda_handler(event, context):`

when we used this method we can exceed its size into almost 400 MB for the whole project and the limit of that zip file should not exceed more than 170 MB for its final size after you zipped it. But unfortunately our project are much bigger than that.

![S3](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2oke5duf01ppemib5uzr.png)


But after we try above method, finally we were decide to move the code into our separate server because the size of project are so big that lambda cannot handle, i think in that case we could learn that lambda are only suitable for small project that doesn't need big size library, but you can still tried above method if your project aren't as big as ours. But if your project is using tensor i fully recommended that you use service like ECS, docker, and etc.
Purchasing Property In Pakistan
Tags: pakistan, finance
Published: 2023-10-12 01:48:46

Currently the Pakistan Rupee has depreciated 40% against the dollar. This makes purchasing assets like property in Pakistan more appealing. Why? 

The goal is to purchase property and hold onto it untill the PKR rises in value. If everything goes correctly then you can make a nice 40% profit + land appreciation bonuses. 

In high inflationary cycles, where prices of goods are rising, the property's price will be adjusted to match the true market value of the property. 

If you have a 30,000 r.s property bought in 2015, you will slowly increase the property price once you notice prices are rising.  

This makes properties a great investment for storing wealth during high inflationary times.  If your currency is getting weaker everyday, buy a property, and slowly raise it's price to match inflation. This way, your money won't be eroded way from inflation.