teleren/devto huggingface dataset:
The Power of Thinking Before You Code: The Benefits of Taking a Break
Tags: productivity, programming, abotwrotethis, webdev
Published: 2023-02-16 21:00:00

As a software developer, it's easy to get caught up in the excitement of coding and jump right into a project without giving much thought to the design and implementation. However, taking a step back and intentionally avoiding coding for some time can lead to significant benefits in the result of your project.

I recently had the opportunity to put this into practice with my last project. I decided to take a week to think through every aspect of the project, making changes to my design decisions as I worked through the problem in my mind. The results were astonishing.

One of the biggest benefits I experienced was the ability to identify potential roadblocks before they became actual problems. For example, I had originally planned to use a certain library for a specific aspect of the project. However, after spending time thinking about it, I realized that the library would not be compatible with another part of the project. By identifying this issue before I had even started coding, I was able to save myself a significant amount of time and frustration in the long run.

Another benefit was the ability to come up with more creative solutions to the problem at hand. When we're in the thick of coding, it's easy to get stuck in a rut and only consider the most obvious solutions. However, by taking a break and letting our minds wander, we open ourselves up to a world of possibilities and often come up with solutions that we wouldn't have thought of otherwise.

In addition to these benefits, taking a break from coding allowed me to approach the project with fresh eyes and a clear mind. The time spent thinking allowed me to work through any mental roadblocks and come up with a clear plan for the project. When I finally sat down to code, everything flowed smoothly and I was able to make significant progress in a short amount of time.

In conclusion, taking a break from coding and allowing yourself time to think through a project can lead to significant benefits in the result. By identifying potential roadblocks, coming up with creative solutions, and approaching the project with a clear mind, you can improve the overall quality of your code and have a more enjoyable coding experience.

So, the next time you're itching to dive into a project, try taking a step back and just think. You may just be surprised by the results.
Repository in Laravel
Tags: laravel, repository, webdev, tutorial
Published: 2023-02-16 20:41:30

Create a Laravel project.

php artisan make:model Event --mcr

Create a folder named as Interfaces under app.
Create EventRepositoryInterface.php inside the folder

EventRepositoryInterface.php:
```php
<?php

namespace App\Interfaces;

interface EventRepositoryInterface 
{
    public function getAllEvents();
    public function getEventById($eventId);
    public function deleteEvent($eventId);
    public function createEvent(array $eventDetails);
    public function updateEvent($eventId, array $newDetails);
}

```

As it's an Interface it only supports public methods, create required methods.

Create a folder named as Repositories under app.
Create EventRepository.php inside the folder

EventRepository.php:
```php
<?php

namespace App\Repositories;

use App\Interfaces\EventRepositoryInterface;
use App\Models\Event;

class EventRepository implements EventRepositoryInterface 
{
    public function getAllEvents() 
    {
        return Event::all();
    }

    public function getEventById($eventId) 
    {
        return Event::findOrFail($eventId);
    }

    public function deleteEvent($eventId) 
    {
        Event::destroy($eventId);
    }

    public function createEvent(array $eventDetails) 
    {
        return Event::create($eventDetails);
    }

    public function updateEvent($eventId, array $newDetails) 
    {
        return Event::whereId($eventId)->update($newDetails);
    }
}
```


Using the Repository in the controller

```php

<?php

namespace App\Http\Controllers;

use App\Interfaces\EventRepositoryInterface;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;
use Illuminate\Http\Response;

class EventController extends Controller 
{
    private EventRepositoryInterface $eventRepository;

    public function __construct(EventRepositoryInterface $eventRepository) 
    {
        $this->eventRepository = $eventRepository;
    }

    public function index(): JsonResponse 
    {
        return response()->json([
            'data' => $this->eventRepository->getAllEvents()
        ]);
    }
    public function store(Request $request): JsonResponse 
    {
        $res = $this->eventRepository->createEvent($eventDetails);
        return response()->json([
            'data' => $res
        ]);
    }

}
```

Lastly the Repository service provider needs to be created, booted and the repository file needs to be mapped for that 

php artisan make:provider RepositoryServiceProvider

