teleren/devto huggingface dataset:
Episode 23/16: Hydration, Angular 17 and Beyond, Webinar on Signals
Tags: webdev, javascript, angular, programming
Published: 2023-04-25 16:28:06

Jessica Janiuk published an outlook for improved hydration support in Angular 16. Minko Gechev went even further and discussed his views on future versions of Angular. Manfred Steyer gave a webinar on how Angular applications will look like, when they are "Signals-powered". 

{% embed https://youtu.be/4IQ2q2GVygs %}

## Non-Destructive Hydration


Jessica Janiuk, a member of the Angular team, published an article about the upcoming changes in hydration. Starting with Angular 16, SSR will support non-destructive hydration, meaning the DOM elements will not be destroyed and rebuilt when Angular activates itself in the browser.

The current library for SSR, Angular Universal, will become part of the framework itself. At the moment, it is a separate Git repository.

Non-destructive hydration is just the beginning. At the end of the article, Jessica gave some hints about the upcoming features.

That would be partial hydration and resumability. Very simplified, both techniques try to send JavaScript to the browser only for the active components. In a way, lazy loading for SSR.

{% embed https://blog.angular.io/whats-next-for-server-side-rendering-in-angular-2a6f27662b67 %}

## Minko Gechev on Angular 17+

Dariusz Kalbarczyk interviewed Minko Gechev about the future of Angular. Minko is the Angular product lead at Google.

It was a nice overview of all the new technologies like Standalone Components, Signals, Hydration but he didn't reveal anything new.
What I found a little unusual was that Minko often referred to an upcoming authoring format.

Just speculating, but maybe this is something for 2024.

{% embed https://www.youtube.com/watch?v=aXfCNbU-9EY %}


## Webinar Signals

Dariusz also hosted a webinar with Manfred Steyer. The webinar was mainly live coding, and Manfred covered all facets of Signals.

Manfred started to integrate Signals into an existing component and then moved to the interoperability with RxJs, a little bit about the state management and ended with an outlook on the Signal component which we can expect in Angular 17.

Angular 16 will already be available in May. So we can expect that the code we've seen will not change significantly anymore.

{% embed https://www.youtube.com/live/7wfwlAIY4jE %}
What is pkill?
Tags: unix, security, sre, systemsdministration
Published: 2023-04-25 16:24:23

The `pkill` command is a command-line utility that is used to terminate processes on Unix or Linux systems. It is an extremely powerful and efficient tool for system administrators and users alike. 

It allows them to quickly and easily terminate processes by name, ID, or attribute, send different signals to processes, and search for processes based on their attributes. A must-have tool for system administration and working with Unix or Linux systems.

One of the most common uses of the `pkill` command is to terminate processes by name. Enter the command + the name of the process to terminate. For example, if you want to terminate a process named ‘firefox’, you would enter

`pkill firefox`

You can also use wildcards to match processes with similar names. E.g. For all processes with names starting with “chrome”.

`pkill -f "chrome*"`

The ‘pkill’ command also allows you to send different signals to processes, including `SIGTERM` (default), `SIGKILL`, or `SIGINT`. The `SIGTERM` signal requests that the process terminate gracefully, while the `SIGKILL` and `SIGINT` signals force the process to terminate immediately.

You can search for processes based on attributes. Search for processes running as a particular user, by specifying the user's name as a parameter.

`pkill -U username`

You can terminate processes based on their CPU usage. E.g. To terminate the process owned by the specified user that has the highest CPU usage.

`pkill -u username -o %cpu -n 1`

    `-u` specifies the username of the user whose processes you want to terminate.
    `-o %cpu` orders the processes by their CPU usage, with the highest usage first.
    `-n 1` specifies that only the process with the highest CPU usage should be terminated. The '-n' flag takes a numerical value for how many processes should be terminated. In this case, only the process with the highest CPU usage (i.e., the one with the rank of '1') will be terminated.

For more details on signals and defaults: [Check this out](https://linuxize.com/post/pkill-command-in-linux/)
Why I got sucked only 2 weeks into my junior developer job and what I learned.
Published: 2023-04-25 16:19:13

Being a junior developer is tough. You’re new to the game, trying to navigate the world of coding and development while also trying to impress your employer with your skills and knowledge. But what happens when you’re sucked from a remote job only 2 weeks after starting the job? It can be devastating, especially when the reasons for getting sucked seem petty or insignificant.

In my case, I was sucked from my first remote job as a junior developer after only 2 weeks. The reasons given to me were that my commit messages were poor, I was using a line spacing of 2 instead of 4 and I took long to deliver a working login page which was more of a backend problem than mine because the API endpoint was not working. I was confused at first and hurt by these reasons, I tried to ask for a second chance but it was too late because my replacement was already on standby. I was new to this job and this was my first time working remotely. I didn't realize that these small things could cause such a big problem.

As time passed, I began to see why my employer was unhappy with my performance and I knew it was over for me the day I received a long voice note from my boss. My commit messages were indeed long and poor, it made it difficult for my team to understand what I was working on or what changes I had made. This made it challenging for them to review my work and offer feedback. On top of that, using a line spacing of 2 instead of 4 may have seemed harmless, but it made my code difficult to read, edit and merge with the main branch. My last two commits before getting sucked were much better and I thought I was progressing well but maybe it was already too late to make things right

As a junior developer who was still learning how to communicate my work effectively and present my code in a readable format. But my employer and seniors had a responsibility to share feedback on areas where I could improve, even if it seems small or insignificant.

Getting sucked from a remote job as a junior developer taught me valuable lessons about the importance of attention to detail, collaboration, and communication which was my biggest problem, I didn't know how to effectively express myself and explain what was going on or what I was up to. It also taught me the value of taking ownership of my mistakes and working hard to correct them.

In conclusion, being sucked from a remote job as a junior developer and worse after only 2 weeks can be discouraging, but it's important to take the situation as a learning experience. Be keen on small details, and work on your soft skills as much as your hard skills, soft skills like effective communication, and collaboration with your team ensure that expectations are met. In the end, it will be worth the effort to become a better developer and excel in your career.
TIL: isBlank() String Method
Tags: java, programming, todayilearned, string
Published: 2023-04-25 16:09:44

Today i learned that in Java 11 there was a new String Method introduced that checks if a string is empty or just contains blanks and the same time. 

So instead of this:

```java
String toCheck = " ";
if(toCheck.trim().isEmpty()) {
...
}
```
You can do this: 

```java
String toCheck = " ";
if(toCheck.isBlank()) {
...
}
```
Makes the if statement a bit cleaner.
How many log levels are there?
Tags: programming, ruby, java, python
Published: 2023-04-25 16:02:10

I'm building a tool to allow you to [change the log levels](https://www.prefab.cloud/features/log-levels/) of your application at runtime. In order to do that, I need to show you a dropdown of the various log levels. Something like:

![Change your log level without restarting](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j66x3ppvxcxj2z7xs3dm.png)

I started with Ruby so I put in `DEBUG` `INFO `WARN `ERROR` `FATAL`. 

Of course, then I wanted to do it for Java, so I had to add `TRACE`. 

Then Python wanted `CRITICAL` so...  spreadsheet time. 

Here's the sheet I ended up with. It was a fun tour. 
![Grid of all log levels available in top languages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q0q4scbqja3r4dlpsd26.png)

I wrote up some details and ideas / humor about why I think each language chose what it chose [here](https://www.prefab.cloud/blog/so-many-levels/), but just take a look at the grid, I was surprised by how many there are.
Moving Zeros To The End
Tags: javascript, webdev, codenewbie, learning
Published: 2023-04-25 15:53:33

### DESCRIPTION:

Write an algorithm that takes an array and moves all of the zeros to the end, preserving the order of the other elements.

### Examples

```js
moveZeros([false,1,0,1,2,0,1,3,"a"])
// returns[false,1,1,2,1,3,"a",0,0]
```

### My approach for solving this problem:


> - I want to loop throw the array 
> - when item == 0 I need to remove it from the array then push it to the end of the array
> - return the final array

### My solution:

```js
const moveZeros =(arr)=> {
    for (let i = arr.length - 1; i >= 0; i--) {
      if(arr[i] === 0){
        arr.splice(i, 1) && arr.push(0);
      } 
    }
  return arr
 };
```
I breath with your support, sometimes I feel discouraged when I don't get reactions on my posts. so please Like 👍 & repost 🔄 if you can. Thanks for being here!

### Follow _Muhmmad Awd_ on 
<a href="https://www.linkedin.com/in/muhmmadawd"><img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white"/></a>

<a href="https://github.com/MuhmmadAwd"><img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white"/></a>

If you have any questions or feedback, please feel free to contact me at 
<a href="muhmmad.awd@gmail.com"><img src="https://img.shields.io/badge/Gmail-D14836?style=for-the-badge&logo=gmail&logoColor=white"/></a>
Wie kann ich meine Küche renovieren?
Published: 2023-04-25 15:45:49


Hallo zusammen! Ich möchte meine Küche renovieren und suche nach Ideen und Inspirationen. Ich habe gehört, dass es viele verschiedene Möglichkeiten gibt, wie man eine Küche renovieren kann - von der Umgestaltung des Layouts bis hin zur Installation neuer Geräte. Könnt ihr mir Tipps geben? Was sind die neuesten Trends in der Küchenrenovierung?
Developer Insights From Robin Thurston: Founder of MapMyFitness and CEO of Outside
Published: 2023-04-25 15:42:48

[https://hackernoon.com/developer-insights-from-robin-thurston-founder-of-mapmyfitness-and-ceo-of-outside](url)

Check out this interview with Robin Thurston, founder of MapMyFitness and CEO of Outside, where he shares his insights on software development, entrepreneurship, and leadership.

In this interview, Thurston talks about his experience building MapMyFitness and his journey as an entrepreneur. He also emphasizes the importance of diversity and inclusion in the tech industry, and how Outside is working to create a more inclusive and equitable workplace.
Explaining event.target
Tags: webdev, javascript
Published: 2023-04-25 15:39:04

My name is Eli Friedlander. As I begin my software engineering journey there are many topics that I could dig deeper into. Throughout the past weeks I have often been confused about the syntax, usage, functionality, etc. of different nuances in javascript, HTML, and CSS. I’ve found solace in blog posts such as this. I hope this can help clear any confusion you may have surrounding the use of “event.target”.

In short - event.target is a property of an event object that _targets_ the specific element that triggers the event. This becomes useful when you are looking to return the _value_ of the element that triggered the referenced event. 

## When to use:

As mentioned above - the target property is used to retrieve any attribute or property of the event it is attached to. Let’s say we have an event listener for an input box like below:

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

First, we are targeting the input box with ID ‘input’ and naming it ‘inputBox’ so that we may attach an event listener to it.

Second, we attach an event listener that is triggered when the input box is interacted with.

So what’s next? Now that we have our event listener we can use the target property to:

1. Retrieve the element of the fired event
2. Access different properties of the fired event
3. Modify properties and attributes of the element 

## Syntax:

The Syntax for using the target property on events is not too different from other syntaxes that leverage dot notation; ‘target’ is added after the event with dot notation like below: 

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

These are a few examples of how you would use event.target to access different attributes of the event, such as the ‘value’ or a specific CSS element. In the first console.log we are simply returning the event object. The second console returns the actual value of the event which can prove useful when you’re looking to attach a command to a value return. The last example portrays how you can use event.target to modify CSS attributes.

In summary, event.target is a way to access the value or specific attributes of an event when an event listener is attached. 

I hope this helped clear up some doubts you may have around how / when to use event.target!
Resolvendo problemas no HackerRank: Dividindo alimentos
Tags: javascript, beginners, programming
Published: 2023-04-25 15:37:12

Olá, seja bem vindo a mais um Resolvendo problemas no HackerRank: No caso de hoje, você é um rei que está dividindo a comida para o povo, pois tempos difíceis chegaram e o povo passa por dificuldades. Vejamos mais informações com a explicação e sua resolução.

**Fair Rations -**

Você é o governante benevolente do Castelo Rankhacker e hoje está distribuindo pão. Seus súditos estão em fila e alguns deles já têm alguns pães. Os tempos são difíceis e os estoques de alimentos do seu castelo estão diminuindo, então você deve distribuir o menor número possível de pães de acordo com as seguintes regras:

- Cada vez que você dá um pão para alguém `i`, você também deve dar um pão para a pessoa imediatamente à frente ou atrás deles na fila (ou seja, pessoas `i`+ 1 ou `i`-1)

- Depois que todo o pão for distribuído, cada pessoa deve ter um número par de pães.

Dado o número de pães já possuído por cada cidadão, encontre e imprima o número mínimo de pães que você deve distribuir para satisfazer as duas regras acima. Se isso não for possível, imprima _NO_.

Vejamos o código a seguir:

```
function fairRations(B) {
    // Write your code here
  let c = 0

  for (let i=0; i<B.length-1;i++) {
      if (B[i] % 2  !== 0) {
          B[i]++
          B[i+1]++
          c+=2 
      }
}
  return (B[B.length-1] % 2 == 0) ? c : 'NO'
}
```

No código acima criamos uma variável c com valor inicial 0. Criamos também uma estrutura de repetição que irá passar por dentro do comprimento de `B` - 1, e adicionar +1. Se o index de B tiver o restante divisível por 2 diferente de 0, devemos adicionar 1 ao index do array dentro de B, e adicionar 1 ao array index e a propriedade `B`e por fim adicionar 2 a variável `c`. Retornarmos ao final o array de B com seu comprimento -1 e seu restante divisível por 2 idêntico a 0. Caso contrário, retornaremos uma string escrita "NO", onde iremos dizer que o rei não conseguiu dividir os alimentos.

O resultado será:

```
5
2 3 4 5 6

input: 4
```

Assim, concluímos mais um _Resolvendo problemas no HackerRank:_ até a próxima.
Java Interview - Understanding HashMap
Tags: java, interview, programming, backend
Published: 2023-04-25 15:36:20

Hey Programmers!
HashMap is one of the most used Java Collection. Understanding HashMap is critical and important in order to succeed in day-to-day programming tasks.

I recently uploaded two videos on HashMap. Please do checkout if you want to master HashMap.

- HashMap Hands-on - https://youtu.be/vtjkyOaHSyw
- Understanding internal working of HashMap - https://youtu.be/n36dFd79v40

Hope you like it. Happy learning!
How to generate Typescript types for GraphQL queries in a React app
Tags: graphql, typescript, vite, react
Published: 2023-04-25 15:34:36


In this article, we'll walk you through the steps for updating the configuration of a frontend React app to generate Typescript types for GraphQL queries based on your API schema. By the end of this tutorial, you'll be able to import `.graphql` files and get fully typed `data` returned by `useQuery` so that your IDE can show you autocomplete suggestions for the fields that can be accessed.

To get started, create a simple React application named `users` using Vite for running and building the app. You can create it any way you want (e.g. CRA or Next.js).

Let's start by defining the type of experience we would like to have, and then we'll work our way up to adding all the configuration in place.

Create a GraphQL file named `getUser.graphql` and add the following query to it:

```gql
query User($id: ID!) {
  getUser(id: $id) {
    id
    name
  }
}
```

Next, create a simple React component that will fetch the user and display their name.

```javascript
import { useQuery } from '@apollo/client';

import { UserDocument } from './getUser.graphql';

type Props = {
  id: string
}

export function User({ id }: Props) {
  const { data, loading, error } = useQuery(UserDocument, { variables: { id } });

  if (loading) return <Spinner />;
  if (error) return <Error />;

  return <span>{data.getUser.name}</span>;
}
```

For this example, we are using the Apollo GraphQL client, but the same example will work just fine with any other client (e.g. URQL) that supports `TypeDocumentNode`s.

To enable such a development experience, we need to install the following NPM dependencies:

```bash
npm i -D @lente/vite-plugin-graphql @graphql-codegen/typescript-operations @graphql-codegen/typed-document-node @babel/preset-typescript @babel/preset-react
```

At the top level of your project, add a `.graphql-let.yml` file with the following content:

```yml
schema:
  - schema.graphql

documents:
  - '**/*.graphql'

plugins:
  - typescript-operations
  - typed-document-node
```

Under the hood, `@lente/vite-plugin-graphql` uses `graphql-let`, and `.graphql-let.yml` is where we define where the GraphQL schema is located and how to identify the GraphQL files to be parsed. Check out this repo for more details on the options available https://github.com/piglovesyou/graphql-let.

Finally, add the configuration to `vite.config.ts` for loading the `.graphql` files:

```javascript
import { defineConfig } from 'vite';

import graphql from '@lente/vite-plugin-graphql';

export default defineConfig({
  ...
  plugins: [
    ...
    graphql({
      include: /\.(graphqls?|gql)$/i,
      babel: {
        presets: ['@babel/preset-typescript', '@babel/preset-react'],
      },
      rootContext: __dirname, // path to directory containing `graphql-let.yml`
    }),
  ],
  ...
});
```

Now you can start the application, and it should automatically parse the GraphQL files and generate the corresponding types.

You can check out this GitHub repository https://github.com/alex-vladut/vite-graphql-example.
DB Transactions In Laravel
Tags: laravel, php
Published: 2023-04-26 10:09:03

---
title: DB Transactions In Laravel
published: true
date: 2023-04-25 15:25:30 UTC
tags: Laravel,php
canonical_url: https://larachamp.com/db-transactions-in-laravel/
---

Hi readers, If you are new to Laravel or just starting with web development, you might have heard about the term “transactions”. We use transactions in Laravel as an essential concept that is widely used to maintain data consistency.

## What are Transactions in Laravel?

In Laravel, we use Transactions to ensure that the database remains in a consistent state by executing a set of database operations as a single unit of queries. This guarantees that all operations are either committed or rolled back in case of an error. For example, if you are running a group of queries and any one query failed then not even one query will execute.

## Why are Transactions Important?

Executing multiple queries simultaneously can potentially cause inconsistencies in the database. But transactions ensure that the database remains in a consistent state. Thus, transactions play an important role in maintaining the integrity of the database. Transactions allow us to avoid the risk of data corruption. This Ensures that your application is always in a predictable state.

For example, suppose we are creating a new user in your database, and at the same time, we are also updating the user’s profile. To avoid inconsistencies, we would execute these operations together as a transaction in that case.

## Using Transactions in Laravel

Using transactions in Laravel is simple, and you can use the `DB` facade to start a transaction, commit it or roll it back. Here is an example of how you can use transactions in Laravel:

```
DB::beginTransaction();

try {
    // Your database queries
    DB::table('users')->insert(['name' => 'John Doe', 'email' => 'johndoe@example.com']);
    DB::table('profiles')->where('user_id', 1)->update(['phone' => '1234567890']);

    DB::commit();
} catch (\Exception $e) {
    DB::rollback();
}

```

Read Also:[WhereHas In Laravel](https://dev.to/_gurpreetkumar/how-to-use-wherehas-in-laravel-56m5-temp-slug-5005496)

## Conclusion

Transactions are an essential concept in Laravel and web development, and you should always use them to ensure data consistency and integrity. I hope this will help.

The post [DB Transactions In Laravel](https://larachamp.com/db-transactions-in-laravel/) appeared first on [Larachamp](https://larachamp.com).
GPT3.5+
Published: 2023-04-25 15:15:37

The more I see of GPT and its capabilities, the less I know what's not possible with it.
It is truly a game-changer in the field of natural language processing and has the potential to revolutionize the way we approach various challenges faced in agriculture. 

One of the most impressive features of GPT3.5+ model is its ability to follow through the "thoughts" or "chat" messages, which can be extremely useful for creating reports, summaries and recommendations out of multi-layered data sources. 

This Auto-GPT tool developed by Significant-Gravitas is a great example of how GPT can be used to automate tasks that would otherwise require significant time and effort. I recommend checking out their GitHub for it's a truly fascinating concept - to let the model figure out how to achieve a programmed goal. 

I see that GPT can be useful in agriculture and precision farming. Say, by analyzing data from various sources such as weather patterns, soil conditions, and crop yields, GPT can help farmers make more informed decisions about when to plant, fertilize, and harvest their crops. 

At AGXactly, we're exploring frontiers of this technology.