teleren/devto huggingface dataset:
Intro to Python: Day 6 - Encapsulation vs Abstraction
Published: 2023-08-05 19:18:38

*Hi there 👋 I'm a New York City based web developer documenting my journey with React, React Native, and Python for all to see. Please follow my dev.to profile or [my twitter](https://twitter.com/stonestwebdev) for updates and feel free to reach out if you have questions. Thanks for your support!*

Today's short post follows up on [yesterday's discussion](https://dev.to/jwhubert91/intro-to-python-day-5-encapsulation-in-oop-3ni9) of encapsulating private variables in Python with a double underscore.

In computer science, *encapsulation* is the practice of making data and processes private within a class or function so that some information is not available to the public. In Python, it is enforced only by convention. We start variables with a double underscore `__my_variable` to make them private. This doesn't totally enforce the information not being public, but it does serve as a readable warning to other developers that these variables shouldn't be exposed.

Relatedly, *abstraction* is the concept, strategy, and discussion of how to best hide information within a program, and when to do it. So to simplify the relationship a bit, one way of thinking about this is, *abstraction* is the theory and *encapsulation* is the practice.

In many programming languages, Python included, it is a best practice to create `getter` and `setter` methods which give limited access to the private variables and data that have been encapsulated. This is another common part of the abstraction process.

Here is an example of a BankAccount class whose constructor creates private instance variables for the account number and balance. Rather than expose those variables directly, we have created getter methods to provide indirect public access which is not easily manipulable on the instance, since it only returns the value of the private variable and does not expose the variable itself.

```python
class BankAccount:
    def __init__(self, account_number, initial_balance):
        self.__account_number = account_number
        self.__balance = initial_balance

    def get_account_number(self):
        return self.__account_number

    def get_balance(self):
        return self.__balance
```

**If you like projects like this and want to stay up to date with more, check out my Twitter [@stonestwebdev](https://twitter.com/stonestwebdev), I follow back! See you tomorrow for another project.**
Asking Developers: What constitutes a project failure? Share your insights and experiences
Tags: discuss, career, management, beginners
Published: 2023-08-05 19:16:39

Back in 2021, the Project Management Institute unveiled a [survey ](https://www.pmi.org/learning/library/beyond-agility-gymnastic-enterprises-12973) that disclosed a striking fact - a staggering **12%** of projects within their organizations were designated as failures. With this in mind, let's discuss what constitutes a project failure in our field.

**Defining Project Failure** 

Project failure isn't simply about a missed deadline.  It encompasses a broader spectrum of factors that can hinder the successful completion of a project. Share your perspective on what you consider to be the defining characteristics of project failure.

**Contributing Factors**

From inadequate project planning, scope creep, and communication breakdowns to technical challenges, resource constraints, and unrealistic expectations – each of these aspects can contribute to a project's downfall. Share your experiences and insights on which factors have played a significant role in projects you've encountered.

**Red Flags and Warning Signs**

Recognizing project failure early on is crucial for effective damage control. What are the red flags and warning signs that indicate a project might be heading towards failure? Have you developed strategies to identify and address these signs before it's too late? 

**Preventing and Mitigating Failure**

Are there specific strategies, best practices, or tools that you've found effective in mitigating the risks of failure? Let's discuss the proactive steps we can collectively take to set our projects up for success.

**Share Your Experiences**

Share your anecdotes, case studies, or any real-world examples that highlight different dimensions of project failure.

Remember, the goal of this discussion is to foster a supportive environment where we can learn from each other's challenges and successes. 

Looking forward to your thoughts and contributions!🗣️📢
Judge whether the usage of capitals in it is right or not
Tags: javascript, programming, beginners, interview
Published: 2023-08-05 18:13:07

## This problem was asked by Google.

**Given a word, you need to judge whether the usage of capitals in it is right or not.**

**We define the usage of capitals in a word to be right when one of the following cases holds:**

- All letters in this word are capitals, like "USA".
- All letters in this word are not capitals, like "dailyfrontendproblem".
- Only the first letter in this word is capital if it has more than one letter, like "Google".
- Otherwise, we define that this word doesn't use capitals in a right way.


**Example**
```
const detectCapitalUse = word => {
  
};

console.log(detectCapitalUse("USA")) // true
console.log(detectCapitalUse("FlaG")) // true
Note: The input will be a non-empty word consisting of uppercase and lowercase latin letters.
```

**Solution**

```
const detectCapitalUse = (word) => {
  if (word.toUpperCase() === word) return true;
  else if (word.toLowerCase() === word) return true;
  else {
    return (
      word[0].toUpperCase() === word[0] &&
      word.slice(1).toLowerCase() === word.slice(1)
    );
  }
};
```
Length of the longest substring without repeating characters
Tags: javascript, programming, beginners, interview
Published: 2023-08-05 18:06:47

## This problem was asked by Yahoo.

**You are given a string, find the length of the longest substring without repeating characters.**


**Example**

```
function lengthOfLongestSubstring(string){

}

console.log(lengthOfLongestSubstring('abcabcbb')); // 3
console.log(lengthOfLongestSubstring('bbbbb')); // 1
console.log(lengthOfLongestSubstring('pwwkew')); // 3
```

**Solution**

```
function lengthOfLongestSubstring(str) {
  let start = 0;
  let longest = 0;
  const seen = {};
  for (let i = 0; i < str.length; i++) {
    const char = str[i];
    if (seen[char]) {
      start = Math.max(start, seen[char]);
    }
    longest = Math.max(longest, i - start + 1);
    seen[char] = i + 1;
  }
  return longest;
}
```

**Explanation**

1. Initialize a seen object to track characters we've encountered before
2. Initialize start to track the start of the current substring
3. Iterate through each character in the string
4. If we've seen this character before, update start to be the maximum of the current start or the last index for this character
5. Update longest to be the max of itself or the current substring length
6. Store the index + 1 of the current character in seen
7. After iterating through all characters, longest will be the length of the longest substring without repeating characters.
Escalado de aplicaciones Node.js con Redis
Tags: redis, node, backend
Published: 2023-08-05 17:33:44

**Redis**, un almacén de datos en memoria, te permite escalar tu aplicación Node.js al brindar una forma ágil de almacenar datos en caché y manejar la mensajería pub/sub 📩. ¡Descubre cómo hacerlo en este post! 📘
## 1. Caché de datos 💽:
¿Quieres un acceso rápido 🚀 a datos frecuentemente usados? ¡El almacenamiento en caché es tu solución! Redis, con su alta velocidad ⚡ y bajo tiempo de respuesta, es perfecto para esta tarea. Aquí te mostramos cómo usar Redis con Node.js para almacenar datos:
```js
const redis = require('redis');  
const client = redis.createClient();  
  
// Set data en el cache de redis
client.set('key', 'value', (err, result) => {  
  if (err) {  
    console.error(err);  
  } else {  
    console.log('Data cached successfully in Redis 🎉');  
  }  
});  
  
// Get data desde el cache de redis
client.get('key', (err, result) => {  
  if (err) {  
    console.error(err);  
  } else {  
    console.log(`Data from Redis: ${result} 🎈`);  
  }  
});
```
## 2. Mensajería Pub/Sub 📬:
Las aplicaciones en tiempo real 🕐, como chats 💬 y feeds en vivo 📺, requieren una excelente gestión de mensajes. Redis con su sistema pub/sub es ideal para esto. Mira cómo hacerlo:
```js
const redis = require('redis');  
const client = redis.createClient();  
  
// Suscribirse a un canal Redis  
client.subscribe('channel');  
  
// Recibir Mensajes de un canal
client.on('message', (channel, message) => {  
  console.log(`From ${channel}: ${message} 💌`);  
});  
  
// Publicar un mensaje  
client.publish('channel', 'Hello World! 🌍');
```
## 3. Almacén de sesiones 🛒:
¿Quieres mantener la información de tus usuarios de manera eficiente? Usa Redis para guardar sesiones 👥. Aquí te mostramos cómo:
```js
const express = require('express');  
const session = require('express-session');  
const redis = require('redis');  
const redisStore = require('connect-redis')(session);  
const client = redis.createClient();  
  
const app = express();  
  
// Usando redis para las sesiones
app.use(session({  
  store: new redisStore({ client }),  
  secret: 'your-secret-key',  
  resave: false,  
  saveUninitialized: true  
}));  
  
// Set & Get session data  
app.get('/', (req, res) => {  
  req.session.username = 'john';  
  res.send('Session data set 🌟');  
});  
app.get('/user', (req, res) => {  
  res.send(`Welcome back ${req.session.username}! 🎈`);  
});  
app.listen(3000, () => {  
  console.log('Server up and running 🚀');  
});
```
## En resumen 📝:
Redis no sólo mejora la velocidad ⚡ y eficiencia de tu aplicación Node.js, sino que también abre un mundo 🌍 de posibilidades como colas de trabajo, limitaciones de velocidad y tablas de clasificación. Es, sin duda, un aliado esencial para toda aplicación Node.js que aspire a escalar.
Is System Design The Core of Engineering Excellence?
Tags: productivity, development
Published: 2023-08-05 17:09:12

System Design: The Core of Engineering Excellence

System design holds a pivotal role in engineering, often considered the backbone of complex technological platforms like YouTube, Twitter, and Facebook. Imagine the masterminds who architect these platforms – they possess not only exceptional intelligence but also a profound ability to solve intricate challenges. System design, arguably more intricate than coding, is about shaping the blueprint of a digital ecosystem, where components seamlessly interact to deliver efficient, scalable, and reliable solutions.

In essence, system design is the art of crafting a high-level structure for software applications or platforms. It encompasses defining how various modules and components communicate, ensuring robustness, scalability, security, and efficiency. While coding brings ideas to life, system design shapes the very foundation on which these ideas flourish. It requires a deep understanding of software architecture, data flow, hardware constraints, and user needs, ultimately leading to the creation of systems that not only function but thrive.

As for my proficiency in system design, I excel in providing insights, best practices, and solutions for designing effective systems. Whether it's optimizing data pipelines, enhancing user experiences, or ensuring seamless integrations, I am well-versed in the intricacies of system design. I can offer valuable expertise in creating architectures that drive innovation, performance, and user satisfaction.

In a world increasingly reliant on digital solutions, system design stands as the unsung hero – a discipline that empowers engineers to build the technological marvels we rely upon daily. So, let's acknowledge the brilliance of system designers and celebrate their role in shaping the digital landscape.
CSS Animation: Card Width expand on hover
Tags: css, webdev, tutorial, animation
Published: 2023-08-05 16:59:21

In this tutorial, you will learn how to create a pure CSS card width expand animation with hover effect.




![Card Width expand on hover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/mcm1rn64fcw3m8kst3ok.gif)

If you want to create this type of animation, simply use the following CSS code snippet.

### CSS Code

```css
.container {
  display: flex;
}
.card {
  height: 200px;
  background: rgb(48, 207, 232);
  flex: 1;
  transition: 0.3s;
}
.card:hover {
  flex: 3;
  background: rgb(12, 171, 195);
}
```

---

### We made a image gallery animation using this code snippet


![Card Width expand on hover](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m749yuwnl91z8xm33hjq.gif)

Source Code

{% youtube bwOsyGQTlTw %}

---
---


Thanks for Reading ❤️! Check my website [Demo coding](https://democoding.in/) for updates about my latest CSS Animation, CSS Tools, and some cool web dev tips. Let's be friends!

Don't forget to subscribe to our channel : [Demo code](https://www.youtube.com/@democode)
Unleashing the Power of useEffect
Tags: react, javascript, frontend, webdev
Published: 2023-08-05 16:39:56

Have you ever wanted to make your web page or app more interactive and fun? In the world of web development, we have a powerful tool called the useEffect hook that allows us to do just that. In this article, we'll explore how the useEffect hook works and how it can bring your web projects to life.

Imagine you have a toy robot that can do different things. Sometimes, you want the robot to do something special when a certain condition is met. That's where the useEffect hook comes in.
The useEffect hook is like a special command you give to the robot. You tell the robot, "Hey, whenever this condition is true, do this special action." The condition could be something like a button being clicked or a number changing.
For example, let's say you have a button on a webpage. When you click the button, you want the robot to make a sound. You can use the useEffect hook to tell the robot, "Hey, whenever the button is clicked, make a sound."
The useEffect hook works like this: you give it two things. First, you give it the special action you want the robot to do. In our case, it's making a sound. Second, you give it the condition that triggers the action. In our case, it's the button being clicked.
The robot listens for the condition to happen. When it does, it performs the special action. In our example, when you click the button, the robot makes a sound.
The useEffect hook is really helpful because it allows you to control when the robot should do something special. You can tell it to do the action only once, or every time the condition happens.
It's important to remember that the robot can also clean up after itself. For example, if the robot creates some mess while making the sound, it can clean it up when it's done. This is called the clean-up function, and it's like the robot taking care of its mess.
So, the useEffect hook is like giving instructions to a robot. You tell it what to do and when to do it. It's a way to make your web page or app more interactive and fun!
Deploying an AWS ECS Cluster with AWS CDK (in GoLang) and Deploying a Streamlit-OpenAI App to the cluster
Tags: aws, openai, langchain, go
Published: 2023-08-05 16:29:00

In this post I walk through steps to use CDK as an IAAC framework for deploying to AWS. The steps in this post follow CDK using Golang. Here we will see how we can use CDK to not only deploy an ECS cluster but the whole infrastructure to support a Streamlit app which uses OpenAI API.  

https://amlanscloud.com/cdkapppost/
Currying in F#
Tags: 100daystooffload, fsharp, currying, programming
Published: 2023-08-05 16:23:21

[Currying] (https://en.wikipedia.org/wiki/Currying) (named after the mathematician Haskell Curry, who discovered the technique) is a design pattern that is natural to use in F#.

To be able to use the power of currying we need to have a function that takes two or more arguments, and that the function is in the curried form.

The *form* can come in two shapes, *curried* or *tupled*. In F# the functions are usually in the *curried* form by default.

```fsharp
// Curried form
let add x y = x + y
// val add: x: int -> y: int -> int

// Tupled form
let add (x, y) = x + y
// val add: x: int * y: int -> int
```

The first example is the more idiomatic way to define functions in F#. The thing is that functions are able to return functions, so in the curried form above of the *add* function we have the following type signature.

```fsharp
int -> int -> int
```

Which states that the function takes an integer and returns a function with the signature

```fsharp
int -> int
```

that means that the returned function takes an integer and returns an integer.

This property of curried functions make them more flexible and enables partially applied functions. So we could do this to create a new function.

```fsharp
let incrementBy20 y = add 20 y
// val incrementBy20: y: int -> int

incrementBy20 2
// val it: int = 22
```

This really shows the composability of functions. If there is a library that offer a function in the tupled form then it is possible to transform it to curried form by using this kind of pattern.
 
```fsharp
let curry f x y = f (x, y)
// val curry: f: ('a * 'b -> 'c) -> x: 'a -> y: 'b -> 'c
```

Of course it's possible to revert the process and make a function in the tupled form.

```fsharp
let uncurry f (x, y) = f x y
// val uncurry: f: ('a -> 'b -> 'c) -> x: 'a * y: 'b -> 'c
```

Happy currying!
Navigating the Tech Maze: A Comprehensive Guide to Choosing the Right Programming Language !
Tags: webdev, beginners, career, softwaredevelopment
Published: 2023-08-05 16:14:53

_**Introduction**:

In the rapidly evolving world of technology, choosing the right programming language can be a daunting task. With an abundance of options available, each tailored to specific purposes, it's essential to make informed decisions. Whether you're a seasoned developer or just starting your coding journey, this guide will help you navigate the complex landscape of programming languages.

**Understanding Your Goals:**

Before delving into the details of various programming languages, it's crucial to understand your goals. Are you building a web application, mobile app, data analysis tool, or game? Each project has unique requirements, and selecting the appropriate programming language can significantly impact your project's success.

**Comparing Popular Choices:**

In this guide, we'll delve into some of the most popular programming languages, including Python, JavaScript, Java, C++, and Ruby. We'll explore the strengths and weaknesses of each language, showcasing real-world use cases where they shine. Whether you're aiming for efficiency, versatility, ease of learning, or robust community support, we'll help you identify the language that aligns with your project goals.

**Trends and Industry Insights:**

Technology is continually evolving, with new languages and frameworks emerging regularly. We'll discuss current industry trends and share insights into which languages are gaining traction and why. By staying updated with industry trends, you can future-proof your skill set and make informed decisions about which languages to invest your time and effort in.

**Learning Resources and Support:**

Learning a new programming language is an exciting journey, and we'll provide you with valuable resources to kickstart your learning process. From online tutorials and interactive coding platforms to vibrant developer communities, we'll guide you toward the best places to learn and seek support as you explore your chosen language.

**Case Studies and Success Stories:**

To illustrate the impact of choosing the right programming language, we'll showcase a series of case studies and success stories. Learn how companies and developers solved real-world challenges by selecting the most suitable language for their projects. These stories will inspire and empower you to make informed decisions that lead to successful outcomes.

**Conclusion:**

Choosing the right programming language is a pivotal decision that can influence your project's efficiency, scalability, and overall success. By understanding your goals, exploring popular languages, staying informed about industry trends, and leveraging learning resources, you'll be well-equipped to navigate the tech maze and embark on a rewarding coding journey.

Join the conversation in the comments section and share your thoughts, experiences, and questions. Together, we'll navigate the complex world of technology and make informed choices that drive innovation and progress._
I salute Bram Moolenaar (VIM)
Tags: vim, neovim, rip
Published: 2023-08-05 16:07:46

---
title: I salute Bram Moolenaar (VIM)
published: true
description: 
tags: vim, neovim, rip
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-08-05 16:03 +0000
---

I salute Bram Moolenaar. He was the author of vim, the best text editor in the world.

> Dear all,
>
>It is with a heavy heart that we have to inform you that Bram Moolenaar passed away on 3 August 2023.
>Bram was suffering from a medical condition that progressed quickly over the last few weeks.

>Bram dedicated a large part of his life to VIM and he was very proud of the VIM community that you are all part of.

> We as family are now arranging the funeral service of Bram > which will take place in The Netherlands and will be held in the Dutch lanuage. The extact date, time and place are still to be determined.
> Should you wish to attend his funeral then please send a  message to funer...@gmail.com. This email address can also be > used to get in contact with the family regarding other matters, bearing in the mind the situation we are in right > now as family.

> With kind regards,
> The family of Bram Moolenaar

* https://groups.google.com/g/vim_announce/c/tWahca9zkt4
* https://en.wikipedia.org/wiki/Bram_Moolenaar


:q!