teleren/devto huggingface dataset:
Php features: constructor changes
Tags: php
Published: 2024-05-01 09:19:23

After [attributes](https://dev.to/xwero/php-features-attributes-32p6) and [first-class callable syntax](https://dev.to/xwero/php-features-first-class-callable-syntax-5ab1) I got the idea to bundle the method parameter improvements.

## Theory

Php 8.0 [constructor property promotion](https://www.php.net/manual/en/language.oop5.decon.php#language.oop5.decon.constructor.promotion). 
Php 8.1 introduced [new in initializers](https://wiki.php.net/rfc/new_in_initializers).

Constructor property promotion makes it easier to create classes without repetition. While new in initializers is more geared to attributes, specifically to allow nested attributes 

## Code

```php
class A{
   function __constructor(public string $b, private $c = new C()) {}
}
```
Before you had to write it like this
```php
class A {
  public string $b;
  private $c;

   function __constructor(string $b) {
      $this->b = $b;
      $this->c = new C();
   }
}
```
Which is more verbose.

I don't recommend to use the initializer, because the tests will have to be at least integration tests. But it is good to know that it is possible.

In php 8.0 If you wanted nested attributes you had do something like this

```php
#[Validators(
 ['password' => [
   'required',
   'minLength' => 8
 ]]
)]
```
Now you can do
```php
#[Validators(
 ['password' => [
  new Required(),
  new MinLength(8)
 ]]
)]
```
While it doesn't change much for the example code. It makes the code less error prone because a typo will be discovered sooner. And an IDE will autocomplete the attribute for you.
When the attributes have multiple parameters you can also use named parameters, but that is for a another post.
Designing with accessibility in mind: Labour Day Poster
Tags: a11y, javascript, html, css
Published: 2024-05-01 08:53:36

## Introduction 

Inspired by [Jen Simmon's Layout Lab](https://labs.jensimmons.com/), I will be taking design and layouts that I come across and imagining how they would be built as webpages (using HTML, CSS and JavaScript) with **accessibility as a priority**.

## Start of exercise

Today's exercise is using a funky Labour Day poster that caught my attention. Let's imagine this as a web page and figure out how to recreate it using HTML, CSS and JavaScript while keeping accessibility in mind!

![Labour day poster](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/al46vl097rsc2mfwepe8.jpg)

At first glance it's clear that plenty of CSS magic will be needed to bring these twisted letters and sentences to life as they are in this design.

Let's start by deciding the HTML structure of the page and imagine how a screen reader user would best map out this information.

I landed on the following:

```

<H1>Labour day & Eve Party</H1>
<p>Live Music & DJS</p>
<H2 class="sr-only">Dates</H2>
 <ul>
  <li>Monday 11 March</li>
  <li>Sunday 10 March</li>
 </ul>
<H2 class="sr-only">Details</H2>
   <ul>
        <li>Food & drinks specials</li>
        <li>Open both days til'late</li>
        <li>No cover charge</li>
    </ul>
```

Let me explain:

1. I believe 'Labour Day & Eve Party' is an apt title because it clearly states the meaning of the page, which is to advertise the Labour Day event.
2. 'Live Music & DJs' is a piece of information about the event, but not necessarily a heading. I think a `<p>` tag is fine.
3. I've added two level H2 headings named 'Dates' and 'Details' that are not present in the design. The titles create clear distinct sections that would help screen reader users map out the page and jump to sections.
4. The dates and the details are lists, so they are written as lists.
5. 'Live Music & DJs' can also be written as a list item under the 'Details' heading and displayed differently using CSS. However, that would create even more of a mismatch between the reading order and visual order.

```

<H1>Labour day & Eve Party</H1>
<H2 class="sr-only">Dates</H2>
 <ul>
  <li>Monday 11 March</li>
  <li>Sunday 10 March</li>
 </ul>
<H2 class="sr-only">Details</H2>
   <ul>
        <li>Live Music & DJS</li>
        <li>Food & drinks specials</li>
        <li>Open both days til'late</li>
        <li>No cover charge</li>
    </ul>
```


I did attempt to recreate this page using CSS but the H1 letters were tricky. My method was to use CSS grid + JavaScript to separate the letters into specific spots. I have left it alone for the sake of my own time, sanity and the scope of this exercise.

_Note: These are exercises are mostly for my own learning, so please read with caution as they might be incorrect. If you know of better method, or something I said was wrong, I would love to hear your feedback!_
ABEND dump #10
Tags: news, newsletter
Published: 2024-05-01 08:47:43

Welcome to the **ABEND dump**, where I share the most interesting content I’ve been reading, listening to, and watching lately.

Want to check the previous issue? Read it here:

{% embed https://dev.to/bitmaybewise/abend-dump-9-2hkk %}

Would you like to know what an ABEND dump is? Check it out here:

{% embed https://dev.to/bitmaybewise/abend-dump-0-3i5i %}

---

## [So you want to be a wizard by Julia Evans](https://jvns.ca/wizard-zine.pdf)


![So you want to be a wizard by Julia Evans](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vsyhayv997o0ptco5dco.jpg)

Julia Evans is amazing at teaching and her zine on how to approach learning hard things and get better at programming is pure gold!

## [10 Postgres tips for beginners](https://postgres.ai/blog/20230722-10-postgres-tips-for-beginners)

Even if you’ve been using Postgres for quite a while, perhaps you can learn one thing or two by reading this insightful article — I certainly did regarding how Postgres performs the autovacuum.

## [25 lines web server](https://youtu.be/7GBlCinu9yg)

{% embed https://youtu.be/7GBlCinu9yg %}

This video from Computerphile is another testament to why it’s one of my favorite YouTube channels.

If you never tried writing your own HTTP server, watch this video and see how simple it can be if you cut some corners and do it purely for educational purposes.

If you prefer a guided step-by-step approach, the course from [codecrafters.io](https://app.codecrafters.io/courses/http-server/overview) is great too. [I did it in Haskell](https://gitlab.com/bitmaybewise/codecrafters-http-server-haskell/-/blob/1ca20d65ed1faef838047eb9fda3ed81e750b3db/app/Main.hs) and had lots of fun!

## [How we’ve saved 98% in cloud costs by writing our own database](https://hivekit.io/blog/how-weve-saved-98-percent-in-cloud-costs-by-writing-our-own-database/)

Purpose-built databases are something that has piqued my interest lately. Maybe I should write my own just for fun and educational purposes.

If you prefer you could watch [ThePrimeagen](https://twitter.com/ThePrimeagen) video on YouTube reacting to the blog post:

{% embed https://youtu.be/vi-qMzxxtYs %}

---

If you liked this post, consider subscribing to my newsletter [Bit Maybe Wise](http://bitmaybewise.com/).

You can also follow me on [Twitter](https://twitter.com/bitmaybewise) and [Mastodon](https://mastodon.online/@bitmaybewise).
Images not appearing in CardContainer components
Tags: react, help
Published: 2024-05-01 08:36:56

I'm facing an issue with my React application where the images inside my CardContainer components are not appearing on the page. The CardContainer components themselves are rendering properly, and the styling is being applied correctly. However, both the default images and the hover images generated by the getHoverImg function are not showing up.

Here's the relevant code snippet:

import React from 'react';
import { useParams } from 'react-router-dom';
import "./CardCollection.css";
import TopNavbar from "../Index/IndexPageComponents/TopNavbar/TopNavbar.jsx";
import SuccessStory from '../Index/IndexPageComponents/SuccessStory/SuccessStory.jsx';
import ContactNavbar from '../Index/IndexPageComponents/ContactNavbar/ContactNavbar.jsx';
import BottomNavbar from '../Index/IndexPageComponents/BottomNavbar/BottomNavbar.jsx';
import CardContainer from '../Introduction/TarotIntroductionComponents/CardContainer/CardContainer.jsx';
import TextContainer from '../Index/IndexPageComponents/TextContainer/TextContainer';

export default function CardCollection() {
    const { cardsName } = useParams();

    const getHoverImg = (defaultImg, hoverImg) => {
        return hoverImg ? hoverImg : defaultImg.replace('.jpg', '-hover.jpg');
    };

    // Data for each Tarot card
    const collectionCardData = {
        'major-arcana': [
            // Card data here
        ],
        'minor-arcana': [
            // Card data here
        ],
    };

    const cardData = collectionCardData[cardsName];

    if (!cardData) {
        return <div>Card data not found</div>;
    }

    return (
        <div className='background_image'>
            <TopNavbar />
            <TextContainer 
                title={cardsName} // Assuming you want to display the category name as title
            />
            <div className='card-container-wrapper-major-arcana'>
                {cardData.map((card, index) => (
                    <CardContainer
                        key={index}
                        img={card.img}
                        hoverImg={card.hoverImg}
                        link={card.link}
                    />
                ))}
            </div>
            
            <div className="success-story-box-container">
                <SuccessStory />
                <SuccessStory />
                <SuccessStory />
            </div>
            <ContactNavbar />
            <div className="success-story-box-container">
                <SuccessStory />
                <SuccessStory />
                <SuccessStory />
            </div>
            <BottomNavbar />
        </div>
    );
}

I've verified that the image paths and hover image paths are correct, and the getHoverImg function is working as expected. However, the images are still not appearing on the page.

(I am using the same images in another component, and there they are rendering, so it has nothing to do with the file names or existence)
Building Beautiful Apps: A Beginner’s Guide to Flutter
Published: 2024-05-01 08:28:34


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

1-If you're looking to accelerate your Flutter project or need specific expertise, consider hiring a professional from Fiverr. Check out these [Flutter Expert Services](https://www.fiverr.com/s/m4BWkx) to enhance your app development.

2-Need help polishing your Flutter app or implementing complex 
features? Get professional assistance by visiting [Hire a Flutter Expert on Fiverr](https://www.fiverr.com/s/m4BWkx).

3-While following this guide, if you find yourself needing additional support, don’t hesitate to seek expert help. You can find experienced Flutter developers here: [Expert Flutter Assistance](https://www.fiverr.com/s/m4BWkx).

4-Looking for professional Flutter developers? Check out Fiverr for expert Flutter services [here](https://www.fiverr.com/s/m4BWkx).
Does Project Documentation Really Matters?
Published: 2024-05-01 08:26:47

Creating software to solve problems is indeed a beautiful thing, and it involves patience and determination. 
 
However, documenting the project, and writing unit tests as well as penetration tests to assert the workflow of the said project are stressful/difficult paths. Without those paths, you are an island to your project especially the *docs* because no one can easily be attracted to your work.
 
 
Documentation plays a pivotal role in ensuring that your project thrives and remains accessible to others. Do not underestimate the documentation of your project, and always update it if there are code changes, the same rule also applies to writing test cases.
 
 
We have different documentation language tools you can learn, and one good thing is that they are easy to master if you take an interest in mastering any of them. Examples are **Markdown (md), reStructuredText (rst)**, etc. For me, I used either of the two. However, if I am writing complex documentation of a project, then Sphinx which uses `rst` is my best shot. Try and pick one and learn if you haven't. Most recruiters and employees do add documentation to their job description as a skill you should possess before they can hire you. So, why don't you start today?
 
 
As software engineers, we don't just design, create infrastructure, and write a bunch of codes, we should also cultivate the habit of writing. It matters a lot because through writing you can express the man's innermost heart.

Please free to ask me questions regarding the documentation of your project. 

You can get me on any of these links:
[LinkedIn](https://www.linkedin.com/in/ejikeme-blaise-2504111b1/), [GitHub](https://github.com/Blaise-93), [Twitter](https://twitter.com/Blaisemat6) or [Stackoverflow](https://stackoverflow.com/users/17365694/blaisemart) 
 
 
#Software #Engineering #softwareengineers #python #pythonsoftwareengineers #fullstack #frontend #Django
Unveiling the Mystery: Decoding the Dilemma of Lambda Deployment in Private Subnets
Published: 2024-05-01 08:12:38

---
title: Unveiling the Mystery: Decoding the Dilemma of Lambda Deployment in Private Subnets
published: true
description: Decoding the Dilemma of Lambda Deployment in Private Subnets
tags: 
---

This article originally published [here] (https://medium.com/@Cloud-DevSecOps/unveiling-the-mystery-decoding-the-dilemma-of-lambda-deployment-in-private-subnets-aafb70fe878c). In this demonstration, we see why we are getting a timeout error when deploying a lambda functions to a public subnet.

I will deploy a VPC with an Internet gateway to demonstrate this error I am not going to deploy any resources in a private subnet, so for the moment I will not create a NAT gateway. After deploying, my VPC belongs as below.


I will deploy a sample Lambda function with role created by default in the vpc-1 in public subnet and I added necessary lambda layers.


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



Below is the code:
```
import requests

def lambda_handler(event, context):
    url = 'https://swapi.dev/api/people/4/'
    response = requests.get(url)
    
    if response.status_code == 200:
        return response.json()
    else:
        return {
            'statusCode': response.status_code,
            'body': 'Failed to fetch data from SWAPI'
        }
```	

General configuration

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



VPC configuration:
Although, the public subnet has a route (0.0.0.0/0)towards internet gateway, the function test will fall into task timed out because the Lambda function itself does not have a publicly accessible IP address.

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

Test python function


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


Now I will deploy my function to a private subnet with NAT gateway in the public subnet. In the route table of the private subnet, I will add a route to 0.0.0.0/0 towards my NAT gateway. I will do a test again.

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

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





Private subnet route table

Test python after private subnet
This is the best practice for a Lambda function to access the resources through internet. In the next article, we will see how to access AWS services (s3,RDS, DynamoDB)from private subnet without NAT.
Journey towards self hosted AI code completion
Tags: llama3, vscode, webdev, ai
Published: 2024-05-01 08:07:12

So after I saw a video of Llama3 8b doing 800-1000 tokens/s I instantly thought it would be phenominal to have that on my laptop instantly giving me responses that I could select or discard with the added side benefit would be to learn some new tech.

I have once coded a small AI trained on like 100.000 items trying to predict housing prices, let me say it was not great.

But again I don't have billions upon billions of records to train on nor the compute to train a decent model but I like the control over my coding environment.

### The first goal

> Having llama 8b running locally autocompleting code snippets.

Yeah I know the barrier are low but is most def a useful starting point. I personally dont believe in setting unobtainable goals because failing at something hard is not as great as succeeding at small increments.

Lastly I intent to make a guide on my complete journey sub and like to get notified when new content is published

_Banner video is from [groq.com](https://groq.com/) a great service where you can test these open source models like llama not sponsored by them just wanted to credit_
１３章68
Published: 2024-05-01 08:06:40

この問題は、Javaのメソッドオーバーロードと型の一致に関するものです。元のメソッドのシグネチャは次の通りです：

```java
public List<Number> test(Set<CharSequence> s) { ... }
```

このメソッドは、`Set<CharSequence>` 型のパラメータを取り、`List<Number>` 型のリターン値を返します。

問題文に示されたオプションのうち、正しいオーバーロードであるBとFを検討しましょう：

- **B. `public List<Integer> test(TreeSet<String> s) { ... }`**
  - `TreeSet<String>` は `Set<String>` のサブタイプであり、`String` は `CharSequence` のサブタイプです。これは型の階層を維持しているため、オリジナルのメソッドのパラメータに型の互換性があります。
  - 戻り値は `List<Integer>` であり、`Integer` は `Number` のサブタイプです。したがって、このオーバーロードは問題なくコンパイルされ、期待される動作をします。

- **F. `public ArrayList<Number> test(Set<CharSequence> s) { ... }`**
  - パラメータ `Set<CharSequence>` はオリジナルのメソッドのパラメータと完全に一致します。
  - `ArrayList<Number>` は `List<Number>` の実装であり、戻り値の型として有効です。こちらも互換性があり、期待どおりに動作します。

その他の選択肢は、型の一致が正しくないか、オーバーロードのルールに違反しています。そのため、BとFが正しい答えとなります。
#2000. Reverse Prefix of Word
Published: 2024-05-01 07:51:19

https://leetcode.com/problems/reverse-prefix-of-word/?envType=daily-question&envId=2024-05-01

```javascript
/**
 * @param {string} word
 * @param {character} ch
 * @return {string}
 */
var reversePrefix = function (word, ch) {
    if (word.indexOf(ch) === -1) return word

    word = word.split('')
    let idx = word.indexOf(ch)
    let reverse = word.splice(0, idx + 1)
    reverse.reverse()

    let newWord = reverse.concat(word)

    return newWord.join('')
};

```
１３章63
Published: 2024-05-01 07:22:43

このJavaプログラムにおける問題の解答について説明します。ここで求められているのは、配列 `array` の内容を逆順に出力するコードの選択です。

配列 `array` は `{1, 2, 3, 4, 5}` と初期化されています。配列の長さを示す変数 `x` は `array.length` によって5に設定されています。Javaで配列のインデックスは0から始まるため、最後の要素のインデックスは4です。

それぞれの選択肢を見ていきましょう：

### 選択肢 D
```java
while (0 < x) {
    x--;
    System.out.println(array[x]);
}
```
このループは `x` が0より大きい間続きます。ループ内で最初に `x--` が行われるため、`x` が5から1まで減少します。`array[x]` はインデックス4から0までの要素を逆順に出力します。これは望ましい動作です。

### 選択肢 E
```java
while (0 < x) {
    System.out.println(array[--x]);
}
```
こちらのループも `0 < x` が真である間続きますが、出力する前に `--x` で `x` をデクリメントします。これにより、`x` が最初の繰り返しで4から始まり、最後に0になるまで続きます。出力は `array[4]` から `array[0]` までの要素を逆順に行います。

### その他の選択肢
- **選択肢 A** と **選択肢 B** は `x` の初期値が配列の長さである5から始まるため、`array[5]` を参照しようとして `ArrayIndexOutOfBoundsException` を引き起こします。
- **選択肢 C** も同様に `do-while` ループの最初の繰り返しで `array[5]` を参照し、例外が発生します。

以上から、**選択肢 D** と **選択肢 E** だけが正しく配列の内容を逆順に安全に出力するコードとなります。

## 追記

選択肢A、B、Cのコードについても、それぞれの動作を説明します。これらの選択肢がなぜ期待される逆順出力（54321）を達成しないかも解説します。

### 選択肢A
```java
while (0 <= x) {
    System.out.println(array[x]);
    x--;
}
```
このコードは、配列の長さ `x` が5から始まります。しかし、配列のインデックスは0から4までです。このため、`array[5]` へのアクセスは存在しないインデックスにアクセスしようとするため、`ArrayIndexOutOfBoundsException` という例外が発生します。最初のループでエラーが起きるため、このコードは機能しません。

### 選択肢B
```java
do {
    x--;
    System.out.println(array[x]);
} while (0 <= x);
```
`do-while` ループは、少なくとも1回はループ内のコードが実行されることが保証されています。このコードも `x` の初期値が5で始まるため、ループの最初の `x--` で4になりますが、ループが終了するまでに `x` が0になった後、さらにデクリメントされ `-1` になると `array[-1]` にアクセスしようとして同様に `ArrayIndexOutOfBoundsException` が発生します。

### 選択肢C
```java
do {
    System.out.println(array[x]);
    x--;
} while (0 <= x);
```
この `do-while` ループは、選択肢Bと同様に動作しますが、最初のステートメントが `System.out.println(array[x]);` であるため、ループが開始する前に `x` が5であり、これは存在しないインデックスへのアクセスを試みるため、同じく `ArrayIndexOutOfBoundsException` を引き起こします。

これらの選択肢は、配列のインデックス範囲外へのアクセスや、末尾のインデックスから開始しないために期待される出力を達成できません。正しい範囲内で配列要素にアクセスし、逆順で出力するには、選択肢DやEのように `x` の初期値をデクリメントしてから配列要素にアクセスすることが必要です。
REBECCA KENNEDY AGE, FITNESS TRAINER, AFFAIR, HEIGHT, WEIGHT
Tags: seo, celeberties, famous, most
Published: 2024-05-01 07:22:08

**1. Introduction to Rebecca Kennedy: **A Fitness Guru with a Passion for Wellness

[Rebecca Kennedy](https://famcelebrities.com/rebecca-kennedy-age-fitness-trainer-affair-height-weight/) is a renowned fitness trainer whose dedication to health and wellness has made her a prominent figure in the industry. With a focus on empowering individuals to lead healthier lifestyles, Kennedy's journey as a fitness guru is marked by her commitment to helping others achieve their fitness goals. In this article, we delve into key aspects of her life, including her age, career as a fitness trainer, personal affairs, height, and weight.

**2. Age: Unveiling the Timeless Beauty of Rebecca Kennedy
**
While specific details about Rebecca Kennedy's age may not be readily available, her timeless beauty and vibrant energy defy conventional notions of aging. Kennedy's dedication to fitness and wellness has undoubtedly contributed to her youthful appearance and vitality. As she continues to inspire others to prioritize their health and well-being, Kennedy's age becomes less relevant, eclipsed by her passion and commitment to empowering others.

**3. Fitness Trainer: Rebecca Kennedy's Path to Empowering Others
**
Rebecca Kennedy's career as a fitness trainer is characterized by her unwavering dedication to helping individuals achieve their fitness goals. With a background in exercise science and a passion for holistic wellness, Kennedy's approach to fitness emphasizes balance, strength, and mindfulness. Through her innovative workout programs and motivational coaching, Kennedy empowers her clients to embrace healthier lifestyles and unlock their full potential.

Kennedy's expertise extends beyond traditional workout routines, encompassing a holistic approach to wellness that addresses both physical and mental well-being. Whether leading high-energy fitness classes or providing personalized coaching sessions, Kennedy's impact on her clients' lives is profound, inspiring them to make positive changes that extend far beyond the gym.

**4. Personal Affairs, Height, and Weight: Insights into Rebecca Kennedy's Life
**
While Rebecca Kennedy's professional endeavors as a fitness trainer are widely recognized, details about her personal life, including any romantic affairs, height, and weight, remain private. Kennedy's focus remains on her mission to promote health and wellness, and she may choose to keep certain aspects of her personal life out of the public eye.

Kennedy's dedication to her craft and her unwavering commitment to helping others achieve their fitness goals are evident in every aspect of her life. While specific details about her personal affairs, height, and weight may not be publicly disclosed, Kennedy's impact on the fitness industry and her clients' lives speaks volumes about her passion and dedication to her work.
Air Canada SIN Terminal
Tags: webdev
Published: 2024-05-01 07:10:30


The national airline of Canada, [Air Canada SIN Terminal](https://www.terminalsguides.com/air-canada/air-canada-sin-terminal-singapore-changi-airport/), has a long and illustrious history in aviation spanning several decades. As one of the top airlines in the world, Air Canada is well-known for its dedication to safety, innovation, and client pleasure. Air Canada continues to set the standard for air travel with its state-of-the-art fleet of aircraft, extensive worldwide network, and commitment to providing exceptional customer service.