teleren/devto huggingface dataset:
What Is Trait In PHP?
Tags: oop, php, python, webdev
Published: 2023-05-28 14:56:18

Question asked in every interview: What does trait mean in PHP?
Today's post is about PHP in general and specifically about something we use every day without delving deep into it, which is the trait class. We all know about object-oriented programming and how we can inherit from one class to another. However, sometimes we need to implement multiple inheritance, which means allowing a class to inherit from more than one class. Unfortunately, this feature is not supported in PHP, so we use traits instead.
In the image below, there is an example comparing traits in PHP and the same concept in Python.
In Laravel, all you need to do to use a trait is to start the class definition with the keyword "trait" and import the namespace "App\Traits." Apart from its main purpose, which is solving the problem of multiple inheritances, traits have many other uses, such as in SOLID principles, object-oriented programming, and more.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kh1bipx1w1e3chbg2sg6.jpg)
Versatile Solutions for Database Developers
Tags: database, softwareengineering, developers, dbforge
Published: 2023-05-28 14:49:19

The day-to-day work of a database developer can involve various complex operations that require a proper set of tools to help developers complete their tasks in a timely and efficient manner. If you are looking for such tools - dbForge database solutions may be just what you need - https://www.devart.com/solutions/database-developer/

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wm4g429kvzll5l39xv3w.png)
MySQL UNION Explained: A Tutorial with Practical Examples for All Skill Levels
Tags: mysql, database, dbforge, dbforgestudio
Published: 2023-05-28 14:27:18

In this article, you can find the definition and benefits of the UNION clause and how it is applied in MySQL - https://blog.devart.com/mysql-union-tutorial-html.html

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tqphg69w2y0vnjuzt2uo.png)
Let's learn about Flexbox
Tags: webdev, css, flexbox
Published: 2023-05-28 14:23:31

# What is flexbox?
Flexbox is a relatively new way of manipulating elements in CSS, and its debut was revolutionary.

# How to create a box and using flexbox:
You can look at the code below
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/quq9numbr0a0hyg69ldp.png)
Then it will display on your screen like this (There are some note for you to know what we code will look like):
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c7fdloksznkg6rowe8jp.png)

# I found this man on DEV Community show us a picture of some examples about how flexbox work: 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cvi3x7vy5k3ftiy155lu.png)

Source: https://dev.to/arafat4693/flexbox-justify-content-visual-representation-4c22
Git Braching Statergy
Published: 2023-05-28 14:12:06

In modern software development, **speed and agility are crucial when it comes to developing and releasing software**. However, when you have a large team of developers working simultaneously, branching and merging code can become messy fast. 

Therefore, teams need to have a process in place to implement multiple changes at once. This is where having an efficient branching strategy becomes a priority for these teams.


**What is a branching strategy**

Branches are primarily used as a means for teams to develop features giving them a separate workspace for their code. These branches are usually merged back to a master branch upon completion of work. 

**Why you need a branching strategy**

1. Enhance productivity by ensuring proper coordination among developers
2. Enable parallel development
3. Help organize a series of planned, structured releases
4. Map a clear path when making changes to software through to production
5. Maintain a bug-free code where developers can quickly fix issues and get these changes back to production without disrupting the development workflow

**Git branching**


**Git and other version control systems give software developers the power to track, manage, and organize their code.**

In particular, Git helps developers collaborate on code with teammates; combining powerful features like commits and branches with specific principles and strategies helps teams organize code and reduce the time needed to manage versioning.

**This branching strategy consists of the following branches**

1. Master 
2. Develop
3. Feature- to develop new features that branches off the develop branch 
4. Release- help prepare a new production release; usually branched from the develop branch and must be merged back to both develop and master
5. Hotfix- also helps prepare for a release but unlike release branches, hotfix branches arise from a bug that has been discovered and must be resolved; it enables developers to keep working on their own changes on the develop branch while the bug is being fixed.



**Trunk-based development**