Inside the RepositoryServiceProvider's boot function mapp the interface with the repo:

```php
$this->app->bind(EventRepositoryInterface::class,EventRepository::class);
```

Also add the the new Service Provider to the providers array in config/app.php so that Laravel boots it when the app boots

```php
'providers' => [
    // ...other declared providers
    App\Providers\RepositoryServiceProvider::class,
];
```
Dubai Kubernetes Meetup
Tags: aws, cloud, awscommunity, 100daysofcloud
Published: 2023-02-16 20:38:40

[47/100] #100DaysOfCloud Today, I attended the first meetup of the Dubai Kubernetes community. I learned about the Cloud Native Computing Foundation (CNCF), the state of containers which is about the past of containers and orchestrations as well as an introduction to Docker and Kubernetes.

If you are in Dubai then feel free to check it out: [Dubai Kubernetes Meetup](https://lnkd.in/dqdfiDFr)

[GitHub](https://github.com/aaditunni/100DaysOfCloud/blob/main/Journey/047/Readme.md)
¿Por qué es importante practicar crear juegos en Javascript?
Tags: webdev, javascript, programming, gamedev
Published: 2023-02-16 20:30:15

¡Hi World! El Yisus esta por acá para expresarse un poco sobre el gamedev en js. 👨🏻‍💻

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

En mi opinión practicar hacer juegos en JavaScript es importante por varias razones:

**1. Aprendizaje**: Crear juegos en JavaScript es una forma divertida y desafiante de aprender el lenguaje. Al crear un juego, los desarrolladores deben aplicar los conceptos básicos de JavaScript, como variables, funciones y eventos, así como conceptos más avanzados como el manejo de canvas o la creación de elementos DOM.

**2. Mejora de habilidades**: Crear un juego requiere una variedad de habilidades, como la lógica de programación, el diseño de interfaz de usuario y la animación. Practicar estas habilidades ayudará a los desarrolladores a mejorar su capacidad para resolver problemas y a pensar de manera creativa.
 
**3. Entender el desarrollo de juegos**: El desarrollo de juegos es un campo en constante evolución y crecimiento. Practicar hacer juegos en JavaScript ayudará a los desarrolladores a entender las tendencias y los desafíos del campo, así como a estar al día con las últimas herramientas y tecnologías.
 
**4. Mejora del rendimiento**: Crear juegos requiere un gran rendimiento en cuanto a velocidad y eficiencia del código, al practicar en crear juegos, se estará mejorando estos aspectos.


En resumen, practicar hacer juegos en JavaScript es una forma efectiva de aprender y mejorar las habilidades en desarrollo web, además de ayudar a entender el campo del desarrollo de juegos y mejorar el rendimiento del código. 🚀

¡Gracias por leer! 🤟
Observers in Laravel
Tags: observer, laravel, php
Published: 2023-02-16 20:15:23

Create laravel project

php artisan make:model Event --mcr //Create model, migration, controller, make controller as resource controller

php artisan make:observer EventObserver --m=Event

After running the abover command laravel will provide certain observer methods.


```php
<?php
 
namespace App\Observers;
 
use App\Models\Event;
 
class EventObserver
{
    /**
     * Handle the User "created" event.
     *
     * @param  \App\Models\Event  $user
     * @return void
     */
    public function created(Event $event):void
    {
        //
    }
 
    /**
     * Handle the User "updated" event.
     *
     * @param  \App\Models\Event  $event
     * @return void
     */
    public function updated(Event $event):void
    {
        //
    }
 
    /**
     * Handle the User "deleted" event.
     *
     * @param  \App\Models\Event $event
     * @return void
     */
    public function deleted(Event $event):void
    {
        //
    }
 
    /**
     * Handle the User "restored" event.
     *
     * @param  \App\Models\Event $event
     * @return void
     */
    public function restored(Event $event):void
    {
        //
    }
 
    /**
     * Handle the User "forceDeleted" event.
     *
     * @param  \App\Models\Event $event
     * @return void
     */
    public function forceDeleted(Event $event):void
    {
        //
    }
}

```

Complete list of methods given below:

- retrieved
- creating
- created
- updating
- updated
- saving
- saved
- deleting
- deleted
- trashed
- forceDeleting
- forceDeleted
- restoring
- restored
- replicating


Go to app/Providers/EventServiceProvider an boot it:

```php
use App\Models\Event;
use App\Observers\EventObserver;
 
/**
 * Register any events for your application.
 *
 * @return void
 */
public function boot()
{
    Event::observe(EventObserver::class);
}
```
Now whenever for example Event::updateOrCreate() method is called, suppose we haven't passed an id, soon after the create operation happens the code will move to the Observer's created method, execute the block and come back and start executing the rest of the code.

For digging deeper into Observers, refer below docs:
https://laravel.com/docs/9.x/eloquent#observers
https://laravel.com/docs/9.x/eloquent#events
pyaction: Over 1 million pulls from the GitHub Container Registry
Tags: github, docker, python, showdev
Published: 2023-02-16 20:13:48

Recently, [pyaction](https://github.com/cicirello/pyaction) passed 1 million pulls from the [GitHub Container Registry](https://github.com/cicirello/pyaction/pkgs/container/pyaction). It is a [Docker container with Python, git, and the GitHub CLI](https://dev.to/cicirello/pyaction-a-docker-container-with-python-git-and-the-github-cli-930).


![1 million pulls from GitHub Container Registry](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/v2cr7t2h59kwozr2mk8p.PNG)

Several GitHub container actions use pyaction as the base image, and specifically pull it from the GitHub Container Registry. So this likely represents over 1 million runs of those dependent Actions. It is also available from [Docker Hub](https://hub.docker.com/r/cicirello/pyaction).



## More Information

Please consider starring pyaction's GitHub repository:

{% github cicirello/pyaction %}

For more information, see my earlier post about pyaction here on DEV, as well as its webpage. 

{% link https://dev.to/cicirello/pyaction-a-docker-container-with-python-git-and-the-github-cli-930 %}

{% embed https://actions.cicirello.org/pyaction/ %}


## Where You Can Find Me

Follow me [here on DEV](https://dev.to/cicirello) and on [GitHub](https://github.com/cicirello):

{% user cicirello %}

Or visit my website:

{% embed https://www.cicirello.org/ %}
Angular Change Detection: Understanding It and Best Practices
Tags: angular, changedetection, performanceoptimization, zonejs
Published: 2023-02-16 19:55:15

Angular is a widely-used framework for building web applications, and its Change Detection system is a key feature. In this blog, we’ll discuss the purpose of Angular Change Detection, how it works, and best practices for optimizing its performance. Understanding these concepts will help you create efficient and fast Angular applications that provide a seamless user experience.

## What is Change Detection in Angular?
Angular Change Detection is a process that tracks changes to an application’s data and updates the UI accordingly. Whenever there is a change in the data, the Change Detection system is triggered to determine **if the change requires an update to the UI**.

## How does Angular Change Detection work?
Angular’s Change Detection system is **based on the Zone.js library**, which creates a root Zone that tracks all changes to the application’s state. Each component in the application has its own Change Detection strategy that determines how it should handle changes to its data. There are two types of Change Detection strategies in Angular: OnPush and Default. **OnPush** is recommended for _static components_, while **Default** is recommended for _components with frequent updates_.

To optimize Angular Change Detection performance depends on best practices:

1. Use the OnPush Change Detection strategy wherever possible.
2. Avoid using complex and deeply-nested data structures.
3. Use the **trackBy** function when using *ngFor directives.
4. Use immutable data structures whenever possible.
5. Use the **ChangeDetectorRef** class to manually trigger the Change Detection process when necessary.

---

[Check out my website for more…](https://cagkanmert.com)
What`s new Map()?
Tags: javascript, beginners, programming, tutorial
Published: 2023-02-16 19:51:34

Let`s talk about what`s "new Map()".

**Uses**
We could use it to define a new object where then calling the key we would be able to get the value on the specific value.

**Usage**
The usage of it is as follows.

First we will see how we declare the variable "objMap" as the "new Map()" object will have.
Then we will set the value it will have calling "objMap" and the internal function "Map()" have. The first value we pass to it will be the key of the object. For example: If we just pass "objMap.set("1", "Hola")", the value will be "Hola" and the key will be "1".
And finally there are examples of how to get the values doing different console.logs, we will see that the first one will return "Hola" and the second console.log will return undefined cause the is not a "2" key.


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

This post is to explain the concept used in the last post.

Hope someone found it useFul.

Lautaro
Create a dynamic route for search bar
Tags: beginners, rails, react, webdev
Published: 2023-02-16 19:09:37


Recently I created a project that allowed users to choose from multiple different options to search by (name, brand, type, size), and when creating routs in the backend - I thought there must be a cleaner more efficient way to do this rather than having a separate method for each search type. After thinking if over I realized that through params, I had the ability to pass in the value of both the search type as well as the value of the search, and use those within my method to create a dynamic search that would return the desired results. I'll go ahead and walk through the steps of setting someting like this up in both the front end and back end.

##Start with the back end

to start, you'll want to create a 'get' route that will be targeting your desired controller where the method will live. something like this 

```get '/:option/:search', to:'synth_modules#search'```

from there, you need to set up a method in your controller that will be looking to find a specific instance, based on the provided info from params. it might look something like this :


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


in the above image - I'm declaring a variable that will be assigned the instance that matches the search. if a instance is created, it will return that data as json back to the front end, and if not the error will be sent up. As you can see, im using a custom method `.filtered_synths` and passing in the params to that method, it makes things cleaner in my opinion to have a single method called rather than `.where`'s and other methods flying around. 

##The Front End

now that the back end is set up to receive data from the front end, heres how we would set up our fetch request in a react front end. 

first, have a form built out based on your own needs, mine had a drop-down where users can select which attribute they would like to search by, followed by a text box where the search value would go. Each of those values are set to state, so that I can reference that in my fetch URL, and it can stay updated on each change of the form. Once the submit button is clicked, it triggers a fetch request, that looks like this 

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

as you can see you need to interpolate the state values of 'option' as well as 'search' inside the URL, and with the response, set that return object to the state that is rendering all of your cards, in my case is was all synth modules, so now the only objects that will be rendered are the modules that match the search value. 

There are plenty of ways to execute this solution, but at the time this seemed like a efficient way to minimize code and multiple methods, by combining all searches into one method with the powerful use of params.
Google status bar #unhide
Published: 2023-02-16 19:05:38

Hi 
on windows 10, google Version 110.0.5481.100, I can't get my status bar on the bottom of the screen to show up.
I've tried both options available by experts
1. Ctrl + mouse up & down
2. Settings--> advanced-->uncheck hardware acceleration
neither gets my status bar to show up.
appreciate any tips.
thanks!

##
Implementing delete feature in ios apps: How to make sure deleting data doesn't mess up the reports
Tags: ios, devjournal
Published: 2023-02-16 18:54:28

### For sql based data
If user has made no transaction. delete him,remove him.
But if he made purchase and his data(user_id) is saved on multiple tables,then 

- make deleted user table. 
whenever you delete
make the obfuscated user data in this table. 
so the app,cms doesn't break. Also let your user know that for legal purposes some data needs to be retained.

### For non sql.
Obfuscate the users data, and insert the user's data as key(eg owner) where the user id was used. Basically insert it as sub document.

Maybe this is not the best solution, for us it worked. how did you guys fixed it
Python comparison between normal for loop and enumerate
Published: 2023-02-16 17:31:41

In [Python](https://www.python.org/), we can use the `for` loop to iterate over a sequence of values, such as a list or a tuple. We can also use the `enumerate` function to add a counter to the loop. Here's an example to compare the normal `for` loop with the `enumerate` function:

Normal For Loop
```py
fruits = ['apple', 'banana', 'orange']
for i in range(len(fruits)):
    print(i, fruits[i])
``` 

Output:
```py
0 apple
1 banana
2 orange
``` 

In this example, we use the `range` function to generate a sequence of numbers from 0 to the length of the `fruits` list. We then use this sequence of numbers to access the elements of the `fruits` list using their indices.

Enumerate
```py
fruits = ['apple', 'banana', 'orange']
for i, fruit in enumerate(fruits):
    print(i, fruit)
``` 

Output:
```py
0 apple
1 banana
2 orange
``` 

In this example, we use the `enumerate` function to add a counter to the loop. The `enumerate` function returns a sequence of pairs, where the first element of each pair is the index, and the second element is the corresponding value from the `fruits` list. We unpack each pair into two variables `i` and `fruit`, and then print them.

As you can see, using the [**python enumerate function**](https://www.programdoc.com/python/enumerate) makes the code shorter and more readable. It also eliminates the need to use the `range` and `len` functions to access the elements of the list.

Here's a summary of the differences between the normal `for` loop and the `enumerate` function:

-   A normal `for` loop can iterate over a sequence of values, but does not provide a counter.
-   The `enumerate` function can iterate over a sequence of values and provide a counter.
-   The `enumerate` function returns a sequence of pairs, where the first element of each pair is the counter, and the second element is the value from the sequence.
-   Using `enumerate` can make the code shorter and more readable, and eliminates the need to use the `range` and `len` functions to access the elements of the list.

## Explore Other Related Articles
[Python if-else Statements Tutorial](https://dev.to/max24816/python-if-else-statements-tutorial-3p25)
[Python set tutorial](https://dev.to/max24816/python-set-tutorial-hcp)
[Python tuple tutorial](https://dev.to/max24816/python-tuple-tutorial-3m62)
[Python Lists tutorial](https://dev.to/max24816/python-lists-tutorial-2g43)
[Python dictionaries comprehension tutorial](https://dev.to/max24816/python-dictionaries-comprehension-tutorial-3bda)
convert api data in csv using postman and miller
Tags: json, csv, api, postman
Published: 2023-02-16 18:47:05

**Aim**: Json response to CSV

**Solution**:

### Miller is a command-line tool for querying, shaping, and reformatting data files in various formats including CSV, TSV, JSON, and JSON Lines.
[Miller Official website](https://miller.readthedocs.io/en/latest/)
Github: [miller](https://github.com/johnkerl/miller)


`mlr --j2c cut -f id,name,username,email,phone  response.json>user.csv`

if all the data is available in one response. save the response as a file via postman
![postman image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3urxpr4sse3fz3h8h6te.png)
Guitar Lessons Home Visits London - London Guitar School
Published: 2023-02-16 18:42:32

Home Visit Guitar lessons London. Learn how to play guitar in our Beginners Academy lessons in Central London. Are you looking for a Guitar Teacher in London? Book your one-to-one online or home visit lesson with one of our guitar tutors. BOOK YOUR LESSON NOW! [Guitar lessons near me ](https://londonguitarschool.com/guitar-lessons-central-london/)
Linode + DEV Hackathon
Tags: linodehackathon
Published: 2023-02-16 18:37:17

## What I built
I built a city website

### Category Submission:
html/css and javascript

### App Link
https://visitabidjan.ca/

### Screenshots


### Description
 the website is to invite people to visit Abidjan or to know Abdidjan

### Link to Source Code


### Permissive License


## Background
(What made you decide to build this particular app? What inspired you?)
This project is my second course project HTML/CSS

### How I built it
(How did you utilize Linode? Did you learn something new along the way? Pick up a new skill?)
I learn horizontal scrolling with grid or flexbox. I learned how to add a map. I learned how to animate a navbar.

However my website is not really responsive on mobile. Because I built it for desktop first.


### Additional Resources/Info
HTML+CSS Workshop
Tags: 100daysofcode, javascript, css, html
Published: 2023-02-16 18:16:47

---
title: HTML+CSS Workshop
published: true
description: Want to learn how to publish websites for free and fast?
tags: 100daysofcode, javascript, css, html
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-02-16 18:14 +0000
---

Want to learn how to publish websites for free and fast?

Fill the survey by the end of today.
https://forms.gle/rixbocSN3foveiES7