teleren/devto huggingface dataset:
La pereza en el trabajo: Cómo aprovecharla sin ser despedido
Tags: productivity, programming, webdev, discuss
Published: 2023-06-18 19:58:43

En [una publicación anterior](https://dev.to/gajaguar/aprovechar-el-poder-de-la-pereza-en-el-desarrollo-de-software-bhf), mencioné como ser "perezoso" podía aportar mucho a nuestro trabajo, así como a evitar errores innecesarios. ¡Suena genial! ¿Cierto?

Sin embargo el uso indiscriminado de la pereza puede traer más problemas que beneficios. Las operaciones perezosas suelen hacer que nuestro código sea más difícil de entender, depurar y probar. A veces, es posible que ni siquiera se sepa cuándo o cómo se evalúa una expresión, o qué efectos secundarios podría tener. Y si no se tiene cuidado, podríamos terminar con una expresión enorme que nunca se evaluó o peor aún, provocar un desbordamiento de la pila de tareas.

## Todo gran poder conlleva una gran responsabilidad

Algunas de las consideraciones que podemos tener en cuenta ante el uso de las cargas o evaluaciones perezosas son:

- Utilizarlas sólo cuando tenga sentido. No hay que ser perezosos por el simple hecho de serlo, si una expresión es barata de calcular, o se necesita su valor de inmediato simplemente hay que ejecutarla y ya.
- Ser consciente de las compensaciones. ¿Se puede mejorar el rendimiento y la modularidad? Sí, pero también se puede introducir complejidad e imprevisibilidad; entonces hay que asegurarnos de comprender los beneficios y costos de su uso en un contexto específico.
- Probar el código a fondo. Es muy probable que éste sea más propenso a fallas y errores por ello debemos asegúrenos de probarlo con diferentes entradas y escenarios, y así verificar si hay comportamientos o resultados inesperados.
- Documentar todo, bueno... No todo. Las operaciones perezosas pueden hacer el código sea menos legible y mantenible; entonces es recomendable asegurarnos de documentar claramente y explicar por qué y cómo se usaron.

---

El desarrollo con un enfoque perezoso es una herramienta poderosa que puede ayudarnos a escribir un mejor software. Pero como cualquier herramienta, también puede ser mal utilizada o abusada. Usa la pereza con cuidado y precaución para aprovechar al máximo sus beneficios sin caer en sus posibles problemas.

Recuerda ¡No dejes que la pereza se apodere de ti!
Empirical Investigations in Software Quality Assurance
Tags: webdevelopemnt, sqa, softwaretesting, qualityassurance
Published: 2023-06-18 19:00:00

Empirical investigations in software quality assurance refer to research studies or experiments conducted to gather data and evidence related to the effectiveness, efficiency, and overall quality of software assurance practices and techniques. These investigations aim to provide empirical evidence to support decision-making and improvement in software quality assurance processes.

Here are some common areas of empirical investigations in software quality assurance:

1. Testing Techniques and Strategies: Researchers may investigate different testing techniques and strategies, such as unit testing, integration testing, regression testing, and automated testing, to determine their effectiveness in finding defects and ensuring software quality. They may compare different approaches, analyze their strengths and weaknesses, and propose improvements.

2. Defect Detection and Prevention: Studies may focus on defect detection and prevention methods, including code reviews, static analysis, and formal methods. Researchers may evaluate the impact of these methods on reducing defects, improving software reliability, and reducing maintenance efforts.

3. Quality Metrics and Measurement: Researchers often develop and evaluate metrics for assessing software quality. These metrics can include measures of code complexity, test coverage, fault density, and maintainability. Empirical investigations help validate the usefulness of these metrics and their relationship to software quality.

4. Process Improvement and Best Practices: Investigations may be conducted to identify and evaluate best practices and process improvement techniques in software quality assurance. This can include studying the impact of process models like Agile, Lean, or DevOps on software quality, as well as examining specific practices such as continuous integration, continuous delivery, and continuous testing.

5. Tool Evaluation: Researchers may compare and evaluate different software quality assurance tools, such as test management tools, bug tracking systems, and code review tools. The investigations can assess the effectiveness, efficiency, usability, and integration capabilities of these tools in supporting quality assurance activities.

6. Human Factors in Quality Assurance: Empirical investigations may explore the role of human factors in software quality assurance, such as the impact of team dynamics, communication, and collaboration on the effectiveness of quality assurance practices. Studies may also examine the skills and competencies required for quality assurance roles.

Empirical investigations in software quality assurance typically involve data collection, analysis, and interpretation. Researchers may use various research methods, including experiments, surveys, case studies, and data mining techniques, to gather and analyze relevant data. The findings from these investigations can help organizations make informed decisions about their quality assurance practices, optimize their processes, and improve overall software quality.
Is this code thread safe? Swift | iOS Development interview question
Tags: ios, mobile, swift, tutorial
Published: 2023-06-18 18:50:55

```swift
Solution {
    static var names: [Int] = []
}
```

- The `names` variable is defined as a static property in the Solution class.
- Static properties are shared among all instances of the class and can be accessed and modified from multiple threads concurrently.
- Since there is no synchronization mechanism in place, concurrent access to the names array can lead to data races and inconsistent results.
- If multiple threads attempt to modify the names array simultaneously, it can result in unexpected behaviour, such as incorrect or incomplete modifications, data corruption, or crashes.
- To ensure thread safety, concurrent access to the names array should be synchronized using appropriate mechanisms like locks, serial queues, or other synchronization primitives.
- Adding synchronization mechanisms will ensure that only one thread can access or modify the names array at a time, preventing data races and ensuring consistent behaviour.

Solution should be like below 🚀
```swift
class Solution {
    private static var names: [Int] = []
    private static let queue = DispatchQueue(label: "com.example.solution-queue")
    
    static func updateNames(_ name: Int) {
        queue.async {
            names.append(name)
        }
    }
}
```

🚀 [LinkedIn](https://www.linkedin.com/in/bibinjaimon/)
🚀 [GitHub](https://github.com/bibin-jaimon)
Building a webchat site from scratch, part 0
Tags: webdev, typescript, python, beginners
Published: 2023-06-18 18:39:10

Computer Science and software development is one of those fields where it doesn't seem to matter much about what school you went to or how you did in your classes. What I have come to learn is demonstrating your skills through personal projects as it shows your personal drive and passion towards your work.

As I am short on some projects myself and am looking towards applying to jobs I thought this would be a great opportunity to get started on some projects of my own hence the building of this webchat.  I'm starting off simple with just a chat webapp as I think it will teach me about front and back end development, data storage and more.  

I've decided to make it in two languages.  I've chosen to make the front end in TypeScript as I'm not very familiar with JavaScript and I've heard a lot of good things about TS, with it being a straight improvement over JS.  And Python, a language I am very familiar with, but using Flask, a web application framework to handle the backend, which I am unfamiliar with.  I considered using Django, another industry standard framework, but from the research I've done, Flask seems to be lighter weight and easier to get up and running.

I will be hosting this website myself, as I was able to grab an retired micro desktop from my work. I've installed Ubuntu server on to it with NodeJS, Python and any other dependencies I may need and I'll be connecting to it through SSH from my PC and laptop to work on it.

This blog will be me journaling any new thing I learn through the process of building the website, noting any changes I make and milestones I reach. I will be basing the foundation of my project off this article I found: [Python backend with JavaScript frontend: how to](https://tms-dev-blog.com/python-backend-with-javascript-frontend-how-to/). It goes through setting up a website just similarly to how I want to, just I will be using TypeScript instead.

With that said lets get started on the website in part 1.
Ulams Spiral of Prime Numbers
Tags: codepen
Published: 2023-06-18 17:12:33

The Ulam Spiral is a fascinating visualization that reveals a surprising pattern in the distribution of prime numbers. Named after mathematician Stanislaw Ulam, who first noticed this pattern while doodling during a boring conference, the Ulam Spiral is a simple way to plot numbers in a spiral starting from the center and mark the primes.

In this CodePen, a square grid is drawn on an HTML canvas. The script generates the numbers from 1 to maxNum, moving in a spiral pattern starting from the center of the grid. Each cell of the grid represents a number, and the cells corresponding to prime numbers are filled in with white.

The resulting pattern reveals that prime numbers aren't distributed randomly - they tend to appear in diagonal lines across the grid, a pattern that still perplexes mathematicians today.

{% codepen https://codepen.io/stp155906/pen/YzRwdgW %}
Account Abstraction && Smart Wallet
Tags: smartcontract, solidity, blockchain, accountabstraction
Published: 2023-06-18 17:04:34

**Account Abstraction :**

- The idea behind **account abstraction** is to let users use smart contract wallets rather than externally owned accounts (EOAs). As a result, users are no longer required to conduct transactions using EOAs.
- Through **EOAs**, users can communicate with the blockchain in conventional Ethereum. EOAs are nothing more than ETH and ERC-20 token holding addresses. Private keys, which are lengthy strings of hexadecimal digits, are used to control them. To access their money, users must safeguard their private keys.
- Contracts known as **smart contracts** have the capacity to store both ETH and ERC-20 tokens. They can also be configured to carry out complicated operations including conditional transfers, time-locked transactions, and multi-signature approvals.


**Smart Contract Wallet :**

Wallets that use smart contracts to manage user accounts are referred to as "smart wallets," "smart contract wallets," or "account abstracted wallets." This indicates that the user's funds are kept in a blockchain-based smart contract rather than a conventional wallet.

**Advantages over EOA :**

- **Enhanced security:** Since smart wallets are not as vulnerable to theft or loss as regular wallets, they are more secure than those latter.

- **Greater adaptability:** Complex activities like multi-signature approvals, time-locked transactions, and conditional transfers can be incorporated into smart wallets.

- Smart wallets make it simpler for users to engage with the blockchain, improving the **user experience**. Users are not required to handle transaction costs or private key management.

---

Examples : Gelato , Zero Dev , Biconomy etc you can checkout them for gas-less transaction , batch transactions and many more .

#blockchain #gas-less
Phyllotaxis pattern with numbered primes
Tags: codepen
Published: 2023-06-18 17:01:10

{% codepen https://codepen.io/stp155906/pen/XWyXoyG %}
Phyllotaxis pattern with numbered primes:
This CodePen illustrates a beautiful phyllotaxis pattern, which is a common growth pattern seen in nature. The script generates n points in a spiraling pattern, with each point located at an angle based on the golden ratio and a distance from the center that increases with the square root of its index.

Each point is represented as a number, starting from 1 and increasing along the spiral. The numbers are color-coded based on their primality: prime numbers are shown in red, while composite numbers are shown in white.

This pattern demonstrates both the prevalence of the golden ratio in natural phyllotaxis patterns, and the intriguing distribution of prime numbers when arranged in this way.
Understanding Property Descriptors in JavaScript
Tags: frontend, javascript, codingtips, jsproperties
Published: 2023-06-18 16:55:53

As a JavaScript developer, you've probably worked with objects and properties before. But have you ever wondered how you can control the behavior of these properties? Enter property descriptors.

Property descriptors are objects that allow you to define the behavior of an object's properties. They give you fine-grained control over how properties are accessed, assigned, and deleted.

There are two types of property descriptors: data descriptors and accessor descriptors.

Data descriptors define the value of a property and whether it can be changed. They have the following properties:

- `value`: The value of the property.
- `writable`: Whether the value of the property can be changed.
- `enumerable`: Whether the property can be enumerated (looped over) using `for...in` or `Object.keys()`.
- `configurable`: Whether the property can be deleted or have its attributes changed.

Accessor descriptors define functions that get or set the value of a property. They have the following properties:

- `get`: A function that gets the value of the property.
- `set`: A function that sets the value of the property.
- `enumerable` and `configurable`: Same as in data descriptors.

Here's an example of how you can use property descriptors to create a read-only property:

```javascript
const obj = {};
Object.defineProperty(obj, "readOnlyProp", {
  value: "foo",
  writable: false,
  enumerable: true,
  configurable: false,
});

console.log(obj.readOnlyProp); // "foo"
obj.readOnlyProp = "bar"; // Throws an error in strict mode
console.log(obj.readOnlyProp); // "foo"
delete obj.readOnlyProp; // Throws an error in strict mode
console.log(obj.readOnlyProp); // "foo"
```

In this example, we use `Object.defineProperty()` to define a property called `readOnlyProp` on the `obj` object. We set the `writable` property to `false`, which makes the property read-only. We also set `configurable` to `false`, which prevents the property from being deleted or having its attributes changed.

Property descriptors give you a lot of power and flexibility when working with objects and properties in JavaScript. By using them, you can create properties with custom behavior that go beyond the default behavior of plain old JavaScript objects.
My beginner intro to drug discovery (part 1)
Tags: drugdiscovery, machinelearning
Published: 2023-06-18 16:43:33

Today, I will share what I am learning from the **WCAIR Drug Discovery Short Course**. This course is crucial as it not only provides interns like myself with a comprehensive understanding of drug discovery but also enables us to make significant contributions to Ersilia (the organization I'm interning for).

In this blog post, I will outline some key takeaways from the first talk, titled "Medicine: How do they work?"

Firstly, I gained a clear understanding that a disease is not merely a set of symptoms; rather, it is any condition that disrupts the normal functioning of the body. For instance, in the case of Lyme disease, the visible rash is not the disease itself; rather, it represents the occurrence that transpires between the parasite causing the disease and the nervous system.

I also grasped that a medicine refers to the substance taken to treat an illness, typically in the form of a liquid that is ingested or swallowed. Therefore, tablets, asthmatic inhalers, and similar devices are not medicines per se; instead, they serve as vehicles for delivering medicines. The actual medicines are the chemical structures contained within the tablet, asthmatic inhaler, etc.

The choice of administration route for a medicine (i.e., the method by which it is introduced into the body) depends on several factors, such as the age group of the patient (child, adult, elderly), the duration of treatment, the site of infection, and the desired speed of the medicine's reaction.

It's important to note that the amount of medicine ingested orally does not equate to the amount that reaches the bloodstream. This explains why a doctor may prescribe a specific dosage of tablets to be taken at certain intervals. It is crucial to follow these instructions diligently. On the other hand, intravenous administration is rapid and ensures that 100% of the medicine reaches the bloodstream by bypassing the stomach, intestines, and liver.



The talk covered numerous other fascinating points, but I have highlighted some key ones above. I will continue sharing insights from the remaining talks in future blog posts.
Operating System Process Scheduling
Tags: c, operatingsystem, os
Published: 2023-06-18 16:14:29

Do You know, what is that magical behind-the-scenes mechanism that allows your computer to juggle multiple tasks effortlessly? If your answer is no, then Buckle up as we will be going on an adventurous journey to understand the inner workings of process scheduling in operating system, its importance, and how it ensures smooth multitasking. So, let’s get started!

## What is Process Scheduling?
Process scheduling is the fundamental mechanism employed by operating systems to manage and allocate system resources to multiple processes or tasks running concurrently.

It determines the order in which processes are executed, ensuring that every task gets its fair share of the CPU’s attention.

You can imagine a chef juggling various dishes simultaneously; that’s what process scheduling does for your computer!

If you are not aware of what a process is in operating system, first learn about process in operating system and then move forward.

## Why Process Scheduling is needed?
The Need for Process Scheduling You might be wondering, why bother with process scheduling? Well, imagine a world without it – your computer would freeze up, leaving you stuck with one task at a time.

Process scheduling optimizes resource utilization, improves system efficiency, and enhances user experience. It’s the superhero of multitasking!

Operating System Process Scheduling Algorithms
Now, we’ll explore various operating system process scheduling algorithms that dictate how the CPU selects and assigns tasks.

From the straightforward FCFS to the dynamic Multilevel Queue Scheduling, each algorithm has its quirks and charm.

## First-Come, First-Serve (FCFS) Scheduling
Imagine you’re waiting in line at a bustling coffee shop, eagerly anticipating your turn to place an order. Just like in real life, First-Come, First-Serve (FCFS) Scheduling works on the principle of serving tasks based on their arrival time.

## How FCFS Scheduling Works?
FCFS scheduling is one of the simplest scheduling algorithms. It operates on the basis of a queue, where processes are placed in the order they arrive.

The CPU executes the processes in the same order, following a “first in, first out” approach. Once a process starts executing, it continues until it completes or is interrupted.

The FCFS algorithm can be explained using a real-life analogy. Imagine you’re a teacher grading assignments. You stack the assignments in the order you received them, and you grade them one by one, starting from the top of the stack. The first assignment you received is the first one you grade, and so on.

Similarly, FCFS scheduling processes tasks in the order they arrive, without considering their execution time or priority.

Read the full blog on: [Process Scheduling](https://hackthedeveloper.com/process-scheduling-operating-system/). Find the blog on Google: [Process Scheduling Operating System](https://www.google.com/search?q=process+scheduling+site%3Dhackthedeveloper.com).
Centralized logging in the Otel era
Tags: logging, opentelemetry, beginners
Published: 2023-06-18 16:02:50

Centralized logging (paradoxically) is a need in the distributed systems world. How would one possibly go through doing that?
This is a post on some approaches that we tried using Opentelemetry collector and an AppDynamics (for logging data store and visualization)

#### 1. PULL model - Log aggregation through agents
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5c0w6ns9tqpigluovxmn.png)
- Made popular by the Java way of doing things
- Suitable for webserver/daemon kind of long running systems
- Agent needs permissions, could create READ locks, consume resources and could be a network hog
- Agents can process and filter the logs before sending, there by reducing the load on the collector

#### 2. PUSH model
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c17k6j7ihaiqrra4u7zf.png)
- Logs are shipped out by the applications using configurable SDKs and libraries
- Decoupled in nature
- Suitable for transient, run-anywhere, script kind of systems
- Intermediary will be a resource hog

---
We proceeded with the PUSH model using **Kafka** as the intermediary due to it's simplicity and reliability

#### First cut
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x4f19ouezpvw92l56hpp.png)
Tried with in-house python-kafka-log-handler, promtail for agent, loki for processor
- Didn't work as Loki could not EXPORT out in Otel format

#### Second try
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9gcfoc5d38tinxxj6k00.png)
Directly PUSH logs from Loki to AppDynamics backend
- Didn't work as Loki and AppD won't talk the same language

#### One more try - Otel collector to the rescue
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/vpkn7v0nkzajwh37rqal.png)
Avoid all intermediaries - Otel collector supports Kafka as a receiver and OtelHttp as an exporter to push to AppD backend (which is fully Otel compliant)
- This worked like a charm!

---
#### Foot notes:
- opentelemtry has two flavors of collectors - `opentelemetry-collector` the minimum stable and `opentelemetry-collector-contrib` which supports a ton of receivers and exporters
- `opentelemetry-collector-contrib` has loki support for both receiver and transporter; but we could not figure out a simpler way of pushing logs from applications to loki(processor/aggregator)
Difference between @Autowiring ➿& @Inject 🔌
Tags: spring, springboot, java
Published: 2023-06-18 16:00:03

In [article](https://dev.to/themayurkumbhar/wiring-in-spring-51lc) we looked at how `wiring` works in the spring framework, how to use the `@Autowired` annotation and different ways to use it.
Here we will briefly compare the `@Autowired` annotation with `@Inject` annotation.

## Qualifier support

- `@Autowired` built-in support the qualifier to qualify which exact bean to use foe dependency injection.
- `@Inject` dose not have built-in support for qualifying the specific bean.


## Standardization of annotation

- `@Autowired` is annotation specific to spring framework and dose not work outside spring context
- `@Inject` is part of java dependency injection ([JSR-330](https://jcp.org/en/jsr/detail?id=330)).


## Optional Dependency Support

- `@Autowired` supports the optional dependency with `Optional<T>` 
- `@Inject` however dose not have built-in mechanism to make dependency as optional


## Framework Integration

- `@Autowired` is specifically developed to use with the spring framework.
- `@Inject` is more general annotation can be used with any framework supporting the [JSR-330](https://jcp.org/en/jsr/detail?id=330)

> Note that both `@Inject` and `@Autowired` serve the purpose of dependency injection and can be used effectively in their respective contexts

---