teleren/devto huggingface dataset:
Effortless HTTP Operations in Java: A Guide Inspired by The Java Workshop
Tags: java, http
Published: 2024-04-30 03:32:14

In the modern era of web development, understanding HTTP operations is crucial. Java, with its rich set of APIs, provides a seamless way to handle HTTP requests and responses. Drawing inspiration from “The Java Workshop,” let’s explore how to perform these operations in Java.

#HTTP: The Foundation of Web Communication
HTTP, or Hypertext Transfer Protocol, is the backbone of data communication on the web. Java’s `java.net.http` package, introduced in Java 11, offers a high-level client interface for sending and receiving HTTP requests and responses.

**Simple HTTP GET Request**
Here’s a simple example of sending a GET request using Java’s `HttpClient`:
![HTTP GET Request](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2jybl668x6jyog2w1crh.png)


#Handling POST Requests
Sending data to a server is often done using a POST request. Here’s how you can do it in Java:
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rputobmzlexep1kgeves.png)

#Conclusion

Working with HTTP in Java is straightforward, thanks to the intuitive `HttpClient` API. Whether you’re making GET or POST requests, Java has you covered. For more in-depth knowledge and practical examples, “The Java Workshop” is an invaluable resource that guides you through the intricacies of Java programming
Migrate Heroku to AWS
Tags: heroku, aws, devops, migrate
Published: 2024-04-30 03:24:59



1.System architecture before migration.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c0g56wlussb037r8l31d.png)

The system includes:
  + 3 Heroku dynos (2 dynos running nodejs and 1 dyno running java)
  + 1 Heroku postgres (Database)
  + 1 Heroku private space

2.Reason for migration
  + The old system is connecting to S3 but the system is located on Heroku, which is difficult to centrally manage
  + The price of Heroku private space is high from 1000$ - 5000$ which is not suitable for websites with only about 200 to 300 people accessing at the same time.

> **After successful conversion, the cost is reduced to 1/3 compared to Heroku**

3.Architecture on AWS
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/86elsft5004b14qul0g9.png)

The system includes:
  + 03 App runner (2 app runner running nodejs and 1 app runner running java)
  + Amazon RDS for PostgreSQL
  + AWS WAF
  + Interface vpc endpoint and Gateway vpc endpoint

4.Notes when using App runner

