teleren/devto huggingface dataset:
Networking fundamentals - Part 1
Tags: networking, cloud, devops, aws
Published: 2023-07-18 17:27:06


**Networking models based on functions**

- Client Server system


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

The client–server model is a distributed application structure that partitions tasks or workloads between the providers of a resource or service, called servers, and service requesters, called clients. 

- Peer to peer system

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

Peer-to-peer (P2P) is a decentralized communications model in which each party has the same capabilities and either party can initiate a communication session.

**Types of Networks based on proximity**

- Local Area Network

- Personal Area network

- Metropolitan Area network

- Wide Area Network

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

**Network Topology**

- Bus topology

Bus topology, also known as line topology, is a type of network topology in which all devices in the network are connected by one central RJ-45 network cable or coaxial cable. 

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

- Ring topology

Ring topology is a type of network configuration in which each device on the network is connected to two other devices, forming a “ring.”

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

- Star topology

Star topology is a type of network topology in which every device in the network is individually connected to a central node, known as the switch or hub.

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

- Mesh topology

Mesh topology is a type of network topology in which all devices in the network are interconnected. In a mesh topology, data can be transmitted by routing (sent the shortest distance) and flooding (sent to all devices).

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

- Hybrid topology

hybrid topology is the combination of two or more networks. The network type could be Star, Ring, Bus, or Mesh. However, in most cases, only the Star and Ring topologies are used to create a Hybrid network.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dv9o0gfk5vx13u29u3q8.png)
Ora2pg
Tags: postgres, database
Published: 2023-07-18 17:22:57

## **Introduction:**

The migration of Oracle databases to PostgreSQL can be a complex process, but Ora2Pg makes it easier. This command-line tool automates the migration by extracting the schema, data, and PL/SQL code from an Oracle database. It then converts the extracted information to PostgreSQL syntax and loads it into a PostgreSQL database.


Ora2Pg supports various versions of Oracle databases and is highly configurable to suit different migration requirements. It can handle complex database objects like triggers, views, and stored procedures, and has support for advanced features like partitioning and materialized views. It provides detailed migration reports for analysis and supports incremental migration, allowing you to migrate only specific changes made to an Oracle database since the last migration.


## **Pros**
Ora2Pg is easy to use and can be run in batch mode or interactively. It provides a comprehensive command-line interface that allows you to control various aspects of the migration process. Additionally, Ora2Pg has a detailed documentation, including examples and use cases, which makes it easy for users to get started with the tool.


Ora2Pg is highly customizable, allowing users to configure various migration settings based on their specific needs. For instance, users can specify the target PostgreSQL version, configure data type mapping, define migration rules, and specify the schema to migrate.


## **Cons**
it does not support migration of all Oracle features, such as user-defined types, object types, and some PL/SQL functions. Additionally, while Ora2Pg can handle large volumes of data, it may not be the best option for real-time migration of very large databases.
An In-depth Look at Arrays and Sorting Algorithms
Tags: array, algorithms
Published: 2023-07-18 17:04:08

Arrays are fundamental data structures in computer programming that allow us to store and manipulate collections of elements. One common operation performed on arrays is sorting, which arranges the elements in a specific order. In this blog, we will explore the concept of arrays, understand their properties, and dive into different sorting algorithms used to order array elements efficiently.

**Bubble Sort:**

Bubble sort is a simple and straightforward sorting algorithm.
It iterates through the array repeatedly, comparing adjacent elements and swapping them if they are in the wrong order.
The process continues until the entire array is sorted.
Bubble sort has a time complexity of O(n^2), making it inefficient for large arrays.
**Selection Sort:**

Selection sort divides the array into two portions: sorted and unsorted.
It repeatedly selects the smallest element from the unsorted portion and moves it to the sorted portion.
The algorithm continues until the entire array is sorted.
Selection sort also has a time complexity of O(n^2), making it inefficient for large arrays.
**Insertion Sort:**

