teleren/devto huggingface dataset:
Today's Daily Humor For Devs - Daily Developer Jokes
Tags: jokes, dailydeveloperjokes, watercooler
Published: 2022-06-08 08:00:03

---
title: "Today's Daily Humor For Devs - Daily Developer Jokes"
description: "Check out today's daily developer joke! (a project by Fred Adams at xtrp.io)"
series: "Daily Developer Jokes"
published: true
tags: #jokes, #dailydeveloperjokes, #watercooler
---

Hi there! Here's today's Daily Developer Joke. We hope you enjoy it; it's a good one.

![Joke Image](https://private.xtrp.io/projects/DailyDeveloperJokes/public_image_server/images/5e1258c20b362.png)

---

For more jokes, and to submit your own joke to get featured, check out the [Daily Developer Jokes Website](https://dailydeveloperjokes.github.io/). We're also open sourced, so feel free to view [our GitHub Profile](https://github.com/dailydeveloperjokes).

### Leave this post a ❤️ if you liked today's joke, and stay tuned for tomorrow's joke too!

_This joke comes from [Dad-Jokes GitHub Repo by Wes Bos](https://github.com/wesbos/dad-jokes) (thank you!), whose owner has given me permission to use this joke with credit._

<!--
Joke text:
___Q:___ Why did the computer keep sneezing?

___A:___ It had a virus!
 -->
Update Mongo DB By NodeJS Cron Job
Tags: node, mongodb, webdev, cronjobs
Published: 2022-06-08 07:53:34

We have multiple scenarios where we need to update our database fields at some particular time instants based on some conditions for example I need to update the status of all students to a particular batch after the course has finished, there are many ways to automate this process so that the fields in my database are updated automatically on a particular time.

## Node JS Cron Package
Performing a particular task at a particular instant can be efficiently achieved through a Cron Job. 
Node Cron is a handy npm package where you schedule different jobs and they run at the particular time instants periodically. Cron Jobs are common to achieve tasks like sending email notifications, deleting error logs or updating some order statuses etc.


## Problem Statement
Today, I am also going to discuss a same scenario where I have a 'Campaigns' table in the mongo database and if the end_date of campaigns is lesser than today then I have to update the status of all those campaigns to 'inactive'. I will make use of Node JS Cron Job to run every midnight and check all the records in 'Campaigns' collection and update the ones that have the above mentioned condition.

Now let's start coding.
First we need to install node-cron package in our node app, I am assuming that you have already created a simple node/express app, if you are new to Node then you can follow my nodejs/express tutorial [here](https://dev.to/nasreenkhalid/create-express-server-with-ejs-templating-engine-200).

Let's begin by installing node-cron package by using following command:
```
npm install --save node-cron
```

Now in the index.js file we will import the cron package and schedule our job:

```
const cron = require('node-cron');
```
Below is the cronjob runs every midnight and set the active campaigns to inactive if end_date is lesser than today 

Also, note that first we need to convert today's date in the same format as saved in db

```
var todayDate = new Date().toISOString().substring(0, 10);

cron.schedule('0 1 * * *', () => {
  console.log('Running a task every midnight (1:00 am)');
  Campaign.findOneAndUpdate({ campaignStatus: 'active', end_date: { 
   
    $lt: todayDate, 

 }}, { $set:  {campaignStatus: 'inactive' }},

 {returnNewDocument: true}, (err, data) => {
  if (err) {
    return errorHandler(dbError, res);
  }
})
});
```

The above job runs every midnight and update the campaigns status accordingly.

If you wish to read more about setting the time intervals in your cron jobs then this is a very helpful [link](https://crontab.guru/#0_1_*_*_*) describing all the asterisks purpose in our cron job schedule.

Hope you enjoyed reading this article and it helps you in your coding journey.

If you are looking for a learning experience that makes you a professional developer with hands-on coding skills, join one of the best courses [here](https://qvault.io/?via=nasreen)

Happy coding...
What are some essential language agnostic books or tutorials to level-up as a web developer?
Tags: webdev, tutorial, books
Published: 2022-06-08 07:52:14

I've been a Front-End developer for almost 4 years. I've always worked with Angular framework at work.
I know that there's so much to learn in this field and I want to learn the stuff that every web developer or software engineer should know to be an efficient programmer and builds performant software or web apps.
I like to know about what happens when a web app is running in the browser, what makes it slower/faster, how does bundling work and how to make the bundle smaller, or other concepts that are important to know. 
please recommend resources you used that helped you become a better software engineer.
Qualitative & Highly Cost-Efficient Dedicated Server
Tags: webhosting, dedicatedserver, sharedhosting, cloudserver
Published: 2022-06-08 07:43:24

VPS hosting from [YouGet Host](https://yougethost.com/) blends the efficiency of a dedicated server with the simplicity of cloud hosting. With our managed VPS solutions, you can keep an eye on your servers, reduce risk, and boost efficiency. Our 24*7 (365) support team is available to help you to choose the best hosting solution for your business.
All of the essentials for a fast website performance

Website Speed: Lightning Fast
Nobody loves a sluggish website. Due to higher servers, premium hardware, and global server locations for the highest possible latency, the websites can load faster.
We use cutting-edge technologies like LiteSpeed, HTTP/2, PHP 7, and a free CDN to make your site faster than ever before, from SSD storage to server-level caching. This boosts your Google rankings while also offering the best possible experience for your visitors.

Strong Security:
With our custom web application firewall guidelines, you can keep your website safe from constant attacks. We can avoid the majority of web application attacks even before they start when we combine real-time 24/7 server monitoring. 
We'll give you a free Let's Encrypt SSL certificate to encrypt HTTPS traffic on your web. We also make daily offsite backups of your website. You can restore your control panel at any time.

For full information on Dedicated Server features visit:- [https://yougethost.com/](https://yougethost.com/)
Partition Equal Subset Sum
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 07:30:38

Given a **non-empty** array `nums` containing **only positive integers**, find if the array can be partitioned into two subsets such that the sum of elements in both subsets is equal.

**Example 1:**

**Input:** nums = \[1,5,11,5\]
**Output:** true
**Explanation:** The array can be partitioned as \[1, 5, 5\] and \[11\].

**Example 2:**

**Input:** nums = \[1,2,3,5\]
**Output:** false
**Explanation:** The array cannot be partitioned into equal sum subsets.

**Constraints:**

*   `1 <= nums.length <= 200`
*   `1 <= nums[i] <= 100`

**SOLUTION:**

    class Solution:
        def isSubsetSum(self, arr, total, n):
            if total == 0:
                return True
            if total != 0 and n == 0:
                return False
            if (n, total) in self.cache:
                return self.cache[(n, total)]
            if 2 * arr[n - 1] > total:
                return self.isSubsetSum(arr, total, n - 1)
            self.cache[(n, total)] = self.isSubsetSum(arr, total, n - 1) or self.isSubsetSum(arr, total - 2 * arr[n - 1], n - 1)
            return self.cache[(n, total)]
        
        def canPartition(self, nums: List[int]) -> bool:
            self.cache = {}
            n = len(nums)
            total = sum(nums)
            if total % 2 == 1:
                return False
            return self.isSubsetSum(nums, total, n)
Coding is fun for me
Tags: beginners, programming, python, codenewbie
Published: 2022-06-08 07:22:42

import friendship as friendship

    Just wanna say hi!
I started new project 3 year ago.
For the first time it looks impossible for me, but my new colleagues helped me.
So the first prototype was made in MS Excel.
Next - was in Python, and it was standalone exe file.
Now it's webapp, and who knows what it's gonna be next?

So, thank you!
Keep in touch.

Vova "Bob" Berrycow
Brutally Roast my Personal Site
Published: 2022-06-08 07:07:42

---
title: Brutally Roast my Personal Site
published: true
description:
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---
My website is ubervincent.com

The idea is for someone to come in and able to follow my routine and my content from various places.

Please let me know how I can improve the UX of someone of wants to follow my work.
Minimum Average Difference
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 07:00:48

You are given a **0-indexed** integer array `nums` of length `n`.

The **average difference** of the index `i` is the **absolute** **difference** between the average of the **first** `i + 1` elements of `nums` and the average of the **last** `n - i - 1` elements. Both averages should be **rounded down** to the nearest integer.

Return _the index with the **minimum average difference**_. If there are multiple such indices, return the **smallest** one.

**Note:**

*   The **absolute difference** of two numbers is the absolute value of their difference.
*   The **average** of `n` elements is the **sum** of the `n` elements divided (**integer division**) by `n`.
*   The average of `0` elements is considered to be `0`.

**Example 1:**

**Input:** nums = \[2,5,3,9,5,3\]
**Output:** 3
**Explanation:**
- The average difference of index 0 is: |2 / 1 - (5 + 3 + 9 + 5 + 3) / 5| = |2 / 1 - 25 / 5| = |2 - 5| = 3.
- The average difference of index 1 is: |(2 + 5) / 2 - (3 + 9 + 5 + 3) / 4| = |7 / 2 - 20 / 4| = |3 - 5| = 2.
- The average difference of index 2 is: |(2 + 5 + 3) / 3 - (9 + 5 + 3) / 3| = |10 / 3 - 17 / 3| = |3 - 5| = 2.
- The average difference of index 3 is: |(2 + 5 + 3 + 9) / 4 - (5 + 3) / 2| = |19 / 4 - 8 / 2| = |4 - 4| = 0.
- The average difference of index 4 is: |(2 + 5 + 3 + 9 + 5) / 5 - 3 / 1| = |24 / 5 - 3 / 1| = |4 - 3| = 1.
- The average difference of index 5 is: |(2 + 5 + 3 + 9 + 5 + 3) / 6 - 0| = |27 / 6 - 0| = |4 - 0| = 4.
The average difference of index 3 is the minimum average difference so return 3.

**Example 2:**

**Input:** nums = \[0\]
**Output:** 0
**Explanation:**
The only index is 0 so return 0.
The average difference of index 0 is: |0 / 1 - 0| = |0 - 0| = 0.

**Constraints:**

*   `1 <= nums.length <= 105`
*   `0 <= nums[i] <= 105`

**SOLUTION:**

    class Solution:
        def getDiff(self, prefix, i, n):
            l = (prefix[i + 1] - prefix[0])
            r = prefix[-1] - l
            l = l // (i + 1)
            r = r // (n - i - 1) if i < n - 1 else 0
            return abs(l - r)
        
        def minimumAverageDifference(self, nums: List[int]) -> int:
            n = len(nums)
            prefix = [0]
            for i in range(n):
                prefix.append(prefix[-1] + nums[i])
            return min(range(n), key = lambda i: self.getDiff(prefix, i, n))
House Robber III
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 04:00:48

The thief has found himself a new place for his thievery again. There is only one entrance to this area, called `root`.

Besides the `root`, each house has one and only one parent house. After a tour, the smart thief realized that all houses in this place form a binary tree. It will automatically contact the police if **two directly-linked houses were broken into on the same night**.

Given the `root` of the binary tree, return _the maximum amount of money the thief can rob **without alerting the police**_.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/03/10/rob1-tree.jpg)

**Input:** root = \[3,2,3,null,3,null,1\]
**Output:** 7
**Explanation:** Maximum amount of money the thief can rob = 3 + 3 + 1 = 7.

**Example 2:**

![](https://assets.leetcode.com/uploads/2021/03/10/rob2-tree.jpg)

**Input:** root = \[3,4,5,1,3,null,1\]
**Output:** 9
**Explanation:** Maximum amount of money the thief can rob = 4 + 5 = 9.

**Constraints:**

*   The number of nodes in the tree is in the range `[1, 104]`.
*   `0 <= Node.val <= 104`

**SOLUTION:**

    # Definition for a binary tree node.
    # class TreeNode:
    #     def __init__(self, val=0, left=None, right=None):
    #         self.val = val
    #         self.left = left
    #         self.right = right
    class Solution:
        def maxRob(self, root: Optional[TreeNode], pos, canLoot = True) -> int:
            if (pos, canLoot) in self.cache:
                return self.cache[(pos, canLoot)]
            maxLoot = 0
            if root:
                if canLoot:
                    l = self.maxRob(root.left, 2 * pos, canLoot = False)
                    r = self.maxRob(root.right, 2 * pos + 1, canLoot = False)
                    maxLoot = max(maxLoot, root.val + l + r)
                l = self.maxRob(root.left, 2 * pos, canLoot = True)
                r = self.maxRob(root.right, 2 * pos + 1, canLoot = True)
                maxLoot = max(maxLoot, l + r)
            self.cache[(pos, canLoot)] = maxLoot
            return maxLoot
        
        def rob(self, root: Optional[TreeNode], canLoot = True) -> int:
            self.cache = {}
            return self.maxRob(root, 1, canLoot = True)
Longest Substring Without Repeating Characters
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 06:30:41

Given a string `s`, find the length of the **longest substring** without repeating characters.

**Example 1:**

**Input:** s = "abcabcbb"
**Output:** 3
**Explanation:** The answer is "abc", with the length of 3.

**Example 2:**

**Input:** s = "bbbbb"
**Output:** 1
**Explanation:** The answer is "b", with the length of 1.

**Example 3:**

**Input:** s = "pwwkew"
**Output:** 3
**Explanation:** The answer is "wke", with the length of 3.
Notice that the answer must be a substring, "pwke" is a subsequence and not a substring.

**Constraints:**

*   `0 <= s.length <= 5 * 104`
*   `s` consists of English letters, digits, symbols and spaces.

**SOLUTION:**

    class Solution:
        def lengthOfLongestSubstring(self, s: str) -> int:
            i = 0
            j = i
            longest = 0
            n = len(s)
            dup = {}
            while j < n:
                if s[j] not in dup:
                    dup[s[j]] = j
                    j += 1
                    longest = max(longest, j - i)
                else:
                    i = dup[s[j]] + 1
                    j = i
                    dup = {}
            return longest
A note app is all I needed to be productive.
Tags: burnout, productivity, webdev, career
Published: 2022-06-08 06:30:14

---
title: A note app is all I needed to be productive.
published: true
description: Being a developer is a mentally demanding job that necessitates many soft and hard skills as well as a specific set of personal traits in order to work productively and avoid burnout.
tags: burnout, productivity, webdev, career
# cover_image: ![Productivity-tips-by-krishna-damaraju](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jg36n11e0vuqhdfwe4wp.png)
# Use a ratio of 100:42 for best results.
---
![Productivity-tips-by-krishna-damaraju](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jg36n11e0vuqhdfwe4wp.png)

Being a developer is a mentally demanding job that necessitates many soft and hard skills as well as a specific set of personal traits in order to work productively and avoid burnout. 

That was my need a few years ago: to make the most of my day, avoid task overload, and _**eventually not work over weekends to compensate 🙅.**_ 

Please read the below article on my journey from spending 6 hours on every weekend and not so good time management to working not more than 8 hours per day and no work load. 

https://www.krishnadamaraju.me/a-note-app-is-all-needed-to-be-productive

I'd be happy to hear you thoughts on it

Cheers 🙌🏻
-Krishna
AWS's disadvantages AWS
Tags: aws
Published: 2022-06-08 06:22:31

After investigating AWS attributes After that, we will look at AWS disadvantages. The AWS Instructional discusses the benefits that cloud computing has over other methods. After studying the AWS Benefits and Limitations , we can use AWS efficiently. Learn further about what you can expect from AWS services by taking [AWS certification](https://www.edureka.co/aws-certification-training).

**Let's now examine the drawbacks of AWS.**

**Limitations**

It's first among the many negatives that come in Cloud Computing. Within AWS there are some limitations on EC2 and security. Businesses using AWS will be able to access resources that are defaulted to be used, however the problem is when the default limits for resources vary between regions. AWS is able to make a request for more resources, companies find it an advantage to AWS.

**Inadequacy of Expertise**

AWS is the latest technology with a complex infrastructure. Companies using AWS to manage Cloud Computing Cloud Computing platform are looking for experts to oversee AWS cloud-based infrastructure. There are only a handful of experts are knowledgeable about AWS and any other cloud service. Businesses are keen to make a commitment AWS but are having a difficult to find the right expert to collaborate with AWS which can help companies to better performance. This could be a disadvantage to AWS in terms of both time as well as money.

**Price Variations**

The price of AWS services can differ depending on various factors, such as the cost of power and land and the tax rates that vary between regions. There are also variations for those who require additional tech support. Developer Enterprise Business Developer, and Business Developer are the three options that you can choose from, and the prices vary based on. This will impact the cost of your monthly bill. But using services like Amazon CloudWatch You can monitor your usage as well. Serverless Data Lake helps you identify the costs of the services that are available within your local area.

**General Problems**

Amazon is a huge customer base with millions of users. Therefore, it can be susceptible to short-term Cloud Computing problems. There are instances of users experiencing downtime when using servers. It could be because of the power failure or connection for the cloud provider. Whatever the reason the issue will be fixed at an upcoming time.

**Conclusion**

This blog is a method to examine the benefits and disadvantages associated with Amazon Web Services. Numerous top businesses, like Netflix, LinkedIn, etc. Many government agencies depend on AWS to satisfy their cloud needs. AWS offers some of the most efficient services that make customers forget about their weaknesses. Amazon has always tried to exceed the expectations of its clients and that's the reason it's so popular.
Search in Rotated Sorted Array II
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 06:00:45

There is an integer array `nums` sorted in non-decreasing order (not necessarily with **distinct** values).

Before being passed to your function, `nums` is **rotated** at an unknown pivot index `k` (`0 <= k < nums.length`) such that the resulting array is `[nums[k], nums[k+1], ..., nums[n-1], nums[0], nums[1], ..., nums[k-1]]` (**0-indexed**). For example, `[0,1,2,4,4,4,5,6,6,7]` might be rotated at pivot index `5` and become `[4,5,6,6,7,0,1,2,4,4]`.

Given the array `nums` **after** the rotation and an integer `target`, return `true` _if_ `target` _is in_ `nums`_, or_ `false` _if it is not in_ `nums`_._

You must decrease the overall operation steps as much as possible.

**Example 1:**

**Input:** nums = \[2,5,6,0,0,1,2\], target = 0
**Output:** true

**Example 2:**

**Input:** nums = \[2,5,6,0,0,1,2\], target = 3
**Output:** false

**Constraints:**

*   `1 <= nums.length <= 5000`
*   `-104 <= nums[i] <= 104`
*   `nums` is guaranteed to be rotated at some pivot.
*   `-104 <= target <= 104`

**Follow up:** This problem is similar to [Search in Rotated Sorted Array](/problems/search-in-rotated-sorted-array/description/), but `nums` may contain **duplicates**. Would this affect the runtime complexity? How and why?

**SOLUTION:**

    class Solution:
        def search(self, nums: List[int], target: int) -> bool:
            # Initilize two pointers
            begin = 0
            end = len(nums) - 1 
            while begin <= end:
                mid = (begin + end)//2
                if nums[mid] == target:
                    return True
                if nums[mid] == nums[end]: # Fail to estimate which side is sorted
                    end -= 1  # In worst case: O(n)
                elif nums[mid] > nums[end]: # Left side of mid is sorted
                    if  nums[begin] <= target and target < nums[mid]: # Target in the left side
                        end = mid - 1
                    else: # in right side
                        begin = mid + 1
                else: # Right side is sorted
                    if  nums[mid] < target and target <= nums[end]: # Target in the right side
                        begin = mid + 1
                    else: # in left side
                        end = mid - 1
            return False