teleren/devto huggingface dataset:
Wait For It
Tags: adventofcode, javascript, programming, algorithms
Published: 2023-12-11 16:51:00

## [Advent of Code 2023 Day 6](https://adventofcode.com/2023/day/6)

### Part 1

#### Seeing the bell curve in the bullet points
```
Btn.
----------------------------------------|
7 -                     .               |
6                   -   .               |
5                       .       X       |
4                       .             X |
3                       .             X |
2                       .       X       |
1                   -   .               |
0 -                     .               |
  0  1  2  3  4  5  6  7. 8  9 10 11 12 | Dist.
```

Cool!

#### Verifying second race stats
> In the second race, you could hold the button for at least 4 milliseconds and at most 11 milliseconds and beat the record

```
Time:      15
Distance:  40
```

- Hold for 4 time units
- Go 4 distance units per time unit

```
Time: 1  2  3  4  5  6  7  8  9 10 11 12 13 14 15
Dist: 0  0  0  0  4  8 12 16 20 24 28 32 36 40 44
```

I feel like I'm starting to see how I could programmatically calculate this.

#### Thinking algorithmically
```
Set winners to 0
For all times i from 1 to N - 1 where N is the race time
  Calculate the product of i and N - i
  Compare to distance target
    If greater, increment winners by 1
```

Using `Time: 7` as example:
```
For i from 1 to 7
  1 * 6 = 6
  6 < 7
  LOSE

  2 * 5 = 10
  10 > 7
  WIN

  3 * 4 = 12
  12 > 7
  WIN

  4 * 3 = 12
  12 > 7
  WIN

  5 * 2 = 10
  10 > 7
  WIN

  6 * 1 = 6
  6 < 7
  LOSE

Winners: 4
```

If all bell curves are symmetrical, then this algorithm could stop as soon as `i` is greater than `N - i`, and just double that winner count at that point.

Time to write this program!

#### My working JavaScript algorithm
```js
times.reduce((product, time, index) => {
  let winners = 0
  for (let i = 1; i < time; i++) {
    winners += (i * (time - i)) > distances[index] ? 1 : 0
  }
  return product *= winners
}, 1)
```

It generates the correct answer for the example input.

And it generates the correct answer for my puzzle input!

### Part 2

#### A nod to kerning? Hahahaha!
It may come in handy to halve my algorithm's operations for this performance test, since my puzzle input requires checking nearly 50 million times.

First, I'll just try it brute-force, evaluating every permutation of `i`.

#### My working JavaScript algorithm
```js
time = parseInt(times.join(''))
distance = parseInt(distances.join(''))
let winners = 0
for (let i = 1; i < time; i++) {
  winners += (i * (time - i)) > distance ? 1 : 0
}
return winners
```

It completed in milliseconds, even on my puzzle input.

And it generated the correct answer!

That was a breath of fresh air compared to Day 5!

Fun with bell curves. Who knew?
PDF Reader UI Design 🖥️
Tags: ux, ui, design, figma
Published: 2023-12-11 16:43:27