Insertion sort builds the final sorted array one element at a time.
It takes each element from the unsorted portion and inserts it into its correct position in the sorted portion.
The algorithm iterates through the array, shifting elements to make room for the inserted element.
Insertion sort has an average time complexity of O(n^2), but it performs well for small arrays or partially sorted arrays.
**Merge Sort:**

Merge sort is a divide-and-conquer algorithm that divides the array into smaller subarrays until each subarray contains only one element.
It then merges these subarrays to form a sorted array.
Merge sort has a time complexity of O(n log n), making it more efficient than the previous algorithms for large arrays.
However, it requires additional memory for merging the subarrays.
**Quick Sort:**

Quick sort is another divide-and-conquer algorithm that selects a pivot element and partitions the array into two parts.
Elements smaller than the pivot are placed to its left, and elements greater than the pivot are placed to its right.
The algorithm then recursively sorts the two subarrays.
Quick sort has an average time complexity of O(n log n), but its worst-case time complexity is O(n^2) if the pivot selection is not optimal.
Quick sort is widely used due to its efficiency and can be improved using various optimizations.


These different algorithms play a pivotal role in data structuring, allowing arrays to be sorted based on desired requirements.
Introduction to Composable Commerce
Tags: webdev, composable, ecommerce, api
Published: 2023-07-18 17:02:33

## Defining Composable Commerce