Trunk-based development is a branching strategy that in fact requires no branches but instead, developers integrate their changes into a shared trunk at least once a day. This shared trunk should be ready for release anytime.

The main idea behind this strategy is that developers make smaller changes more frequently and thus the goal is to limit long-lasting branches and avoid merge conflicts as all developers work on the same branch. In other words, developers commit directly into the trunk without the use of branches.
The Best VSCode Git Extension Pack
Published: 2023-05-28 14:10:16

It Automatically set the **best configurations** of these extensions for you and it has 2 commands for manually activate/deactivate. 

Features:

- Supercharge the Git capabilities built into Visual Studio Code — Visualize code authorship at a glance via Git blame annotations and code lens, seamlessly navigate and explore Git repositories, gain valuable insights via powerful comparison commands, and so much more

- Story mode Browsing history and files in any git repository

- Conventional Commits for VSCode.

- Checkpoints - Checkpoints(using ctrl+alt+s) used in between commits for keeping a local short-term history of work in progress files, like bookmarks in you undo-stack.

Hope to be useful for you. Please support us with GitHub star, LinkedIn ❤️

[**Visual Studio Code marketplace**](https://marketplace.visualstudio.com/items?itemName=SeyyedKhandon.gpack)

[**GitHub**](https://github.com/SeyyedKhandon/gpack)

To see other developer experienced based extensions:

https://marketplace.visualstudio.com/publishers/SeyyedKhandon
JavaScript Loops and Functions #10
Tags: javascript, programming, tutorial, googledevops
Published: 2023-05-28 14:01:02

// chapter 3 pratice set 
// Q1: Write a program to print the mark of a student in an object using for loop  Obj {sage 68, rohan 72,sunny 8}

let marks = {
  sage: 68, 
  rohan: 72,
  sunny: 8,
  adarsh: 44,
}
for(let i=0;i<Object.keys(marks).length;i++){
  // console.log("The marks of " + Object.keys(marks)[i] + "are" + marks[Object.keys(marks)[i]])
}
// Q2 write a program in Q1 using in loop .?

for (let key in marks) {
  // console.log("The marks of " + key + " are " + marks[key])
}

// Q3 write a program to print "try again" until the user enter the correct number .

// let cn = 9
// let i 
// while (i != cn){
//   console.log("Try again")
//   i = prompt("Enter a number")
//   }
// console.log("You have enterned a correct number")


// write a function to find mean of 5 number 

const mean = (a, b, c, d) => {
  return (a + b + c + d)/4
}

console.log(mean(4, 5, 6, 7))[](https://replit.com/@SkSage/JavaScript-Chapter-3-Loops-and-Functions-12#index.js)
N Queens Problem
Tags: javascript, dsa, backtracking
Published: 2023-05-28 13:50:29

## How can we place N chess queens on a N × N chessboard so that no two queens threaten each other?

Solution: 
In the following backtracking is used to solve the problem.
Backtracking is one of the important way of solving problem. But, for now lets focus on solving the problem wherein the N Queens should be placed on NxN chessboard such that no queens threatens no other queen, in how many ways we can do so?


![N Queens](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0n19j26s1k6k7gvs71ak.png)
Some structural planning
Published: 2023-05-28 13:45:30

So my first conversation with GPT was a bit overwhelming. There's a lot of stuff that goes into planning an app that I wasn't aware of, but they all do seem necessary (or at least beneficial); however, I probably don't need to go for all the planning methods.

From the start I told it I would be using ASP.NET and some form of relational database. Some things kept coming up during the conversation:

## Object-Relational Mapping
Apparently there are frameworks that work as intermediaries between DBs and the app itself. Fantastic! But as I dug deeper, the rabbit hole revealed itself.

As I understand it, you make your DBs schema and map it to your applications model using the ORM which manages the connection between them (EF Core was suggested since I'm using dotnet). The question is... what's an application model? I also saw mentions of model-view-viewmodel which probably fits into that category.

## Database Choice
I want to use some sort of relational database and since I'm pretty comfortable with SQL, I asked GPT for some recommendations:

- [SQLite](https://www.sqlite.org/index.html) which I used in CS50 is filebased and very easy to use but I was looking for something server-based.but MariaDB is server-based instead of file-based.

- [PostgreSQL](https://www.postgresql.org/) aims to be big and scalable but was probably way more than I need for this small project. It seems very strong for when you need great security and stability for big apps.

- [MySQL/MariaDB](https://mariadb.org/) is pretty light and seems easy enough to install on my Fedora machine. MariaDB is advertised as the clear upgrade to base MySQL. I also don't have experience with MySQL which is a plus.

- [Microsoft SQL Server](https://www.microsoft.com/en/sql-server/sql-server-downloads) is the big one. I'm pretty familiar with it and its Management Studio program, and although the Express version is perfect for this project, I want to learn new things
**
I ended up choosing MariaDB**. Had to uninstall a previous problematic installation but I got it working with a test DB in 5 minutes!!


I'll make a future post with how I'm sketching up my DBs schema.
Should we still write software engineering blog posts?
Tags: thoughts, softwareengineering
Published: 2023-05-28 13:36:51

---
title: Should we still write software engineering blog posts?
published: true
date: 2023-05-28 13:36:11 UTC
tags: Thoughts,Softwareengineering
canonical_url: https://www.rockandnull.com/software-engineering-blog-posts-in-ai-era/
---

 ![Should we still write software engineering blog posts?](https://images.unsplash.com/photo-1533073526757-2c8ca1df9f1c?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wxMTc3M3wwfDF8c2VhcmNofDN8fGZ1dHVyZXxlbnwwfHx8fDE2ODUyODA4Njh8MA&ixlib=rb-4.0.3&q=80&w=2000)

We initiated this blog with the realization that we were consuming a lot of content on the internet without actively contributing. As software engineers, both as a hobby and professionally, we have become accustomed to relying on search engines to find solutions and complete our software projects. Often, our queries led us to blog posts, Stack Overflow threads, or forum discussions where we discovered the answers we sought.

Hence, we naturally created this blog as a way to document our own software engineering discoveries, hoping to assist fellow engineers who may encounter similar challenges. Initially, it worked well, serving as a valuable resource for others. However, as we enter the era of artificial intelligence, the way people seek software engineering solutions is changing. Traditional search engines are being replaced by AI language models like Google Bard and ChatGPT, which provide direct answers. There is no longer a need to sift through blogs, forums, or personal websites to find solutions.

Given this new reality, one might question the purpose of continuing to write these concise blog posts that aim to address specific engineering issues. Initially, it may seem unnecessary. After all, why maintain personal notes when the answers are just a chat away?

However, upon deeper reflection, we realize that these blog posts likely contribute to the training data of these AI language models. Thus, the original intention of sharing collective knowledge remains valid, albeit in a more indirect manner without receiving any credit. Even for bloggers who do not monetize their content, visitor counts and occasional thank-you emails serve as valuable feedback, affirming that they are making a positive impact. Unfortunately, this feedback loop is broken in the new era.

If we were to cease writing these blog posts, it could potentially diminish the quality of the answers provided by AI language models over time. But if our only readership will eventually be AI training crawlers, what would be the point? While I'm not an expert in the field, it appears there may be an upcoming issue concerning the future training of AI language models. Perhaps we are currently witnessing the peak performance of these models, and there will come a time when blog posts like ours regain their utility.

Personally, I have not yet decided whether I will continue writing these posts. My motivation for doing so has certainly waned. Only time will tell.
The one about maximums
Tags: perl, python, theweeklychallenge
Published: 2023-05-28 13:31:29

## Weekly Challenge 218

[Challenge](https://theweeklychallenge.org/blog/perl-weekly-challenge-218/), [My solutions](https://github.com/manwar/perlweeklychallenge-club/tree/master/challenge-218)

## Task 1: Maximum Product

### Task

You are given a list of 3 or more integers.

Write a script to find the 3 integers whose product is the maximum and return it.

### My solution

This seemed straight forward. Sort the numbers numerically and multiple the three largest numbers to get a solution. But it's not that simple.

The last example shows that the solution is obtained by multiple the lowest two numbers and the largest number. We know that if we multiple an even number of negative integers, the result is positive. Multiplying an odd number of negative numbers is always a negative. Given that we only look at three digit, the maximum number of negative numbers is two, unless they are all negative.

So with this out of the way, I calculate the product of the three largest numbers, and the two lowest and largest number. I then display the maximum of these two values.

### Examples

```bash
$ ./ch-1.py 3 1 2
6

$ ./ch-1.py 4 1 3 2
24

$ ./ch-1.py -1 0 1 3 1
3

$ ./ch-1.py -8 2 -9 0 -4 3
216
```

## Task 2: Matrix Score

### Task

You are given a `m x n` binary matrix i.e. having only `1` and `0`.

You are allowed to make as many moves as you want to get the highest score.

    A move can be either toggling each value in a row or column.

To get the score, convert the each row binary to dec and return the sum.

### My solution

This challenge actually turned out easier than I thought it would be, thanks to the use of xor and a bit of logic. I start my setting the `solution` variable to `0`, and `xor_row` to 1 less than 2 to the power of the number of columns. So if we have 4 columns, `xor_row` is 15 (or `1111` in binary notation).

The next thing I do is convert each row from a list (array in Perl) into a decimal number. In Python this is done with `int(<binary>, 2)`, while in Perl this is done by calling `oct("0b<binary>")`, which seems counter-intuitive given octets are from 0-7. I digress.

The next part is which rows and columns to toggle. For the columns I have a loop from `0` to `xor_row`. I numerically xor that value with each number from the previous step. This ensures that we consider every combination of which columns we want to toggle.

Toggling the rows is much easier thankfully. We know that the maximum sum for each row is either when we have the integer from the above step, or the value xored with `xor_row`, so I calculate this for each row. If the sum of the rows is greater than the current solution, I update `solution` with the new value.


### Examples

```bash
$ ./ch-2.py "[[0,0,1,1],[1,0,1,0],[1,1,0,0]]"
39

$ ./ch-2.py "[[0]]"
1
```
Spring IoC container 📦
Tags: spring, basics, container
Published: 2023-05-28 13:13:49

Spring IoC container is the component in spring core framework. Lifecycle of bean is maintained by this container. This container converts the java objects into the beans by provided configurations.

## Spring IoC container responsibilities:
* instantiate the application class
* configure object
* assemble the dependencies between objects

## Types of IoC
* Bean Factory - Basic IoC container, no advance feature, only bean creation, maintenance, auto wiring & injecting dependencies. 
* Application Context - advanced IoC provides all features of Bean Factory & on top of it provides extra features like event handling based on bean events.
Speed up your Laravel test suite
Published: 2023-05-28 13:09:53

If you work with Laravel and TDD, you certainly know how fast your test suite can grow and even take several minutes to run.
With the latest versions of Laravel there are a couple of things you can do to speed it up.

### Reset your database status only when you need to

Laravel 8 and up include a new `LazilyRefreshDatabase` trait, which can be used in place of `RefreshDatabase` to only migrate and seed the database if the previous test changed it.
See [this episode of Laracasts](https://laracasts.com/series/jeffreys-larabits/episodes/10) for further information.

### Use parallel testing

Another thing you can do to improve the running time of your tests is running them in parallel instead of sequentially.
[The paratest composer package](https://github.com/paratestphp/paratest) will help you with that. 
Just follow the instructions in the README to install and use it.
Quick tip: with parallel testing, every test will run on a different database. Make sure your database user is allowed to create and operate on each of them, setting his permissions accordingly :)

Do you have any other suggestion to share about improving the test running time?
How To Make Hover Effect Overflow Its Container with React
Tags: webdev, react, javascript
Published: 2023-05-28 13:07:32

✨ [**Watch on YouTube**](https://youtu.be/35XAA5Hgag0)  |  🐙 [GitHub](https://github.com/RodionChachura/reactkit)  |  🎮 [Demo](https://reactkit.radzion.com/hoverable)

Do you see this nice hover effect going beyond the boundaries of a checklist item? Let me show you how to make a reusable component to make any interactive element hoverable with ease.

![](./hover.gif)

The component receives `children`, an optional horizontal and vertical offset to let hover go beyond the boundaries of an element, the `as` property so we can render the element as a `div`, `button`, or `label`, and optional `onClick` and `style` properties.

```tsx
import styled from "styled-components"

import { defaultTransitionCSS } from "./animations/transitions"
import { ComponentWithChildrenProps } from "lib/shared/props"
import { UnstyledButton } from "./buttons/UnstyledButton"
import { getCSSUnit } from "./utils/getCSSUnit"

const Highlight = styled.div`
  position: absolute;
  ${defaultTransitionCSS};
  border-radius: 8px;
`

const Container = styled(UnstyledButton)`
  position: relative;

  :hover ${Highlight} {
    background: ${({ theme }) => theme.colors.backgroundGlass.toCssValue()};
  }
`

const Content = styled.div`
  z-index: 1;
`

interface HoverableProps extends ComponentWithChildrenProps {
  horizontalOffset?: number
  verticalOffset?: number
  as?: React.ElementType
  onClick?: () => void
  style?: React.CSSProperties
}

export const Hoverable = ({
  children,
  horizontalOffset = 8,
  verticalOffset = 8,
  onClick,
  as,
  style,
}: HoverableProps) => {
  return (
    <Container onClick={onClick} as={as} style={style}>
      <Highlight
        style={{
          left: getCSSUnit(-horizontalOffset),
          top: getCSSUnit(-verticalOffset),
          width: `calc(100% + ${getCSSUnit(horizontalOffset * 2)})`,
          height: `calc(100% + ${getCSSUnit(verticalOffset * 2)})`,
        }}
      />
      <Content>{children}</Content>
    </Container>
  )
}
```

We base the container on an `UnstyledButton` component that clears all the default styles of a button element. We want it to be relative so we can position the `Highlight` element absolutely. The hover effect has a transition to animate appearance, `border-radius`, and no background, as it will be set on hover of the `Container` element. To position the `Highlight` and make it larger than the content inside, we'll make the left and top values negative and make the width and height 100% plus their offset. To make the content appear above the hover effect, we'll apply a `z-index`.
REMOVE GMAIL FROM UNWANTED ACCOUNTS.
Tags: beginners, community, web
Published: 2023-05-28 12:57:49

                                                                            
Hey there, how many websites do you remember registering under your personal email address👀?

                         Facts😁.

Many at times users tend to signup using their personal email addresses onto various websites and with time they stop using these sites and forget to remove their email credentials.

Well some of you might not know this but may websites actually websites still have access to your data and this is can be used by attackers who gain access to this data.

                        Solution💫.

Step to remove your email address from unused and unwanted websites✊.

1. Sign in to your gmail account account, and on the top right corner click on your profile after the nine square dots. Beneath it you will see a button Manage your Google Account  click it.

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




2. Proceed to the security tab and click on it. This can either be on the left panel as indicated below or sometimes the panel might not be on the sides but up the page.



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


  



3. Scroll down and find Signing in with Google and click on it, this can be found under the section Signing in to other sites as indicated down below

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




4. Once you have clicked on Signing in with Google, you will see a list of all the websites and applications that have access to your gmail account.

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


5. Lastly, among this list you will notice any unused or unknown website. Click directly on its name and proceed on to clicking the remove access button.

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