teleren/devto huggingface dataset:
ZooKeeper Chronicles: Navigating EOFException and the Enigma of 0-Length Files
Tags: zookeeper, kafka, cloud, distributedsystems
Published: 2023-12-18 18:55:58

In the realm of technology, ZooKeeper plays a crucial role in maintaining order within distributed systems. However, much like any compelling narrative, I recently encountered a stumbling block marked by an unexpected challenge – an EOFException paired with an intriguing 0-length file.

#### _The Error:_
```
ERROR [main:Util@214] - Last transaction was partial.
ERROR [main:ZooKeeperServerMain@66] - Unexpected exception, exiting abnormally
java.io.EOFException
    at java.io.DataInputStream.readInt(DataInputStream.java:392)
```

An EOFException occurred, causing our ZooKeeper server to crash.

---

#### _The Mysterious 0 Length File:_

Navigating through the ZooKeeper folder, I saw something strange:

```
-rw-rw-r-- 1 zookeeper zookeeper 1342177280 Sep 23 23:17 log.be45c2
-rw-rw-r-- 1 zookeeper zookeeper          0 Oct  1 14:31 log.be85e9
```

---

#### _Digging Deeper:_

The zero file hinted at trouble with our transaction logs. Looking into the logs, we found the last transaction was a bit messed up, triggering the EOFException. But why did it result in a zero file?

---

#### _Real Issue: Running Out of Space_

There was a 0 Length File because the underlying disk utilization was full and no space was left on the device to write the logs. 