[Composable Commerce](https://composablearchitecture.dev) is a new approach to building out unique digital commerce experiences. Historically, businesses were forced into two distinct approaches: buying generic software that can be themed and lightly customized, or coding an entire solution from scratch. Composable Commerce provides a third approach. By breaking traditional software functionality into smaller pieces, each offered separately, they can then be used as building blocks to create custom software without extensive coding.

## Benefits vs challenges of composable commerce

This approach allows every business the benefit of a custom solution, while matching the cost and effort associated with buying generic software. For businesses with unique requirements, who want to control the entire customer experience, or who hope to leverage cutting-edge techniques, composable commerce is an easier and cheaper solution than forcing these requirements into an existing software package. This enables businesses to quickly adapt to changing requirements, customer preferences, and marketing conditions, and to quickly take advantage of technological advancements.

Due to the architecture principles required to create these building blocks, the individual services benefit from better scalability, lower maintenance, and faster response times. Since each individual piece can be swapped out as requirements shift, there is no need for massive re-platforming projects, instead the system grows and evolves over time.

The major challenges of composable commerce are the initial investment in planning and designing the solution. When buying all-in-one software, the vendor defines what functionality will be delivered. With composable commerce more time is spent on defining the overall requirements to ensure the best pieces are identified and integrated. Additionally, with this being a new approach businesses and architects may face a steeper learning curve as they adapt. Thankfully, there are now experts with years of experience ready to assist in navigating the many possible components and services.

## Composable commerce vs composable architecture

[Composable commerce](https://composablearchitecture.dev) refers to the use and application of composable architecture for digital commerce solutions. Composable architecture is broader, defining the use of these concepts across any industry or project. Composable commerce is a subset of composable architecture, but highly focused on meeting the unique needs of selling online.

---

https://www.youtube.com/@thecomposableconnection
https://www.thecomposableconnection.com/
LLMs for Schema Augmentation
Tags: chatgpt, json
Published: 2023-07-18 16:55:43

I have recently been experimenting with the use of large language models (LLMs) to augment JSON Schemas with useful features. While ChatGPT gets most of the press, there are many other LLMs that are specifically designed to work with code. The idea is that these LLMs can be used to augment incomplete schemas with additional useful information.

Consider an example schema such as the one below. This is a basic schema which might be created from an automated schema mining process. For such a small schema, this is probably sufficient information to tell you useful things about the dataset.

```json
{
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string"}
  }
}
```

However, as schemas grow in size and complexity, additional metadata can be useful. For example, JSON Schemas can contain a `description` attribute which provides a natural language description of each property. To generate a value for such a property, we can prompt the LLM with a prefix of the schema such as the following.

```json
{
  "type": "object",
  "properties": {
    "name": {"type": "string"},
    "address": {"type": "string", "description": "
```

From here, we just need to continue generating tokens until we get to a closing quote. This approach was borrowed from [Jsonformer](https://github.com/1rgs/jsonformer) which uses a similar approach to induce LLMs to generate structured output. Continuing to do so for each property using [Replit's code LLM](https://huggingface.co/replit/replit-code-v1-3b) gives the following output:

```json
{
  "type": "object",
  "properties": {
    "name": {
      "type": "string",
      "description": "The name of the item"
    },
    "address": {
      "type": "string",
      "description": "The address of the person"
    }
  }
}
```

While it's not perfect, and not obviously useful for such a small schema, I think the results are promising. I've also tried several other schema formats such as [Zod](https://github.com/colinhacks/zod), [Typescript object types](https://www.typescriptlang.org/docs/handbook/2/objects.html), and [Pydantic](https://docs.pydantic.dev/latest/). A lot more experimentation is required with these different formats and various LLMs to see which works best. So far, I'm pretty pleased with results. The code for this post [is available on GitHub](https://github.com/michaelmior/annotate-schema).
Today I Learned 06-18.
Published: 2023-07-18 16:43:19

I am learning new and exciting information regarding CSS. I always thought that I had pretty good knowledge of CSS design principles but today is a great example that CSS has lots to learn and anyone can discover something new about the CSS structure. While going through Codecademy introduction to CSS I was able to learn about the attribute selector "The attribute selector can be used to target HTML elements that already contain attributes" so this means that element tags that are the same can be targeted uniquely by their attribute value. The website had a good example and I was able to understand more. 

img[src*='winter'] {
  height: 50px;
}
 
img[src*='summer'] {
  height: 100px;
}
In the above CSS code, the attribute selector is used to target each image individually by looking specifically for the key value winter and summer within the image tags.

I can always learn something new by remaining curious and open.
Writing a NES game day 6, a new controller
Tags: nes, nintendo, blogging, gamedev
Published: 2023-07-18 16:28:01

Hello here, as I was able to move the Mario character that I have on screen to the left and to the right, I wanted to know if it works the same way with a NES controller. You know, making the experience as close to the real thing as possible for future testing.

I wanted a NES USB controller, but I live in Argentina and getting some things is kind of complicated so the closest thing that I could buy was a SNESlike controller but It will do (there is no option).



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

It is a cheap thing that I would not use for hardcore gaming but again, it will do what we need here.

At first I thought that it was not working but FCEUX needs you to configure all the buttons in order to work.

After that, everyting was smooth and working so I will be testing this with the new controller (and why not use it for Final Fantasy?)
65 berufliches Vorwärtskommen: In welchem Lager und warum?
Tags: deutsch, career, motivation, discuss
Published: 2023-07-18 16:15:00

Moin Moin,

wie so oft gibt es auch bei der Frage bezüglich Maschinen und menschlicher Arbeit zwei Lager, wie [im letzten Beitrag→](https://dev.to/amustafa16421/64-berufliches-vorwartskommen-zwei-lager-19nk) angesprochen. Die einen wünschen die menschliche Arbeit durch Maschinen zu ersetzen, die anderen diese durch Maschinen zu ergänzen.

Eine Frage, die mich interessiert ist, warum man sich selbst in dem einen oder dem anderen Lager sieht.
Eine ausführliche Antwort meinerseits würde mich schnell in Vermutungen über die Grenzen der Wahrnehmung und Denkleistung des Menschen insgesamt führen, sowie in weitere Bereiche – ich lasse dies hier einmal aus.

Ich denke jedoch, dass eine Antwort auf die Frage für die eigene Karriere wichtig ist bzw. wird. Jedoch spielt es auch eine Rolle, welches Lager gerade die allgemeine Denkrichtung vorgibt.

1) Hast du eine ausführliche Antwort darauf in welchem Lager du dich befindest? ( Oder sind es mehrere, oder keines? )  
2) Meinst du, dass eine Antwort auf 1) wichtig für die eigene Karriere ist oder sein wird?

Lass uns mittels Kommentaren austauschen.

Beste Grüße,
Mustafa

Oder auch mittels E-Mail: mustafa.kevin.dwenger@posteo.de
Betreff: Austausch
Learn-while-play
Tags: beginners, programming, python, productivity
Published: 2023-07-18 15:56:30

Sorry for disappearing from a long time!!!
 Now, I come-back with my result of learning all **collecting types** in Python, actually simple code for amateur. So I have created this game:[press this](https://replit.com/@Nguyen-Duc-TaiD/guessing-munber-game?v=1)
 Try it and give me some advice, also the improvement...
Mocker: Easy Live-to-Mock Switching in VS Code
Tags: javascript, kubernetes, vscode, testing
Published: 2023-07-18 15:53:25

Mia from [Skyramp](http://www.skyramp.dev) once again!

Today we’re showing how easy [Mocker](https://marketplace.visualstudio.com/items?itemName=skyramp.mocker-vscode) makes it to switch from a live service running in your cluster to a mock. It only takes a few seconds using this [VS Code extension](https://marketplace.visualstudio.com/items?itemName=skyramp.mocker-vscode) that simplifies service mocking in Kubernetes clusters.

Here’s a super-short video showing how easy it is to switch from live to mock in seconds. [Watch it here](https://www.skyramp.dev/blog/mocker-easy-live-to-mock-switching-in-vs-code/).
Kafka containers with Docker Compose
Tags: dockercompose, kafka
Published: 2023-07-18 15:48:06

---
title: Kafka containers with Docker Compose
published: true
tags: ['dockercompose', 'kafka']
canonical_url: https://sevic.dev/notes/kafka-docker-compose/
---

Docker Compose facilitates spinning up containers for Kafka broker and Zookeeper without installing them locally. Zookeeper is used to track cluster state, membership, and leadership.

### Prerequisites

- Docker Compose installed

### Configuration

The following configuration spins up Kafka and Zookeeper containers with the Kafka UI tool.

The Kafka broker address is `http://localhost:29092`, and Kafka UI is available at the `http://localhost:8085` address.

```yml
# docker-compose.yml
version: '3.8'

services:
  kafka:
    image: confluentinc/cp-kafka:6.0.14
    depends_on:
      - zookeeper
    ports:
      - '29092:29092'
    environment:
      KAFKA_BROKER_ID: 1
      KAFKA_ZOOKEEPER_CONNECT: 'zookeeper:2181'
      KAFKA_ADVERTISED_LISTENERS: LISTENER_DOCKER_INTERNAL://kafka:9092,LISTENER_DOCKER_EXTERNAL://${DOCKER_HOST_IP:-127.0.0.1}:29092
      KAFKA_LISTENER_SECURITY_PROTOCOL_MAP: LISTENER_DOCKER_INTERNAL:PLAINTEXT,LISTENER_DOCKER_EXTERNAL:PLAINTEXT
      KAFKA_INTER_BROKER_LISTENER_NAME: LISTENER_DOCKER_INTERNAL
      KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR: 1

  kafka-ui:
    image: provectuslabs/kafka-ui:latest
    ports:
      - 8085:8080
    environment:
      KAFKA_CLUSTERS_0_NAME: local
      KAFKA_CLUSTERS_0_BOOTSTRAPSERVERS: kafka:9092
      DYNAMIC_CONFIG_ENABLED: 'true'

  zookeeper:
    image: confluentinc/cp-zookeeper:6.0.14
    ports:
      - '22181:2181'
    environment:
      ZOOKEEPER_CLIENT_PORT: 2181
      ZOOKEEPER_TICK_TIME: 2000
```

Run the following command to spin up the containers.

```bash
docker-compose up
```

### Boilerplate

Here is the [link](https://sevic.dev/nestjs-starter?ref=kafka) to the boilerplate I use for the development.
Day 7: Once
Tags: javascript, 100daysofcode, day7
Published: 2023-07-18 15:39:43

## Question:
Write a function called `once` that takes a function as an argument and returns a new function. The new function should only call the original function once and return its result for subsequent calls.

```javascript

function once(fn) {
 // Todo add your code
}

function expensiveOperation() {
  // Time-consuming calculation
  console.log("Executing expensive operation...");
  return "Result";
}

const executeOnce = once(expensiveOperation);
console.log(executeOnce()); // Result
console.log(executeOnce()); // Result

```

🤫 Check the comment below to see answer.
Doticons - A collection of minimal dot icons
Tags: webdev, github, ui, opensource
Published: 2023-07-18 15:37:18


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

Doticons is a comprehensive and carefully curated collection of SVG dot icons. They are based on a 16x16 and 32x32 dot matrix, which gives them a pixelated and retro look. They are also scalable and customizable, so you can adjust their size and color.

## 🎨 What's Inside?
Doticons are free to use and modify for any personal or commercial project. You can download them from my GitHub repository: [https://github.com/eduardconstantin/doticons](https://github.com/eduardconstantin/doticons)

You can open a request for adding new icons, improving existing ones, or suggesting new categories or join the discussion tab if you have any feedback or questions.

I am also looking for contributors to help me improve this project, so open a PR or an issue, I appreciate any feedback, suggestion or improvement.
Can you use React Hooks in loops and conditions that guarantee the same order for every render?
Tags: react
Published: 2023-07-18 15:08:04

React [docs say][1]:
> Hooks—functions starting with use—can only be called at the top level of your components or your own Hooks. You can’t call Hooks inside conditions, loops, or other nested functions.

and [it explains][2] that since hooks have no names that can be used for look-up, their call order is used:
> Hooks rely on a stable call order on every render of the same component. This works well in practice because if you follow the rule above (“only call Hooks at the top level”), Hooks will always be called in the same order.

**Given that explanation, can you break that rule if you can guarantee the same call order for hooks?**

for example here the loop and conditions are applied on a hard-coded object and no input change or side effect will change that, hence the order in which hooks are called remains unchanged (this is just an example to showcase a guaranteed order with loops and conditions, please don't provide alternative solutions for this specific example):
```jsx
const props = [
  { name: 'p1', initial: 1 },
  { name: 'p2', action: () => {// modify the DOM},
  { name: 'p3', initial: 'str' }
];

const RougeReactComponent = () => {
  const states = [];
  for (const prop of props) {
    if (prop.action) {
      useEffect(prop.action, []);
    }
    else if (prop.initial) {
      states.push(useState(prop.initial));
    }
  }
  
  return states.map((state, key) => <p key={key}>{state[0]}</p>);
};
```


  [1]: https://react.dev/learn/state-a-components-memory#meet-your-first-hook
  [2]: https://react.dev/learn/state-a-components-memory#how-does-react-know-which-state-to-return
Open Question Coding Interviews
Tags: codinginterview, interview
Published: 2023-07-18 15:03:49

I deeply believe that Developers should write code on interviews.

The most critical part of the coding interview is the thinking and communication process.

So how does a person interact with you, and what kind of questions person asks?

Designing small and, most importantly, open interview challenges suitable for multiple levels is hard.

One of the interesting forms of coding interviews could be a code review.

I like this code review task from my ex-colleague.

```
/***
* Select Last 10 Orders  
*/
public class RecordController {
  RecordRepository r;
  public RecordController() {
  }
  public RecordController(RecordRepository repository) {
    r = repository;;
  }
  
  public ArrayList<Record> get_forPage(String query) {
    List<Record> l = r.findByQuery(query.toLowerCase());
    ArrayList<Record> rrr = new ArrayList<>();
    for (int i = 1; i < 10; i++) {
      rrr.add(l.get(i));
    }
    Collections.sort(rrr, new RecordSorterByDateAsc());
    return rrr;
  }
  
  public class RecordSorterByDateAsc implements Comparator<Record> {
  
    public int compare(Record a, Record b) {
      return b.getOrderDate().compareTo(a.getReturnDate());
    }
  }
}
```
It is broken into many dimensions, from architecture and layer abstraction to the most important part.

The first question I expect to get — is what it should do.

I got so many quite interesting results out of this task

some candidates ignored the original request for code review and tried to rewrite a code,
some folks did not try to ask questions about logic, etc
The best part of this task — it is open so many cool topics to talk about