teleren/devto huggingface dataset:
Episode 23/42: Template Control Flow & @defer, Forms & Signals
Tags: angular, webdev, javascript, programming
Published: 2023-10-26 23:22:58

Angular 17 comes closer. Last week, we received the first beta release.

[Angular 17: Release Candidate](https://github.com/angular/angular/releases/tag/17.0.0-rc.0)

## Mark Thompson & Alex Rickabaugh on new Template Syntax and `@defer`

Mark Thompson and Alex Rickabaugh, both members of the Angular team, discussed the upcoming additions for the template at Angular Nation.

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

According to Mark, the new template syntax is backwards-compatible. An automatic migration might be available in version 17 but we can still use the old version with structural directives.

[Direct Link](https://www.youtube.com/watch?v=QrEH53tSUf0&t=804s)

In addition, Mark suggested that Angular leads the way againt, and that other frameworks will soon to come up with similar features.

[Direct Link](https://youtu.be/QrEH53tSUf0?si=BnLJdfvWnXzO3xO7&t=744)

Whether the new template syntax will be in developer preview or stable is still being determined. A possible reason for developer preview might be that parts of the underlying algorithm for lists are different.

Alex underlined that this shouldn't be a reason to stick to the old structural directives.

[Direct Link](https://www.youtube.com/watch?v=QrEH53tSUf0&t=2433s)

A benchmark from the alpha version confirms the performance improvement when list rows change their order. This is precisely the part that Alex mentioned.

{% embed https://twitter.com/pkozlowski_os/status/1714959894317568127 %}

## Template-Driven Forms and Signals

Combining Signals with Template-Driven Forms is quite lengthy. We cannot use two-way binding but have to fall back to an explicit, even listener.

Brecht Billiet of SimplifiedCourses published a video where he uses a two-liner directive which seamlessly updates Signals via on valueChanges and thus reduces quite a lot of boilerplate code.

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

## State Adapt 2

NgRx is the number one in Angular regarding state management, but alternatives exist. A young one is State Adapt, which was released in version 2.

It distinguishes itself by a declarative style. StateAdapt can run on top of NgRx but also natively. Support for the Redux DevTools is available. The author of StateAdapt is @mfp22. He frequently publishes articles on dev.to around state management and other topics around Angular.

{% embed https://youtu.be/lLfafNPVs5g?si=xXQHZcIfh146QiDV %}

## RxAngular

RxAngular, another library for state management, had a minor version upgrade to 16.1.

RxAngular is actually a suite where parts of it are for state management. The other part is about directives you can use for Angular applications with a high-performance demand.

{% embed https://www.rx-angular.io/ %}
How to estimate the number of rows and size of tables in Postgres DB?
Tags: devops, postgres, database
Published: 2023-10-26 22:59:57

How to estimate the number of rows and size of tables in Postgres DB?

```
select
    nspname as schema,
    relname as tablename, 
    to_char(reltuples, '999,999,999,999') as rowcounts,
    round(pg_relation_size(c.oid)/1024/1024/1024) AS tablesize_gb
  from pg_class c JOIN pg_catalog.pg_namespace n
   ON n.oid = c.relnamespace where relkind='r' and nspname = 'public' 
   order by nspname, reltuples desc;
```
React AND nginx
Tags: react
Published: 2023-10-26 22:29:04

Hello,

I am supposed to set up a React project on my server for a friend and I am still looking for the right solution.

He sent me his project and I built it with "npm run build".

This has worked so far, the data is now in /build/ but the PHP files are still in /src/.

But what is now the correct way to deploy such a data e.g. under Debian?

Way a) would be the possibility via "aserve -s build" and I could then let a nginx with proxy point to this.

Way b) would be /build/ as www-root, but then all PHP files seem to be missing, because they are still in /src/.

What is the right way to do this?

Thanks
Cronjobs: WGet versus PHP CLI in the crontab
Tags: php, cron, cli
Published: 2023-10-26 22:06:43

TL;DR: Use PHP CLI instead of WGET for your crons!

I've noticed devs using wget for all their crons running in the crontab. I've done it too but i thought about it and the crons running from the CLI are not adding the overhead of making an HTTP request to the server on top of the base request.

I did some googling but could not find one clear answer on how this can affect performance. Lots of SO posts and blogs talking about using the two methods with great examples, but not a single one talked about performance. 

So i turned to chatGPT because i too am a lazy developer. 

## Here's what it had to say:

Yes, there can be a performance difference between using `wget` and the PHP CLI (Command-Line Interface) directly in the crontab for running PHP cron scripts.

1. **Using PHP CLI:**
   ```bash
   0 2 * * * php /path/to/your/script.php
   ```

2. **Using wget:**
   ```bash
   0 2 * * * wget -q -O - https://yourdomain.com/path/to/your/script.php
   ```

**Performance Considerations:**

- **PHP CLI:**
  - Directly executes the PHP script using the PHP CLI binary.
  - Usually faster as it avoids the overhead of making an HTTP request.
  - Suitable for scripts running on the same server.

- **Wget:**
  - Makes an HTTP request to the specified URL, which means it involves additional overhead compared to direct CLI execution.
  - May be useful if your script relies on a web server environment or needs to simulate a web request.

**Factors to Consider:**

1. **Server Environment:**
   - If your PHP script is designed to run on the same server where the cron job is scheduled, using PHP CLI is more direct and efficient.
   - If the script relies on a web server environment, using `wget` might be necessary.

2. **Overhead:**
   - Using `wget` introduces additional overhead due to making an HTTP request, parsing headers, etc.
   - PHP CLI directly runs the script without this additional overhead.

3. **Web Server Configuration:**
   - Ensure that the web server configuration allows access to the PHP script if using `wget`.
   - CLI doesn't have this concern as it runs locally.

**Conclusion:**

If the PHP script is designed to run in a command-line environment and doesn't rely on a web server context, using PHP CLI is generally more efficient and direct. If the script requires a web server context or if the server environment is different, then `wget` might be necessary.

It's recommended to benchmark and test in your specific environment to determine the most suitable approach based on your script's requirements and server configuration.
------------------------END chatGPT answer-----------------------

I think it hit the nail on the head, and though i don't have any benchmarks to really compare, i may test it out on some heavy crons i got running and see what happens. It would make sense that removing the HTTP request overhead would cause a small improvement in performance.
Let's interact with Ruby.
Tags: ruby, rails, webdev, womenintech
Published: 2023-10-26 22:03:06

Hey there, it's Khadija from Pakistan. I am a Web Developer.

Recently, I have developed a keen interest in delving deeply into Ruby, and I'm planning to share all my learning experiences with you all. If you are a learning or experienced developer, let's connect and share ideas!

Do you know? Ruby is a versatile and powerful programming language that has garnered a lot of attention since its creation in the mid-1990s. Ruby's syntax is designed to be clean, consistent, and readable. This makes the code not only easier to write but also easier to maintain and understand.

I started with the installation process, which was not easy, even though the language itself is very simple.

I am currently utilizing various resources to enhance my knowledge. These include Codecademy, Pragmatic Studio, and YouTube.

Here's the Ruby resource link if anyone is interested:
[Codecademy](https://www.codecademy.com/courses/learn-ruby)
Como eu estudei para certificação DP900 e fui aprovada
Tags: azure, certification, cloud, braziliandevs
Published: 2023-10-26 21:50:03

Essa foi a minha ultima e a que iniciei os estudos com poucos dias para prova. Então otimizei com os videos do Canal da nuvem:

- [DP-900 | EP 1/4 | DP900 | Treinamento Oficial | Microsoft Azure Data Fundamentals](https://www.youtube.com/embed/-znvy4pHy1Y?si=WM6S5srZJx_slbsq)
- [DP-900 | EP 2/4 | DP900 | Treinamento Oficial | Microsoft Azure Data Fundamentals](https://youtu.be/5xpocWtIrxM?si=Zsz9FW7W_9np6WSj)
- [DP-900 | EP 3/4 | DP900 | Treinamento Oficial | Microsoft Azure Data Fundamentals](https://youtu.be/Dj0VxU633l0?si=PWXVZ0-qWEcKwkSK)
- [DP-900 | EP 4/4 | DP900 | Treinamento Oficial | Microsoft Azure Data Fundamentals](https://youtu.be/uQJKTcF2VTE?si=SDfdogUdHIJ8-Prh)

Assistam e me agradeçam depois!
Java 17 LTS
Tags: java, news, newfeatures
Published: 2023-10-26 21:35:35

**Introduction**
Java 17 is a special version of Java that is designed to be used for production applications. It will be supported by Oracle for many years, so you can be sure that your applications will continue to work even as Java changes.

Other versions of Java are released every six months, but they are not supported for as long. These versions are meant for developers to try out new features and experiment.

If you are developing a Java application that you need to be reliable and stable, you should use Java 17. It will be the most stable and reliable version of Java for many years to come.

Key points about Java 17 as an LTS release:

**1.Extended Support:** Java 17, as an LTS release, will receive updates and bug fixes for a longer period compared to non-LTS releases. These updates are important for maintaining security and stability in production environments.

**2.Compatibility:** LTS releases like Java 17 prioritize backward compatibility. This means that applications developed on previous LTS versions can more easily be migrated to Java 17 without significant code changes.

**3.Enterprise Adoption:** LTS releases are favored by enterprises and organizations for building and maintaining Java applications that require long-term stability. It's a safe choice for applications that have a lengthy lifecycle.

**4.Support from Third-Party Vendors:** Many third-party vendors and Java runtime providers offer extended support and services for LTS releases, ensuring that businesses have a range of options for support.

**5.Features and Improvements:** Java 17 includes various features and improvements over its predecessor versions, making it an attractive choice for new projects and modern Java development.

**6.Security Updates:** LTS releases, including Java 17, will receive regular security updates, which are critical for maintaining the security of applications and systems.

If you are planning to start a new Java project or if you have an existing project that requires long-term support and stability, Java 17 LTS is a strong candidate for your choice of Java version. It's important to stay updated on Oracle's support policies and to consider the support options available from other vendors if you plan to use Java 17 in a production environment.
[Tiny] Injecting Dependency With Default Value in Spring: What Could Go Wrong?
Tags: kotlin, spring, tiny
Published: 2023-10-26 21:26:29

If you are writing applications in Kotlin, you may be using [default value](https://kotlinlang.org/docs/functions.html#default-arguments) Kotlin feature. Be careful though when you use default values for injected dependencies in Spring applications. It may lead to unexpected behaviour, and Spring will not even warn you.

Here is an example.

We have Ford Prefect who depends on humans:

```kotlin
@Component
class FordPrefect(
    private val humans: List<Human>,
) {
    @PostConstruct
    fun init() {
        log.info("humans: $humans")
    }

    companion object {
        private val log = LoggerFactory.getLogger(FordPrefect::class.java)
    }
}
```

Where a human is defined as

```kotlin
interface Human
```

And then we have a couple of humans who depend on Ford:

```kotlin
@Component
class ArthurDent(
    private val fordPrefect: FordPrefect,
) : Human {
    override fun toString() = "Arthur"
}

@Component
class TrishaMcMillan(
    private val fordPrefect: FordPrefect,
) : Human {
    override fun toString() = "Trisha"
}
```

If you start the spring application with these three components, it will fail with `UnsatisfiedDependencyException` due to the circular dependency, which is expected:

```
┌─────┐
|  arthurDent defined in file [/.../ArthurDent.class]
↑     ↓
|  fordPrefect defined in file [/.../FordPrefect.class]
└─────┘  
```

However, the situation changes if you add the default value for `humans` property:

```kotlin
private val humans: List<Human> = emptyList(),
```

Now the application starts without any problem or warning. And it prints an empty list of humans:

```
INFO 6380 --- [           main] gDependencyWithDefaultValueApplicationKt : Starting SpringDependencyWithDefaultValueApplicationKt using Java 17.0.8.1 with PID 6380 (...)
INFO 6380 --- [           main] gDependencyWithDefaultValueApplicationKt : No active profile set, falling back to 1 default profile: "default"
INFO 6380 --- [           main] d.p.s.d.defaultvalue.FordPrefect         : humans: []
INFO 6380 --- [           main] gDependencyWithDefaultValueApplicationKt : Started SpringDependencyWithDefaultValueApplicationKt in 1.179 seconds (process running for 2.067)
```

I bet you do not expect such a thing. By setting the default value you probably expect `humans` to be set with an empty list when no beans of `Human` are available. Or fail as in the previous scenario due to the circular dependency. However, this is not what is happening.

Actually, if you delete both `ArthurDent` and `TrishaMcMillan` components, the application will start and the output will be exactly the same - now as expected.

So, remember this and be careful when you are setting default values for injected dependencies.

The full source code is available on [GitHub](https://github.com/pfilaretov42/spring-dependency-with-default-value).

---

*Dream your code, code your dream.*
Discussion of the Week - v8
Tags: bestofdev, discuss
Published: 2023-10-26 21:17:04

In this weekly roundup, we highlight what we believe to be the most thoughtful, helpful, and/or interesting discussion over the past week! Though we are strong believers in healthy and respectful debate, we typically try to choose discussions that are positive and avoid those that are overly contentious.

Any folks whose articles we feature here will be rewarded with our Discussion of the Week badge. ✨

![The Discussion of the Week badge. It includes a roll of thread inside a speech bubble. The thread is a reference to comment threads.](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yvizv31dpchucxic2lxc.png)

Now that y'all understand the flow, let's go! 🏃💨

## The Discussion of the Week

This week we're spotlighting Dominic (@magnificode) for dropping the discussion "[The Web Industry Has A Hiring Problem 😬](https://dev.to/magnificode/the-web-industry-has-a-hiring-problem-4g98)":

{% embed https://dev.to/magnificode/the-web-industry-has-a-hiring-problem-4g98 %}

Dominic's post shines a light on the disheartening situation many beginner devs face when applying for entry-level positions. These positions are competitive and often have high expectations of those applying. As Dominic notes, many junior-level job descriptions are not-so-junior sounding and sometimes require formal education. Also, these days it's the norm for applications to ask folks to participate in lengthy take-home projects.

The discussion that follows is complex, folks chiming in to agree that there are plenty of challenges new devs face as they apply for those entry-level roles. @pterpmnta brings up the difficulty of trying to land a role at a place that requires  C1 or C2 English level: 

{% embed https://dev.to/pterpmnta/comment/2aa5f %}

Not to mention, there are also some thoughtful, respectful counterpoints brought forth from @theaccordance in this comment:

{% embed https://dev.to/theaccordance/comment/2aa29 %}

All in all, it was a solid discussion well worth having. If anybody has any thoughts on the state of entry-level hiring or perhaps some advice for junior devs who are busy job searching, hop into the thread of Dominic's post and share them with us!  

## What are your picks?

The DEV Community is particularly special because of the kind, thoughtful, helpful, and entertaining discussions happening between community members. As such, we want to encourage folks to participate in discussions and reward those who are initiating or taking part in conversations across the community. After all, a community is made possible by the people interacting inside it.

There are loads of great discussions floating about in this community. This is just the one we chose to highlight. 🙂

I urge you all to share your favorite discussion of the past week below in the comments. And if you're up for it, give the author an @mention — it'll probably make 'em feel good. 💚
How to limit the number of connections on the level of the DB user / Database in the Postgres Server?
Tags: postgres, devops, tutorial, database
Published: 2023-10-26 20:47:23

How to limit the number of connections on the level of DB user in the Postgres Server?

```
ALTER USER my_db_user WITH CONNECTION LIMIT 2;

SELECT rolname, rolconnlimit
FROM pg_roles
WHERE rolconnlimit <> -1;

This query will return nothing if you don't have any custom roll limits set up.
```

How to limit the number of connections on the level of the 
 specific database in the Postgres Server?

```
postgres=> select datconnlimit from pg_database where datname='my_database';
 datconnlimit 
--------------
            0
(1 row)
```

Reset to default value (i.e. no limit).

```
postgres=> alter database my_database connection limit -1;
ALTER DATABASE
postgres=> \q

dmitryr@dmitryr-mac my_postgres % 
```
ELI5: Ethereum Improvement Proposals (EIPs)
Tags: blockchain, ethereum, beginners, web3
Published: 2023-10-26 20:45:23

## Introduction

The concept of Ethereum Improvement Proposals (EIPs) was introduced in October 2015 (about 8 years ago) via a GitHub repository, as a specific method or system for including potential new features or processes for Ethereum. This is done by proposing, discussing, and implementing those changes to the network.
EIPs can range from core protocol changes to application standards.
Interestingly, anyone in the community can submit an EIP, and then various stakeholders in the community will debate to determine if it should be adopted as a standard or included in a network upgrade. If the community agrees, the EIP is implemented in the Ethereum codebase.

#### Here is a simple analogy:

Imagine that Ethereum is a big classroom, and the EIPs are like suggestions for how to improve the classroom. Anyone in the classroom can make a suggestion, and then the class discusses it to see if they want to implement it. If the class agrees, the suggestion is implemented.

For example, one student might suggest that the teacher move the whiteboard to a different location. Another student might suggest that the class start a new project. All of these suggestions would be considered EIPs.

EIPs are important because they allow the classroom to improve over time. The class can make changes that benefit everyone by listening to everyone's suggestions.

There are different types of EIPs, including core EIPs for low-level protocol changes that affect consensus and require a network upgrade, and ERCs for application standards.

#### Below are some EIPs and what their implementation has achieved:

**- EIP-1559:** This EIP changed the way that transaction fees are calculated and paid, making it more predictable and sustainable.
**- EIP-20:** This EIP created a standard for fungible tokens, which are the most common type of tokens on Ethereum.
**- EIP-721:** This EIP created a standard for non-fungible tokens (NFTs), which are unique digital assets that can be used to represent ownership of things like artwork, collectibles, and game items.
Today I learned
Published: 2023-10-26 20:30:03

Today I learned how to define our own class. We use attr_accessor to add attributes to the class. I also learned how to define my own method using the def keyword. There are instance methods as well as class methods. We use the self keyword to refer to certain objects since we don't know the variable name in advance. Using the < notation, we can define a new class that inherits the power of a parent class.
Enable Wireless Debugging on Android Device
Tags: android, tutorial, beginners
Published: 2023-10-26 20:03:11

This article explains how to set up wireless debugging to avoid needing a USB cable plugged into an Android Device.

##Android Settings
####Enable wireless debugging through the Android Settings:
1. Developer options must be enabled first
<p>
a. Go to _Settings_ -> _About Tablet_ -> _Software Information_
<br>
b. Tap _Build Number_ multiple times until you see "You are now in Developer mode!" </p>
2. Go to _Settings_ -> _Developer Options_ and toggle on _Wireless Debugging_
3. Tap _Allow_ in the popup to enable it
4. Follow steps below for **ADB Commands**


##IDE Plugin
####Enable wireless debugging through IDE Plugin:
1. Install the “ADB Wireless Plugin” in your IDE (Or something similar in name. May be “Android Wifi ADB” for example). Typically you'd use Android Studio but I needed to use Intellij.
2. Connect device to computer with a USB cable
3. Connect to device through ADB Wireless Plugin
a. The ADB Wireless Plugin menu should show up in the right-side tool menu.
4. Unplug the USB cable and follow steps below for **ADB Commands**


##ADB Commands
####Set up adb so that commands such as `adb logcat` will run:
1. Connect the device to your computer with a USB cable. Check that USB debugging is working by running `adb devices`. The device should be listed.
2. Run `adb tcpip 5555`
3. Disconnect the USB cable
4. Go to the _Settings_ -> _About Tablet_ -> _Status_ to view the IP address of your device
5. Run `adb connect <IP address of device>:5555`
6. Run `adb devices` again and you should see the device


You can now wirelessly run adb commands!