```
Filesystem      Size  Used Avail Use% Mounted on
/dev/sde         25G   25G     0 100% /var/lib/zookeeper
```
As per the Zookeeper official documentation [here](https://zookeeper.apache.org/doc/r3.3.2/zookeeperAdmin.html#Ongoing+Data+Directory+Cleanup)

> A ZooKeeper server will not remove old snapshots and log files, this is the responsibility of the operator. Every serving environment is different and therefore the requirements of managing these files may differ from install to install (backup for example).

> The PurgeTxnLog utility implements a simple retention policy that administrators can use. The API docs contains details on calling conventions (arguments, etc...).

---

#### _Using the PurgeTxnLog utility_

```
zookeeper@zk-0:/bin$ zkCleanup.sh
Usage:
PurgeTxnLog dataLogDir [snapDir] -n count
    dataLogDir -- path to the txn log directory
    snapDir -- path to the snapshot directory
    count -- the number of old snaps/logs you want to keep, value should be greater than or equal to 3
```

Keep the latest 5 logs and snapshots
`` ./zkCleanup.sh -n 5 ``

---

## _Conclusion:_

In the dynamic landscape of distributed systems, unexpected errors often hint at underlying complexities. Our journey through the EOFException and zero file quandary emphasizes the importance of vigilant monitoring of logs and disk space. As tech custodians, we must be prepared to decode mysteries, address core issues, and ensure the seamless operation of systems like ZooKeeper.

ZooKeeper, with its unique quirks and challenges, continues to be an exciting playground for tech enthusiasts eager to navigate the intricacies of system synchronization.
Error: Cannot select module with conflict on capability 'com.google.guava:listenablefuture:1.0' also provided by...
Tags: java, springboot, gradle
Published: 2023-12-18 18:44:24

Error: `Cannot select module with conflict on capability 'com.google.guava:listenablefuture:1.0' also provided by [com.google.guava:listenablefuture:9999.0-empty-to-avoid-conflict-with-guava(compile)]`


Hey, are you stumbling in that error? Then I think I could help you, try to add this line in your `build.gradle`: 

`implementation 'com.google.guava:guava:27.0.1-android'`

Everything should work now!

Source: https://stackoverflow.com/a/56639924
break and continue statements in C programming.
Tags: break, beginners, cprogramming, tutorial
Published: 2023-12-18 18:42:55

## break
The break statement in loop is used to terminate from the loop and no further code after for loop will be executed.

**break statement in for loop:**
```
int main() {
    for(int i=1; i<=5; i++){
        if(i==3){
            break;
        }
        printf("%d\n", i);
    }
    return 0;
}
```

**break statement in while loop**
```
int main() {
    
    while(1){
        int number;
        printf("Enter the number: ");
        scanf("%d", &number);
        
        if(number < 0){
            break;
        }
        printf("%d\n", number);
    }

    return 0;
}
```

## continue
The continue statement skips the current iteration of the loop and starts the loop with next iteration.
Example:
```
int main() {
    for(int i=1; i<=5; i++){
        
        if(i==3){
            continue;
        }
        
        printf("%d\n", i);
    }
    return 0;
}
```

Below is the code using both break and continue statement:
```
#include <stdio.h>

int main() {
    
    while(1){
        int number;
        
        printf("Enter a number: ");
        scanf("%d", &number);
        
        if(number <= 0){
            break;
        }
        
        if((number % 2) != 0){
            continue;
        }
        
        printf("%d\n", number);
    }
    return 0;
}
```
Idiomatic React and React Forget
Published: 2023-12-18 18:41:39

---
title: Idiomatic React and React Forget
published: true
description: Does the way React code is written have a real impact on performance optimization tools like React Forget?
tags:
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i9dk3gy7s6m3o0bdcvt4.png
# Use a ratio of 100:42 for best results.
# published_at: 2023-12-18 16:43 +0000
---

When I first delved into writing user interfaces with React, I was guided by the "[Thinking in React](https://react.dev/learn/thinking-in-react)" article from the React documentation. This piece emphasizes the library's design principle: decomposing UI widgets (collections of components) into small, atomic components. The strategy involves assembling these components into a logical hierarchy and strategically managing the state within this structure.

Adhering to this approach, the React projects I've contributed to typically feature numerous small components. These components are easily understandable, testable, and debuggable. Adopting a "one component per file" rule often results in projects with an extensive number of files. However, I've noticed that teams, particularly those with less experienced React developers, sometimes deviate from this practice by constructing entire widgets within a single, large component.

In my view, this strays from the ideal React development methodology and disrupts the proverbial feng shui of the framework. Some might argue that the simplicity of housing all code for a widget in one place justifies this approach, even if it sacrifices code maintainability, or that following the guidance from in the documentation is rigid adherence to guidelines rather than considering practical development strategies.

I haven't experimented with optimizing these large, perhaps bloated, components. Yet, I speculate that such efforts would only add to the bloat, making the components more cumbersome. This brings me to the tool [React Forget](https://react.dev/blog/2022/06/15/react-labs-what-we-have-been-working-on-june-2022#react-compiler), which aims to eliminate the need for optimization code (like `useMemo`, `useCallback`, etc.). The rationale is that even well-structured code which adheres to the "[Thinking in React](https://react.dev/learn/thinking-in-react)" philosophy, can become less manageable with extensive optimization.

React Forget, as I understand it, optimizes (at least in one way) by analyzing a component's `props` and memoizing the component accordingly. So, components don't re-render if their `props` remain unchanged. Given that 'bloated' components often have numerous `props`, I wonder if UIs consisting of smaller, more focused components would offer more opportunities for optimization. Could React Forget be more effective in one paradigm over the other? This is an aspect worth exploring, especially in the context of maintaining efficient and clean code in React development.
Delegate in C#
Tags: csharp, delegates
Published: 2023-12-18 18:40:22


![Delegate Example and Usages](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2yewmo27mq9v6q0ctbur.jpg)

**What is a Delegate?**

- A delegate in C# is a type that represents references to methods with a specific parameter list and return type.

- When you create an instance of a delegate, you can associate it with any method that has a compatible signature (matching parameters and return type).

- Delegates allow you to pass methods as arguments to other methods.

**Code Example**

```
using System;
using System.Collections.Generic;

public class Program
{
    public class Person
    {
        public string Name { get; set; }
        public int Age { get; set; }
    }

    // Define a delegate to represent filtering methods
    public delegate bool FilterDelegate(Person p);

    public static void Main()
    {
        // Create some Person objects
        Person p1 = new Person() { Name = "Rohit", Age = 26 };
        Person p2 = new Person() { Name = "Lal", Age = 40 };
        Person p3 = new Person() { Name = "Prashant", Age = 65 };

        // Populate a list with Person objects
        List<Person> people = new List<Person>() { p1, p2, p3 };

        // Display people based on different filters
        DisplayPeople("Children", people, IsChild);
        DisplayPeople("Adults", people, IsAdult);
        DisplayPeople("Seniors", people, IsSenior);

        Console.Read();
    }

    // Display people based on a specified filter
    static void DisplayPeople(string title, List<Person> people, FilterDelegate filter)
    {
        Console.WriteLine(title + ":");
        foreach (Person p in people)
        {
            if (filter(p))
            {
                Console.WriteLine("{0}, {1} years old", p.Name, p.Age);
            }
        }
        Console.WriteLine();
    }

    // Filter methods
    static bool IsChild(Person p) => p.Age < 18;
    static bool IsAdult(Person p) => p.Age >= 18 && p.Age < 65;
    static bool IsSenior(Person p) => p.Age >= 65;
}

```

**Key Concepts Explained**

Delegate Declaration:

- We define a FilterDelegate to represent filtering methods that take a Person object and return a boolean value.
- This delegate allows us to dynamically choose different filters for our list of people.

Method Definitions:

- We have three filter methods: IsChild, IsAdult, and IsSenior.
- These methods determine whether a person falls into the child, adult, or senior category based on their age.

Displaying People:

- The DisplayPeople method takes a title, a list of people, and a filter delegate.
- It iterates through the list and displays relevant information based on the specified filter.

Output:

```
Children:
Rohit, 26 years old

Adults:
Rohit, 26 years old
Lal, 40 years old

Seniors:
Prashant, 65 years old
```
serve a plotfile with deno
Tags: deno, ssr, plot
Published: 2023-12-18 18:38:44

Hi,

I am generating a matplotlib file (SVG or PNG) with a little typescript code. 
The goal is to serve a simple onepage website with deno and  display this file on that simple website.

There should be a button at that served page. When the button is clicked my deployed ts program generates a new plot and saves it at webspace.
A file server gives it to the dynamically served website, where the plot is displayed.

I have tried with pogos simple-server:

[](https://github.com/sholladay/pogo/tree/master/example/simple-server)


import { pogo } from './dependencies.ts';  // pogo 
const server = pogo.server({ port : 3010 });
server.router.get('/', () => {
    return 'Hello world!';
  }
);
export default server;

Now, where is written 'Hello World!'  the served plotfile should be displayed at that simple website.

I am really trying out these things and I am not familiar with dynamic websites.

Thanks for support :)
What do we look in a Software Engineer
Published: 2023-12-18 18:32:25

In my experience as a software engineer, I've found that excelling in problem-solving demands skills beyond coding. Effective communication, initiative, and ownership are essential. In this article I share on what I seek when evaluating potential software engineers for our team, and the practical skills I think are needed for success. So what are these skills, and why I think they are so important for success?

Communication is fundamental for a good software engineer. Our work isn't just about technical skills; it's also about explaining our ideas and solutions clearly. If you can't explain your solution well, it might mean you don't fully understand what you're doing, or proposing.

In our hiring process, we keep our code challenges as simple and open-ended as possible. This allows the candidates to show their problem solving skills, and also is an opportunity for them to explore something new, whether it's a new technology or a concept they may be unfamiliar with.

Ownership also shows how well a candidate documents their work, and how much they care for it. Similarly, writing articles and sharing them publicly is a great way to demonstrate ownership. It can offer insights into their processes, the obstacles they tackled, and the lessons they learned. Being willing to document and share not only benefits the community but also shows a sense of pride in the work.

In conclusion, I think that being a good software engineer, goes beyond technical skills. Clear communication, initiative, and ownership are just as important. Communicating your ideas, taking the initiative of proposing innovative solutions and having ownership of your work, is what truly makes someone excel.

---

If you want to work in a startup in its early stages, This  is your chance. [Apply today!](https://woovi.com/jobs/)

---

[Woovi](https://woovi.com/) is a Startup that enables shoppers to pay as they please. To make this possible, Woovi provides instant payment solutions for merchants to accept orders.

If you want to work with us, we are [hiring](https://woovi.com/jobs/)!

---

Photo by <a href="https://unsplash.com/@chrislawton?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Chris Lawton</a> on <a href="https://unsplash.com/photos/assorted-color-lear-hanging-decor-5IHz5WhosQE?utm_content=creditCopyText&utm_medium=referral&utm_source=unsplash">Unsplash</a>
Isolation Levels - part XII: To go further
Tags: sql, database
Published: 2023-12-18 18:32:13

SQL isolation levels are typically characterized by their effects, such as anomalies or phenomena, or by their implementation, such as lock duration. However, this approach doesn't provide much guidance to developers on when to use each level, and that's what I tried to address in this series.

ANSI SQL does not describe this topic accurately. 
Here's a more detailed explanation of the issue:
[A Critique of ANSI SQL Isolation Levels](https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr-95-51.pdf)

---

Once correctly described, those anomalies can be tested, and Martin Kleppmann has created a testing suite for it: [https://github.com/ept/hermitage](https://github.com/ept/hermitage). 

---

The complete description of the isolation level is more complex than what has been described here. 
Here is a comprehensive description: 
[Consistency Models - Kun Xi](https://www.kunxi.org/notes/Distributed_System/Consistency_Models/)

---

You may wonder how Oracle can enforce referential integrity without row share locks and serializable isolation level. The magic relies on using the index on the foreign key as a range lock. 
I had put many details in this old presentation: 
[Indexing Foreign Keys in Oracle]
(https://prezi.com/uzdd5ttg4cu0/indexing-foreign-keys-in-oracle/)

---

YugabyteDB has one of the most extensive implementations available, with all levels like PostgreSQL, but additionally solves the Read Committed inconsistency with statement restarts like Oracle. 
Here is the documentation: 
[Isolation levels | YugabyteDB Docs](https://docs.yugabyte.com/preview/explore/transactions/isolation-levels/)

---

Every database behaves differently even when using an isolation level that has the same name. For example you may be surprised by these simple examples by Daniel Vérité: [Isolation Repeatable Read in PostgreSQL versus MySQL](https://postgresql.verite.pro/blog/2020/02/14/isolation-repeatable-read-postgresql-mysql.html). 
You can migrate an application without changes only with truly compatible databases, like between PostgreSQL and YugabyteDB. Being only "wire-compatible" may work but cause wrong results and data corruption. 

---

In this final post of the series, I want to make it clear that my aim when comparing different database implementations is to understand them better. Please note that I am not trying to determine which database is better or worse. All of the databases mentioned in this series are utilized for running critical OLTP applications. For instance, some people like to make jokes about Oracle, but the lack of true Serializable doesn't affect the consistency of existing applications in any way. To avoid conflicts, applications written for Oracle use explicit locking such as SELECT FOR UPDATE, LOCK TABLE, and DBMS_LOCK. Remember that explicit locking was ignored by the original description of transaction isolation.
Qarbon IT
Published: 2023-12-18 18:27:09

We handle software development from A to Z - starting with product workshops, through business consultations, to modern UX/UI design, development, and evolving the finished product. Besides, we support your project and software development teams, offering the experts you need.
[AI Development](https://www.qarbon.it)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lazlbghtr9jgem2p0eje.jpg)
Kotlin Multiplatform SQLDelight
Published: 2023-12-18 18:21:58

Hello, I am currently trying to use SQLDelight with kotlin Multiplatform. But unfortunately I can't find any detailed instructions and therefore I can't get any further.

Does anyone have a current example project for Kotlin Multiplatform with SQLDelight for Android and Desktop?


As an alternative I discovered this project on Github and would like to add JVM for the desktop view.

Here the GitHub Project: https://github.com/KSdesu06/ItemProject

Can anybody add the Desktop jvm platform to this project ?
#100DaysOfCode - Day 01/02
Tags: 100daysofcode, css, tailwindcss, html
Published: 2023-12-18 18:19:49

Over the past two days, I’ve created 2 mini projects with tailwindCSS, and implemented Tailwind and Font Awesome directly into the HTML projects, without using any CDNs.

Here is a brief breakdown of the projects:

**Project 1**: I created a home personal home page specifically for developers. where a developer can share their social links alongside a brief introduction to themselves.
[Live Preview](https://html-tailwind-css.netlify.app/01.personal-profile/)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gpy3le8oktg8gfknuyrs.png)




**Project 02**: this one is from front-end mentor challenges. it was a QR code card component.
[Live Preview](https://html-tailwind-css.netlify.app/02.qr-code-component/)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mo3ijczxhbx5gfww650c.png)

Feel free to connect with me through my social links below. Let's code, learn, and grow together!"
[@nomanux](https://twitter.com/Nomanux)
Você se preocupa com o Referrer Policy dos seus links HTML <a>?
Published: 2023-12-18 18:08:54


O atributo _referrerpolicy_ é utilizado no elemento `<a>` do HTML5 para controlar como as informações de referenciamento (_referrers_) são enviadas quando o usuário clica no link e navega para uma nova página. Esses valores indicam como o cabeçalho _HTTP Referer_ deve ser gerado e enviado para a página de destino. 

Resumidamente, o cabeçalho _Referer_ é um campo no cabeçalho HTTP de uma solicitação web que indica a origem da requisição. Ele informa ao servidor de destino de onde veio a solicitação. O cabeçalho _Referer_ contém a URL da página da qual o usuário navegou ou foi direcionado para a página atual.

No entanto, esse cabeçalho também pode apresentar preocupações com a privacidade. Se a URL da página de referência contiver **informações sensíveis, como parâmetros de consulta com dados pessoais, essas informações serão enviadas junto com a solicitação**. Por esse motivo, alguns sites e desenvolvedores optam por manipular o cabeçalho Referer usando o atributo referrerpolicy no HTML ou configurando diretivas em nível de servidor para controlar como essas informações são transmitidas ou se são transmitidas.

Vamos explicar cada um dos valores:

**no-referrer**

Nenhum cabeçalho _Referer_ é enviado. O referenciador não é incluído na requisição HTTP.

**no-referrer-when-downgrade**

O cabeçalho _Referer_ é enviado apenas para requisições seguras (HTTPS), quando a requisição é feita a partir de uma página segura. Em requisições não seguras (HTTP), nenhum cabeçalho _Referer_ é enviado.

**origin**

Apenas o valor de origem (origin) da URL de referência é enviado como Referer. O caminho e a consulta não são incluídos.

**origin-when-cross-origin**

Semelhante a "origin", mas se a origem da página de referência for diferente da origem da página de destino, o caminho completo é enviado como Referer.

**same-origin**

O cabeçalho Referer é enviado apenas para páginas que têm a mesma origem (mesmo esquema, host e porta).

**strict-origin-when-cross-origin (Padrão dos navegadores)**

Semelhante a "origin-when-cross-origin", mas apenas o valor de origem é enviado como Referer para requisições cruzadas.

**unsafe-url**

O cabeçalho Referer é sempre enviado, incluindo o caminho completo da URL de referência. 

Esses valores permitem que os desenvolvedores controlem a privacidade e a segurança das informações de referenciamento, ajudando a evitar vazamento de informações sensíveis, especialmente ao lidar com navegação entre diferentes origens (cross-origin). 

**Escolher o valor apropriado depende dos requisitos de segurança e privacidade do aplicativo da web. Já vi muita gente copiando _code snippets_ UNSAFE da internet.**


> A ortografia "Referer" em vez de "Referrer" é derivada de um erro tipográfico na especificação original HTTP/1.0, e a ortografia errada foi mantida por razões de compatibilidade.
Flowchart editor dgrm.net / Rights for schemes
Tags: webdev, javascript, programming, productivity
Published: 2023-12-18 17:43:43


![Diagram rights](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mv3fvflm9r1cevgy11hl.jpg)

You can give viewing and editing rights.
Now you can work with common schemes together with your colleagues.