4.1. Use github to configure CI/CD with App runner
[Refer to the article](https://docs.aws.amazon.com/apprunner/latest/dg/manage-connections.html)
4.2. Use app runner vpc connector
[Refer to the article] (https://docs.aws.amazon.com/apprunner/latest/dg/network-vpc.html)
4.3. Use interface vpc endpoint and gateway vpc endpoint for
  S3
[Refer to the article](https://docs.aws.amazon.com/vpc/latest/privatelink/gateway-endpoints.html)
4.4. Use WAF to allow access to only certain IP addresses
  access the system
[Refer to the article](https://docs.aws.amazon.com/waf/latest/developerguide/classic-web-acl-ip-conditions.html)
4.5. Use the DBeaver tool to easily migrate data from Heroku
  to RDS 
[Refer to the article](https://community.pyramidanalytics.com/t/h7hk07w/how-to-backup-and-restore-a-postgresql-database-via-dbeaver) 

5.Deep Dive on AWS App Runner VPC Networking
[Refer to the article](https://aws.amazon.com/vi/blogs/containers/deep-dive-on-aws-app-runner-vpc-networking/)

If you have any questions, please contact us: [https://www.linkedin.com/in/huydanggdg/](https://www.linkedin.com/in/huydanggdg/)
Find Your Summer Style: The Ultimate Selection of Beach Towels
Tags: watercooler
Published: 2024-04-30 03:22:55

Your Summer Style Unveiled: Choose from our Ultimate Selection of Beach Towels



If you're excited for the summer season to start, we've got some fantastic news for you. This year, we have the ultimate selection of beach towels that cater to every age group and personality.



Benefits of Our Beach Towels:

Our coastline  are manufactured from top-notch materials and intensely are often soft, making them perfect for lounging on the coastline or by the pool.

Our towels can be lightweight, making them an task like pack like straightforward simply take with you.

They're easily obtainable in several sizes and practices, that will help you learn this is the  like ideal fits your preferences and design.

Revolutionary Designs and Protection:

Our Cotton beach towel would be obtainable in additionally a selection of revolutionary designs that attract all preferences and preferences.

We use eco-friendly dyes, that do not damage the environment, and only make use of premium-quality materials which can be safe for skin.

Utilizing Our Beach Towels:

Utilizing our coastline towels will not merely be shake like hard sand out or fold and debris them up if you are done.

They will have been device washable and dryable, therefore them because of the claim like uses that are initial are also many it is possible to get back.

Quality and Service:

We pride ourselves from the standard associated with Microfiber waffle beach towel and possess taken every measure to be sure which they endure a period of time like quite very long.

Our group like devoted of solution agents is usually open to respond to any inquiries no doubt you've and to make sure that you're happy with your purchase.

Applications for the Beach Towels:

Our coastline towels may be used for the quantity like genuine of.

They make perfect picnic blankets, yoga mats, or even while a throw blanket for the sleep or couch.

No matter like use like real store, our coastline towels are versatile and sturdy.



Find Your Summer Style:



In conclusion, our ultimate selection of beach towels provides a wide range of styles and designs that cater to every personality. With our eco-friendly and skin-safe materials, high-quality products, and dedicated customer service, you can find the perfect beach towel that fits your style, needs, and budget. So, what are you waiting for? Unveil your summer style with our Microfiber beach towel and get ready for an unforgettable summer season.
Lets build Quick Start POC for Dapr.io
Tags: microservices, distributedsystems, dapr
Published: 2024-04-30 03:07:09

Lets build Quick Start POC for Dapr.io

> 
Please checkout my POC link  
https://medium.com/@vaibhavhpatil/lets-build-quick-start-poc-for-dapr-io-57ba34f2d830 


“We have what we need, if we use what we have.”
— Edgar Cahn


Why Dapr selected?

> Dapr provides integrated APIs for communication, state, and workflow. Dapr leverages industry best practices for security, resiliency, and observability, so you can focus on your code.
This is true distrusted application runtime support multiple languages and hides complexity of managing distributed application can work as side car pattern — service mesh and Dapr provides integrated APIs for communication, state, and workflow.

Dapr leverages industry best practices for security, resiliency, and observability, so you can focus on your code.


##  Please like and subscribe and be in touch to see my up coming teach radar article series 

**https://medium.com/@vaibhavhpatil**




![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wiuo6r0ssmlmq9y16809.png)
I Wrote a Knowledge Graph Render by LangChain
Tags: langchain, neo4j, knowledgegraph, zhipuai
Published: 2024-04-30 02:53:14

Hello and good morning.

I am a student from Chain. Recently, our teacher let us to write a KnowledgeGraph(as KG) render and save the graph to a graph database like neo4j.

Yeah, I know LangChain already provide the function to generate the graph data, but I still want to build my own version of KG. I tried many models like `phi-3-mini`, `llama3-8b`, but none of them work very well, so I changed my mind to use GLM-4 powered by ZhiPuAI, and it works very well. Here is the showcase: A very large image.

![KG](https://github.com/Helio609/zhipuai_kg_generator/raw/main/knowledge_graph.png)

Although the showcase shows that KG render works very well, but I have some problem to fix:

- I save graph to neo4j, but for the same label nodes, they are all connected to a same label nodes, although they have different type. Just like the word *Key*, *Key* could be related to many different fields like *keyboard* or *database*.

- If I enable the *update* in args, render image will slow down the speed entirely, If there is a better way to show real time graph?
13章３１
Published: 2024-04-30 02:52:35

以下は、それぞれのコード行に対するより詳細なコメントアウトを含む説明です。

クラスAに関するコード:
```java
import java.util.Collection; // Collectionインターフェースをインポートする。

public class A {
    // 'collection'は、どんな種類のCollection（リスト、セットなど）も
    // 保持できるプライベートなメンバ変数です。
    // 'private'アクセス修飾子により、この変数はクラスAの内部でのみアクセス可能です。
    private Collection collection;

    // 'set'メソッドはパブリックであり、外部からこのクラスの
    // 'collection'変数に値をセットするために使用されます。
    // 'Collection'型のパラメータを受け取り、このクラスの'collection'変数に代入します。
    public void set(Collection collection) {
        this.collection = collection; // 現在のインスタンスの'collection'に、引数で渡された'collection'を代入します。
    }
}
```

クラスBに関するコード:
```java
import java.util.Map; // Mapインターフェースをインポートする。

// クラスBはクラスAを継承しているため、Aのメソッドや変数にアクセスできます（継承のアクセスレベルに応じて）。
public class B extends A {
    
    // オーバーライドされた'set'メソッドは、Mapのインスタンスを受け取ります。
    // このメソッドは、Mapの値を'Collection'型として親クラスAの'set'メソッドに渡すために使われます。
    public void set(Map<String, String> map) {
        // クラスAの'set'メソッドを呼び出し、マップの値のコレクションを渡すためには
        // 'map.values()'を使用してマップのすべての値を取得し、それをCollectionとして親クラスの'set'メソッドに渡します。
        super.set(map.values()); // 'super'キーワードを使って親クラスのメソッドを呼び出します。
    }
}
```

適切な行をクラスBの`set`メソッドに挿入すると、選択肢A（`set(map.values());`）が正しいコードになります。これはクラスBがマップの値だけをコレクションとして親クラスAに渡したい場合に使用します。この動作は、クラスBの`set`メソッドにより、`A`クラスの`collection`プライベートメンバに対して間接的にマップの値をセットすることができるようになります。
Tech Radar 4 | Consul HashiCorp
Published: 2024-04-30 02:43:37

Tech Radar 4 | Consul HashiCorp
🙌 Distributed architecture made Easy? 🙌

I am super excited to share small prof of concept (POC) sample example which have created to explore Consul , which OLD champion in distributed architectural word. Hope this can help some one to setup locally as hello word example.


_Lets begin ! happy learning and coding_

In the realm of microservices architecture, addressing common challenges like distributed configurations, locking, and event handling is paramount. In this article, we delve into three indispensable distributed architecture patterns that form the backbone of robust microservices implementations. Consul come into picture and save our life and make our distributed arch life awesome.

> Please visit my blog and like and subscribe if you are ok thanks !

**https://medium.com/@vaibhavhpatil/tech-radar-4-consul-hashicorp-7e409725e0d6**
Cómo un bucket S3 vacío puede hacer que tu factura de AWS explote
Published: 2024-04-30 02:40:05

**Créditos:** Este artículo está basado en las experiencias de Maciej Pocwierz, quien compartió su historia en un [post de blog](https://medium.com/@maciej.pocwierz/how-an-empty-s3-bucket-can-make-your-aws-bill-explode-934a383cb8b1) detallando cómo terminó con una factura exorbitante de AWS debido a un bucket S3 vacío.

## Antecedentes

Maciej estaba trabajando en una prueba de concepto (PoC) de un sistema de indexación de documentos para un cliente. Creó un único bucket S3 en la región `eu-west-1` y subió algunos archivos allí para realizar pruebas. Dos días después, al revisar su factura de AWS, se encontró con un cargo de más de $1,300, ¡con casi 100,000,000 solicitudes PUT a S3 ejecutadas en un solo día!

Al habilitar los registros de AWS CloudTrail, observó que miles de solicitudes de escritura provenían de múltiples cuentas de terceros. Después de investigar, descubrió que una popular herramienta de código abierto tenía una configuración predeterminada para almacenar sus copias de seguridad en un bucket S3, utilizando el mismo nombre que Maciej había elegido para su bucket.

![s3 bill](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8nzwhhbbyy55cofykkww.png)


## El problema y las lecciones aprendidas

1. **AWS cobra por solicitudes no autorizadas (errores 4xx) a S3**: Esto significa que si alguien intenta acceder a tu bucket S3 sin tener los permisos adecuados, aún así se te cobrará por esas solicitudes fallidas.

2. **Las solicitudes S3 sin región específica se redirigen a `us-east-1`**: Si no especificas la región AWS al realizar solicitudes a S3, estas se redirigen a `us-east-1` por defecto, lo que genera cargos adicionales por la redirección.

3. **Usar nombres de bucket cortos y comunes aumenta el riesgo**: Maciej encontró que al abrir brevemente su bucket para escritura pública, en menos de 30 segundos recibió más de 10GB de datos. Esto demuestra que los nombres de bucket cortos y comunes son vulnerables a fugas de datos debido a configuraciones incorrectas de terceros.

## Lecciones y recomendaciones

- **Agrega sufijos aleatorios a los nombres de tus buckets S3** para reducir la probabilidad de colisiones con herramientas mal configuradas.
- **Especifica siempre la región AWS** al realizar solicitudes a S3 para evitar cargos por redirección.
- **Monitorea de cerca tu factura de AWS** y habilita las alertas de facturación para detectar cargos inesperados.
- **Reporta problemas de seguridad** a los proveedores de herramientas y servicios afectados para que puedan abordar las configuraciones predeterminadas inseguras.

Esperamos que esta historia de Maciej Pocwierz te concientice sobre los riesgos potenciales en AWS S3 y te ayude a evitar facturas inesperadas y problemas de seguridad similares.
Best approach to find duplicates in an array
Tags: programming, career, algorithms, interview
Published: 2024-04-30 02:28:39

The question '[Find duplicate elements in an array](https://interviewspreparation.com/best-way-to-find-duplicates-in-an-array/)' is frequently posed in interviews. Stay with us to verify '[whether an array contains duplicates](https://interviewspreparation.com/best-way-to-find-duplicates-in-an-array/)'.

Welcome back, readers. In this blog post, I'll be elucidating how to identify similar items within an array. During interviews, this concept may be presented as 'Write an algorithm to detect duplicates in an array' or 'Find duplicate pairs in an array'. However, the approach remains consistent regardless of the phrasing."

for animation check video here 
{% embed https://youtu.be/Sr95yWVB4kY %}

## Program To Check An Array Contains Matching Elements

```
private static bool IsContainsDuplicate(int[] data)
{
    HashSet<int> list = new HashSet<int>();   

    for (int i = 0; i < data.Length; i++)
    {
        if (list.Contains(data[i]))
        {
            return true;
        }
        else
        {
            list.Add(data[i]);
        }
    }

    return false;
}
```

## Efficient way to find duplicates in array
In my case, during high school, I employed nested for loops to identify duplicates in an array. However, do you believe this approach is sufficient for acing an interview? I would argue not, as it lacks optimization. Therefore, stick with us to conquer the 'Efficient way to find duplicates in an array' interview question.

I'm planning to implement a HashSet to ascertain whether our array contains duplicates or not. This choice stems from the HashSet's capability to search for any element with linear time complexity and its built-in functionality to check the uniqueness of elements. For further details about HashSet, you can refer to its official site.

Check Below Video Animation How this logic working. or Do check our Beginner and Intermediate pages
Best approach to find duplicates in an array
Tags: programming, career, algorithms, interview
Published: 2024-04-30 02:28:38

The question '[Find duplicate elements in an array](https://interviewspreparation.com/best-way-to-find-duplicates-in-an-array/)' is frequently posed in interviews. Stay with us to verify '[whether an array contains duplicates](https://interviewspreparation.com/best-way-to-find-duplicates-in-an-array/)'.

Welcome back, readers. In this blog post, I'll be elucidating how to identify similar items within an array. During interviews, this concept may be presented as 'Write an algorithm to detect duplicates in an array' or 'Find duplicate pairs in an array'. However, the approach remains consistent regardless of the phrasing."

[Reverse a linked list recursively in python](https://interviewspreparation.com/reverse-a-linked-list-recursively/)

for animation check video here 
{% embed https://youtu.be/Sr95yWVB4kY %}

## Program To Check An Array Contains Matching Elements

```
private static bool IsContainsDuplicate(int[] data)
{
    HashSet<int> list = new HashSet<int>();   

    for (int i = 0; i < data.Length; i++)
    {
        if (list.Contains(data[i]))
        {
            return true;
        }
        else
        {
            list.Add(data[i]);
        }
    }

    return false;
}
```

## Efficient way to find duplicates in array
In my case, during high school, I employed nested for loops to identify duplicates in an array. However, do you believe this approach is sufficient for acing an interview? I would argue not, as it lacks optimization. Therefore, stick with us to conquer the 'Efficient way to find duplicates in an array' interview question.

I'm planning to implement a HashSet to ascertain whether our array contains duplicates or not. This choice stems from the HashSet's capability to search for any element with linear time complexity and its built-in functionality to check the uniqueness of elements. For further details about HashSet, you can refer to its official site.

[Find Solution of Two Sum Problem ](https://interviewspreparation.com/two-sum-leetcode-solution/)
STOLEN OR LOST CRYPTO RECOVERY THROUGH PRO WIZARD GIlBERT RECOVERY
Published: 2024-04-30 02:25:51

INFORMATION OF PRO WIZARD GILBERT RECOVERY:
SEND Email: (prowizardgilbertrecovery(@)engineer.com)
WEB HOMEPAGE: (https://prowizardgilbertrecovery.xyz)
Best Wishes.

I got scammed by an online cryptocurrency trading company, my first ever experience with a scam and it was a terrible one for me as I lost everything I had worked for over the years to this fake trading company, i was devastated and lost, but special thanks to this Godsend Team Pro Wizard Gilbert Recovery for saving my life. It all started on January 2nd, 2024 when a lady I had been friends with on Facebook contacted me and offered me some investment advice, from her page she looked like a certified crypto trader who also runs a mentorship program, this got me interested as I wanted to know more she had offered to guide me and put me down through the whole process so without much deliberation we moved forward, I first started the beginner's project with $800usd, it was going on well and I made some upgrade as the lady advised me. later upgraded to the “millionaires pack where I invested USD 1.5 M, and made all transfers with my Binance account without knowing that I had been defrauded. It then got to the point that I wanted to move some parts of my funds into my bank account That was when I noticed that my withdrawal wasn’t approved, i quickly called the attention of the customer care department for assistance but I was asked to pay some huge fees just so my withdrawals can be processed, I did pay the fees of $250 but my funds were still not released. This was around mid-March this year and the lady who was putting me through all this stopped replying to my texts and calls, I then realized that I had been scammed by this platform, Well i reported my case immediately to the authorities but no serious action was taken for a few weeks I had made my report, I then decided to look out for a good hacking team to help me to recover back my funds from this platform, so grateful I met Pro Wizard Gilbert Recovery through the individual reviews of fellow victims who had their funds recovered, I quickly contacted them and they responded and asked for a few details which I had them provided with before they processed the recovery of my funds, I am so happy and thankful to this professional team for recovering back my funds from the fake platform that defrauded off my investment. If you have ever been defrauded I advise you to reach out to Pro Wizard Gilbert Recovery for their assistance and services to recover back your funds.
Using dependency injection in nodejs environment
Tags: node, angular, web
Published: 2024-04-30 02:12:29

---

title: Using dependency injection in nodejs environment
published: true
tags: node,angular,web,
---

## Introduction

- Angular dependency injection standalone version
- The usage method is completely consistent with Angular's dependency injection
- No transformer required
- 0 dependencies
- Remove Decorator
> `@Injectable()`=>`static injectOptions={}`
> `@Inject() xx`=>`xx=inject()`
> `@Optional()`=>`xx=inject(token,{optional:true})`
- `JS`/`TS` Support

## Source

- Angular 17.3.6

## Usage
- `npm i static-injector`
- Create a first level dependency injector with `Injector.create`
```ts
import { Injector, inject } from 'static-injector';

class Main {
  child = inject(Child);
}
class Child {
  output() {
    return 'hello world';
  }
}
let injector = Injector.create({ providers: [Main, Child] });
const instance = injector.get(Main);
console.log(instance.child.output());
```

## Different from `injection-js`

- `injection-js` belongs to dynamic dependency injection and is a version used before Angular5. Currently no longer updated
- The two are basically interchangeable (the details need to be adjusted)

- Support the use of `inject` during construction

## No Decorator

- The original use of `@Injectable()` to pass parameters has been changed to `static injectOptions={}`. If there are no parameters, there is no need to set them
- Originally, `@Optional`, `@SkipSelf`, `@Self`, please use the second pass parameter of `inject` instead

## Test

- Partially conducted unit testing to ensure that most functions are functioning properly
- Because most of the code itself is extracted from Angular, stability is definitely guaranteed

## Sync

- Currently, the synchronization logic has been refactored and modified using `@code-recycle/cli` to ensure consistency with the official version of `angular`

## Examples
- [https://github.com/wszgrcy/static-injector/tree/main/test/import](https://github.com/wszgrcy/static-injector/tree/main/test/import)

## Contact me
- If you have any technical issues, please  contact me for assistance `wszgrcy@gmail.com`