![Image description](https://i.ibb.co/Mgg5hRB/Screenshot-from-2023-12-18-11-51-06.png)

2nd UX/UI Design created in Figma on Linux. Combined several unforgetable mainstream features and used a Windows 7 visual style for a fully fledged nostalgic PDF Reader software.

**My Portfolio**: https://aredray-portfolio.vercel.app/
How I optimize express.js API's
Tags: express, javascript, api, optimization
Published: 2023-12-11 16:36:47

When developing basic web applications or APIs with express.js for personal use there is no need to worry about optimizing the application. However, optimising the application becomes an important consideration if you intend to create an API that will serve thousands or even millions of users. In this blog, I will explain the concept of optimization and discuss various methods you can employ to enhance the performance of your application.

"What the heck is optimization?" you may ask. Consider optimization as giving your computer a spa day; visualize it relaxing in a virtual hot spring, operating more quickly, smoothly, and drama-free. It's the technological equivalent of saying to your computer "Hey, chill out, you've got this!" 

Here are some of the ways I optimize my express.js applications

## Using Node.js compression middleware

Compression middleware is used to reduce the amount of data sent over a network request between a client and a server. It's important for improving the performance and speed of web applications. [Package](https://www.npmjs.com/package/compression) and here is how you can use it

```
const compression = require('compression');
app.use(compression());

```

## Caching
Implement caching mechanisms to store frequently accessed data and reduce the need to regenerate it on each request. I leverage tools like Redis or in-memory caching to store and retrieve data efficiently.

```
const redis = require('redis');
const client = redis.createClient();

// Example middleware for caching
app.use((req, res, next) => {
  const key = req.originalUrl || req.url;
  client.get(key, (err, reply) => {
    if (reply) {
      res.send(reply);
    } else {
      res.sendResponse = res.send;
      res.send = (body) => {
        client.set(key, body);
        res.sendResponse(body);
      };
      next();
    }
  });
});

```


## Optimize Database Queries
I ensure that database queries are efficient by using proper indexing, optimizing queries, and fetching only the necessary data. I normally Object-Relational Mapping (ORM) libraries like Sequelize or Mongoose.

```
// Example with Mongoose
const mongoose = require('mongoose');
mongoose.connect('mongodb://localhost/your-database');

const userSchema = new mongoose.Schema({
  name: String,
  // ...
});

const User = mongoose.model('User', userSchema);

// Efficient query with select
app.get('/users', async (req, res) => {
  const users = await User.find().select('name');
  res.json(users);
});

```

## Monitoring and Optimizing Memory Usage
Regularly monitoring the application's memory usage to identify and address memory leaks. I like using tools like heapdump and pm2 to analyze and optimize memory consumption.

## Conclusion
By following these optimization strategies, you can significantly enhance the performance of your Express applications. Regularly test and monitor your application to identify areas for improvement and ensure a seamless user experience.
remote jobs
Published: 2023-12-11 16:34:49

Explore endless opportunities with Social swirl, your one-stop destination for remote jobs, online courses, and internships. Unlock a world of flexible work, skill-building experiences, and professional growth from the comfort of your own space. Join our community and redefine your career path today!

for more detail and apply click on the link https://socialswirl.godaddysites.com/ [](https://socialswirl.godaddysites.com)
Python3 venev setup in ubuntu
Published: 2023-12-11 16:18:06

# To install pip

```
sudo apt-get install -y python3.8-pip

```

# To install python3 virtual env

```
sudo apt install python3.8-venv

if required for python3.10
sudo apt install python3.10-venv
```

# To create a virtual env run the below command

```
python3.8 -m venv venv
```

# To activate virtual env run the below command

```
source venv/bin/activate
```

# To deactivate just type deactivate

```
deactivate
```

# Deleting the Python Virtual Environment

```
rm -rf venv 
```


# To check the installed Python package inside the virtual env run the below command

```
pip list or pip3 list
```
Производство пакетов
Published: 2023-12-11 16:11:17

В мире, насыщенном потребительским спросом, упаковка играет важную роль в обеспечении удобства и защиты товаров. Одним из наиболее распространенных материалов, используемых для производства упаковочных материалов, является полипропилен. В этой статье мы рассмотрим процесс производства полипропиленовых пакетов и их роль в современном обществе.

1. Сырье и Производство Полипропилена:
Производство полипропиленовых пакетов начинается с получения полипропилена — полимера, получаемого из нефти или природного газа. Процесс полимеризации превращает эти сырьевые материалы в полипропилен, обладающий прочностью, гибкостью и устойчивостью к химическим воздействиям.

2. Экструзия и Формирование Пленки:
Полученный полипропилен затем подвергается процессу экструзии, в результате которого формируется пленка. Этот этап определяет толщину и ширину будущих пакетов. Современные технологии позволяют производить полипропиленовую пленку с различными характеристиками, включая прозрачность, матовость и цветовые оттенки.

3. Процесс Изготовления Пакетов:
Сформированная пленка направляется на машины для изготовления пакетов. Высокотехнологичные автоматизированные системы обеспечивают точность и эффективность процесса. Пакеты могут быть созданы с использованием различных техник и иметь различные характеристики, такие как ручки, клапаны и замки-молнии.

4. Экологическая Устойчивость:
Сегодня вопросы экологии становятся все более важными. Многие производители полипропиленовых пакетов стремятся к устойчивому производству. Возможности переработки полипропилена, а также использование биоразлагаемых добавок, снижают негативное воздействие на окружающую среду  источник   [производство полипропиленовых пакетов](https://www.packet.msk.ru/pakety/proizvodstvo/)
Elevate Your Brand with Expert Mobile App Developers
Published: 2023-12-11 16:08:07

Explore unparalleled mobile app development with TechnBrains, your premier choice for expert [mobile app developers in the USA](https://www.technbrains.com/services/hire-developer/). Our proficient team turns concepts into cutting-edge applications that engage users and enhance your brand identity.

**Collaborate with us for:**

✅ Custom Mobile App Development 
✅ Intuitive User-Centric Design 
✅ State-of-the-Art Technological Solutions 
✅ Unrivalled Proficiency in Diverse Platforms

As your dedicated mobile app development partner, we prioritize innovation. Join the league of successful enterprises that have entrusted TechnBrains to redefine their digital landscape. Boost your business—get in touch with us today!
Building Festive Vibes DIY Christmas Card in Tailwind CSS
Tags: tailwindcss, css, webdev, tutorial
Published: 2023-12-11 16:05:38

In this tutorial we will create holiday Christmas card UI using Tailwind CSS. [view](https://larainfo.com/blogs/building-festive-vibes-diy-christmas-card-in-tailwind-css)
<br>

## Example 1
Create a simple Christmas design using Tailwind CSS.
```html
<div class="bg-green-500 h-screen flex items-center justify-center">
    <div class="bg-white p-8 rounded-lg shadow-md text-center">
        <h1 class="text-4xl font-bold text-red-500 mb-4">Merry Christmas!</h1>
        <p class="text-gray-700 mb-4">Wishing you a season of joy, peace, and love.</p>
        <img src="https://source.unsplash.com/400x200/?christmas" alt="Christmas Tree" class="mx-auto mb-4">
        <p class="text-gray-700">From, Your Name</p>
    </div>
</div>
```
![christmas card in tailwind](https://larainfo.com/storage/canvas/images/806neeOha2El1rese0o07iEhJOaK43Ts45ZsyxT9.png)
<br>

## Example 2
Design a Christmas card UI with a Santa Claus theme using Tailwind CSS.
```html
<div class="bg-red-600 h-screen flex items-center justify-center">
    <div class="bg-white p-8 rounded-lg shadow-md text-center">
        <h1 class="text-4xl font-bold text-green-500 mb-4">Ho Ho Ho! Merry Christmas</h1>
        <p class="text-gray-700 mb-4">May your home be filled with joy and laughter.</p>
        <img src="https://source.unsplash.com/400x200/?christmas" alt="Santa Claus" class="mx-auto mb-4 rounded-full">
        <p class="text-gray-700">From, Your Name</p>
    </div>
</div>
```
![tailwind css christmas card ui](https://larainfo.com/storage/canvas/images/jigM43ITFgnIO8ialqU5G7UpoQJDyzFaCEh5Q7Wg.png)
<br>

## Example 3
Design a Christmas card smooth on hover with gradient color using Tailwind CSS.
```html
<div class="bg-gradient-to-r from-blue-500 via-purple-500 to-pink-500 h-screen flex items-center justify-center">
    <div class="bg-white p-8 rounded-lg shadow-md text-center transform hover:scale-105 transition-transform">
        <h1 class="text-4xl font-bold text-red-500 mb-4">Wishing You a Jolly Christmas!</h1>
        <p class="text-gray-700 mb-4">May your days be filled with love and laughter.</p>
        <img src="https://source.unsplash.com/400x200/?christmas" alt="Christmas" class="mx-auto mb-4 rounded-lg">
        <p class="text-gray-700">From, Your Name</p>
    </div>
</div>
```
![tailwind holiday Christmas](https://larainfo.com/storage/canvas/images/MeK1ArbtQ0A9LvW3r2EXlcQQ717AyBOO3y8FoqXK.png)
odoo : how to get purchase order and sales order from invoice model
Tags: odoo
Published: 2023-12-11 16:01:15

Hi, 
If you need to get purchase order and sales order from account.move model ( invoic), you can use below link 

```
self.line_ids[0].sale_line_ids.order_id.id
```
that will gives you the sale order id and using that  

```
self.env['sale.order'].browse(sales_order_id).get_purchase_order()
```
then the method is 


```
        if hasattr(self, 'order_line') and self.order_line:
            purchase_line_ids = getattr(self.order_line, 'purchase_line_ids', [])
            if purchase_line_ids and purchase_line_ids[0]:
                purchase_order = purchase_line_ids[0].order_id
                if purchase_order:
                    return purchase_order
        return ''
```
AWS Cloud computing services
Published: 2023-12-11 15:59:08

AWS Cloud computing services: 
1. Amazon Elastic Compute Cloud (Amazon EC2): EC2 is a web service that provides secure and resizable compute capacity in the cloud. You can use it to provision virtual servers that are called Amazon EC2 instances, which can handle almost any computing need.

With Amazon EC2 you can do the following:
Provision and launch one or more EC2 instances in minutes.
• Stop or shut down EC2 instances when you finish running a workload.
• Pay for only the compute time that you use when running an instance.

2. AWS Lambda: Lamda is a serverless compute service that helps you run code without provisioning or managing servers. You pay for only the compute time you consume, and you incur no charges when your code isn't running.

With Lambda, you can run code for virtually any type of application or backend service, all with zero administration. You need only to upload your code, and Lambda manages everything required to run and scale your code with high availability. You can set up your code to automatically launch from other AWS services or call it directly from any web or mobile app.

3. Amazon Elastic Container Service (Amazon ECS): Amazon ECS is a highly scalable and high-performance container management system. It helps customers new containers and manage them across EC2 instances. Amazon ECS supports Docker containers. Docker is a software platform that packages software (such as applications) into containers.
To manage your containers, you must install an open-source Amazon ECS container agent on your EC2 instances. This agent is referred to as a container instance. You can run this agent on both Linux and Windows Amazon Machine Images (AMIs). Amazon ECS uses API calls to control Docker-enabled applications

4. Amazon Elastic Kubernetes Service (Amazon EKS): Amazon EKS provides the flexibility to start, run, and scale Kubernetes applications in the AWS Cloud or on premises. Kubernetes is an open-source platform for managing containerized applications. It is portable and extensible.
With Amazon EKS, you can provide highly available and secure clusters. It automates patching, node provisioning, and updates.

5. AWS Fargate is a serverless compute engine for containers. It supports both Amazon ECS and Amazon EKS architectures. Fargate allocates the right amount of compute, which reduces the need to manage EC2 instances, cluster capacity, and scaling.

6. AWS Elastic Beanstalk: AWS Elastic beanstalk is an easy-to-use service for deploying and scaling web applications. You can upload your code, and Elastic Beanstalk automatically handles the deployment, from capacity provisioning, load balancing, auto-scaling to application health monitoring. At the same time, you retain full control over the AWS resources powering your application and can access the underlying resources at any time.
There's no additional charge for Elastic Beanstalk; you pay for only the AWS resources needed to store and run your applications.
Task 1
Published: 2023-12-11 15:51:17

1. What is software testing?

     Software testing is the part of development process it involves evaluating the software application

PURPOSE OF SOFTWARE TESTING:

* Test the application works correctly
* It meets the requirements of the application
* Highly quality

KEY OBJECTIVES OF SOFTWARE TESTING:
* Defects identification
* Quality assurance
* Risk mitigation(To reduce the risk of development i.e security hacking kind of things)
* Validation (purpose of developing the application)


2. What we need to know about software testing?

     Software testing has two types
(i) Manual testing
     In manual tesing each and every machine needs to be test manually
 for example: tesing the software application in 50 laptops, each and every laptops needs to be test individually.

(ii) Automation testing
     In automation tesing, by using the code to test the all application at a time

The choosing the tesing is based on the test cases
   
STAGES OF TESING
(i) Unit tesing - Individual components/fields are testing example calculator(addition, subtraction,... etc)
(ii) Integration tesing - In this tesingt the integration between two functions example( addition and subtraction testing in one test case)
(iii) system tesing - entire function are tesing at a time
(iv) UI tesing - graphical, screen transition, page loading, user experiencing about the good working
(v) Acceptance testing - accepting when meets the required customer requirements.

TYPES OF MANUAL TESTING:
(i) Black box tesing - we tesing the behavious/functionality of internal structure or logics or code implementation
for example: tesing the laptop while tesing the all buttons are working good or not (while pressing number 1 its correctly working or not like that tesing the internal functionality)
(ii) White box or clear black box testing: a users know the entire knowledge of the code implementation/ structure/functionality like fully known about the application
(iii) Grey box testing - It is the combination of black box and white box testing
for exambple: tesing the functionality & internal knowledge of the application.

3. What is the relevance of software testing?

Software development life cycle
PLANNING - what we want to built
REQUIREMENTS - what is the requirements that customer required
DESIGN - design the application
CODING 
       - coding and tesing both are going simantanuously
TESTING (DLC/HDLC subset of software development)
DEPLOY - deploying the code to test the application to find issues/bugs.
MAINTENANCE - after user experinence changes are done

TYPES OF SDLC:
(i) Waterfall method: it is a time taken process. Once the application is completely ready then it comes to the market. in below flow
Requirements
Design
Implementation
Testing
Maintenance
(ii) Agile method: It is working in a integration/loop manner. i.e each function is done in a loop manner. like in a calculator requirement is done we can release. its 100% not sure criteria at any time we can change the changes in the particular loop.
Competitive Coding Websites
Tags: coding, competativeprogramming, programming
Published: 2023-12-11 15:46:20

Some of the competitive coding websites are:

- HackerRank
- HackerEarth
- LeetCode
- Codeforces
- CodeChef
- Kaggle
- TopCoder
- AtCoder
- Project Euler

Have I missed out any? Do let us know in the comments!
Websites on which you can learn to code
Tags: discuss, coding, programming, learning
Published: 2023-12-11 15:42:46

Different websites on which you can learn to code:
- Udemy
- Udacity
- Coursera
- freecodecamp
- Codecademy
- DataCamp
- FutureLearn
- SoloLearn
- edX
- W3Schools
- MIT OpenCourseWare
- Khan Academy
- GUVI

What are the websites that I missed out? Let me know in the comments!
What is imposter syndrome among developers?
Tags: beginners, developer, mongolian, programming
Published: 2023-12-11 15:34:44



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

Hey there, fellas! Let's talk about something that's been on my mind lately - imposter syndrome. You might have heard of it, or maybe you've even felt its effects without realizing it. So, what exactly is imposter syndrome? Well, it's that nagging feeling that despite your skills and accomplishments, you're just one step away from being exposed as a fraud. It's that voice in your head telling you that you're not good enough, that you don't belong, and that you're just faking it. Sounds familiar?

Now, the thing about imposter syndrome is that it's incredibly common in our field. The tech industry is vast and ever-changing, and it's easy to feel like you're falling behind or that you don't measure up. But here's the truth - you're not alone. Many of us, from junior developers to seasoned pros, have grappled with imposter syndrome at some point in our careers. It's a sneaky, persistent feeling, but it's important to recognize it for what it is - a trick of the mind.


So, how do you know if you're dealing with imposter syndrome? Well, here are a few signs to look out for:
Persistent Self-Doubt: Do you often question your own abilities, even in the face of evidence that you're skilled and competent?
Fear of Failure: Are you terrified of making mistakes or falling short of expectations, to the point where it holds you back?
Overworking: Do you find yourself overcompensating by working long hours or taking on more than you can handle, just to prove yourself?

Minimizing Achievements: When you do succeed, do you downplay your accomplishments, chalking them up to luck or good timing?
If any of these sound familiar, it's possible that imposter syndrome has been whispering in your ear. But fear not - there are ways to prevail over it. Here are a few tips that might help:
Talk About It: Share your feelings with a trusted colleague or friend. You'll be surprised how many people can relate, and just speaking about it can be incredibly freeing.

Reframe Your Thoughts: When that voice of self-doubt creeps in, challenge it. Remind yourself of your achievements and the hard work that got you where you are.

Set Realistic Goals: It's okay not to know everything. Set achievable goals for yourself, and celebrate your progress along the way.

Seek Support: Whether it's through mentorship, coaching, or therapy, seeking support can be a game-changer. Sometimes, an outside perspective can help you see your own worth more clearly.

Remember, imposter syndrome is a common foe, but it's not insurmountable. By recognizing it, talking about it, and taking steps to counter its effects, you can prevail over it. You belong in this field, and your skills and contributions are valuable. So, the next time imposter syndrome comes knocking, show it the door and keep on coding!


Happy coding folks!