teleren/devto huggingface dataset:
Implement strStr()
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 00:30:42

Implement [strStr()](http://www.cplusplus.com/reference/cstring/strstr/).

Given two strings `needle` and `haystack`, return the index of the first occurrence of `needle` in `haystack`, or `-1` if `needle` is not part of `haystack`.

**Clarification:**

What should we return when `needle` is an empty string? This is a great question to ask during an interview.

For the purpose of this problem, we will return 0 when `needle` is an empty string. This is consistent to C's [strstr()](http://www.cplusplus.com/reference/cstring/strstr/) and Java's [indexOf()](https://docs.oracle.com/javase/7/docs/api/java/lang/String.html#indexOf(java.lang.String)).

**Example 1:**

**Input:** haystack = "hello", needle = "ll"
**Output:** 2

**Example 2:**

**Input:** haystack = "aaaaa", needle = "bba"
**Output:** -1

**Constraints:**

*   `1 <= haystack.length, needle.length <= 104`
*   `haystack` and `needle` consist of only lowercase English characters.

**SOLUTION:**

    class Solution:
        def strStr(self, haystack: str, needle: str) -> int:
            n = len(haystack)
            k = len(needle)
            exists = {needle}
            for i in range(0, n - k + 1):
                if haystack[i : i + k] in exists:
                    return i
            return -1
Solution for 'wazuh-agentd: ERROR: Invalid server address found: 'MANAGER_IP''
Tags: wazuh, security, python, ubuntu
Published: 2022-06-09 00:22:12


### Problem:

Running into the following error when trying to install `wazuh-manager` / `wazuh-agent` in Ubuntu 20.04:

```
Jun 08 17:06:38 sean-VirtualBox env[5409]: /var/ossec/bin/wazuh-logcollector
Jun 08 17:06:38 sean-VirtualBox env[5409]: /var/ossec/bin/wazuh-modulesd
Jun 08 17:06:38 sean-VirtualBox env[5409]: Starting Wazuh v4.3.4...
Jun 08 17:06:38 sean-VirtualBox env[5409]: wazuh-execd already running...
Jun 08 17:06:38 sean-VirtualBox env[5433]: 2022/06/08 17:06:38 wazuh-agentd: ERROR: (4112): Invalid server address found: 'MANAGER_IP'
Jun 08 17:06:38 sean-VirtualBox env[5433]: 2022/06/08 17:06:38 wazuh-agentd: CRITICAL: (1215): No client configured. Exiting.
Jun 08 17:06:38 sean-VirtualBox env[5409]: wazuh-agentd did not start
```

### Solution:

This error indicates that the `server.address` field in the `/var/ossec/etc/ossec.conf` file does not contain a valid IP address.

To fix this run the command `sudo nano /var/ossec/etc/ossec.conf` and change the `server.address` field to whatever you're server IP address is(`127.0.0.1` in my case)

Here the section of the `/var/ossec/etc/ossec.conf` file where you need to make the change:

```
...
<client>
    <server>
      <address>127.0.0.1</address>
      <port>1514</port>
      <protocol>tcp</protocol>
    </server>
    <config-profile>ubuntu, ubuntu20, ubuntu20.04</config-profile>
    <notify_time>10</notify_time>
    <time-reconnect>60</time-reconnect>
    <auto_restart>yes</auto_restart>
    <crypto_method>aes</crypto_method>
</client>
...
```

Hope this solves your issue!

## Conclusion

Thanks for reading this blog post!

If you have any questions or concerns please feel free to post a comment in this post and I will get back to you when I find the time.

If you found this article helpful please share it and make sure to follow me on [Twitter ](https://twitter.com/SeanAtukorala)and [GitHub](https://github.com/ShehanAT), connect with me on [LinkedIn](https://www.linkedin.com/in/shehan-atukorala-8631491a5/) and subscribe to my [YouTube channel](https://www.youtube.com/channel/UCtxed_NljgtAXrQMMdLvhrQ).
Number of Equivalent Domino Pairs
Tags: leetcode, dsa, theabbie
Published: 2022-06-09 00:00:44

Given a list of `dominoes`, `dominoes[i] = [a, b]` is **equivalent to** `dominoes[j] = [c, d]` if and only if either (`a == c` and `b == d`), or (`a == d` and `b == c`) - that is, one domino can be rotated to be equal to another domino.

Return _the number of pairs_ `(i, j)` _for which_ `0 <= i < j < dominoes.length`_, and_ `dominoes[i]` _is **equivalent to**_ `dominoes[j]`.

**Example 1:**

**Input:** dominoes = \[\[1,2\],\[2,1\],\[3,4\],\[5,6\]\]
**Output:** 1

**Example 2:**

**Input:** dominoes = \[\[1,2\],\[1,2\],\[1,1\],\[1,2\],\[2,2\]\]
**Output:** 3

**Constraints:**

*   `1 <= dominoes.length <= 4 * 104`
*   `dominoes[i].length == 2`
*   `1 <= dominoes[i][j] <= 9`

**SOLUTION:**

    class Solution:
        def numEquivDominoPairs(self, dominoes: List[List[int]]) -> int:
            n = len(dominoes)
            ctr = {}
            for i in range(n):
                curr = tuple(sorted(dominoes[i]))
                ctr[curr] = ctr.get(curr, 0) + 1
            op = 0
            for pair in ctr:
                op += ctr[pair] * (ctr[pair] - 1) // 2
            return op
Append K Integers With Minimal Sum
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 23:30:39

You are given an integer array `nums` and an integer `k`. Append `k` **unique positive** integers that do **not** appear in `nums` to `nums` such that the resulting total sum is **minimum**.

Return _the sum of the_ `k` _integers appended to_ `nums`.

**Example 1:**

**Input:** nums = \[1,4,25,10,25\], k = 2
**Output:** 5
**Explanation:** The two unique positive integers that do not appear in nums which we append are 2 and 3.
The resulting sum of nums is 1 + 4 + 25 + 10 + 25 + 2 + 3 = 70, which is the minimum.
The sum of the two integers appended is 2 + 3 = 5, so we return 5.

**Example 2:**

**Input:** nums = \[5,6\], k = 6
**Output:** 25
**Explanation:** The six unique positive integers that do not appear in nums which we append are 1, 2, 3, 4, 7, and 8.
The resulting sum of nums is 5 + 6 + 1 + 2 + 3 + 4 + 7 + 8 = 36, which is the minimum. 
The sum of the six integers appended is 1 + 2 + 3 + 4 + 7 + 8 = 25, so we return 25.

**Constraints:**

*   `1 <= nums.length <= 105`
*   `1 <= nums[i] <= 109`
*   `1 <= k <= 108`

**SOLUTION:**

    class Solution:
        def minimalKSum(self, nums: List[int], k: int) -> int:
            nums.sort()
            nums.insert(0, 0)
            nums.append(float('inf'))
            print(nums)
            total = 0
            n = len(nums)
            for i in range(n - 1):
                if k >= nums[i + 1] - nums[i] - 1:
                    if nums[i + 1] - nums[i] > 1:
                        total += nums[i + 1] * (nums[i + 1] - 1) // 2
                        total -= nums[i] * (nums[i] + 1) // 2
                        k -= nums[i + 1] - nums[i] - 1
                else:
                    end = nums[i] + k
                    beg = nums[i]
                    total += end * (end + 1) // 2
                    total -= beg * (beg + 1) // 2
                    break
            return total
Day 569 : Always
Tags: hiphop, code, coding, lifelongdev
Published: 2022-06-08 23:27:45

_liner notes_:
- Professional : Not a bad day. Had a couple of meetings. Updated some documentation. Ran into some issues with GitHub where I had to fix some merge conflicts, that was fun. Submitted a Call For Papers to an upcoming conference. Responded to a question in the community channel. Pretty productive.

- Personal : Updated https://doingstuff.in with the stuff from my latest trips. Played with this new technology trying to get it to work. The provided demo only worked sometimes. Got caught up with "The Boys" and went to sleep.

![View from a rocky shore with a lake a forest on the edge looking at a mountain with some more brown, green and red trees at the base in Lake Willoughby, VT, USA](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/183gtkgcwef6tx91z529.jpg)

Going to go through some tracks for this week's radio show so I can get a head start. Then I'll probably watch the premiere episode of "Ms Marvel" on Disney+. May try to play around with that technology some more. Always trying out new stuff to use in upcoming projects.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube jVYed4NUZsQ %}
After I start a node program listening on port 8080, can I still start a Java program on port 8080 without reporting an error?
Tags: java, node, springbootadmin
Published: 2022-06-08 23:22:01

When I was working before, a node program listened to port 8080 before starting the Spring Boot Admin Server, and then started the Spring Boot Admin Server (the default is also port 8080).

At this time, the browser can access the Spring Boot Admin Server interface normally, but other Java services cannot be registered with the Spring Boot Admin Server, prompting a 404 error. 

Later, it was found that the registration of the novel service was handled by the node program listening on port 8080, and the node program could be closed to register normally.

Is this because Node.Js can achieve port reuse? Can someone who knows it explain it in detail?
Day 61: Handling errors in GraphQL
Published: 2022-06-08 23:15:18

Hi!
Today I mainly worked on the mockups designs with Figma and Logo designs with Photoshop for a new project I plan to work on with a friend of mine. in the evening is where I started doing research about Good practices of handling errors in GraphQL. I have found some good resources including tutorials and documentations but I was not able to work on the implementations which I plan to start working on by tomorrow as the project is due on Friday. 
Today I also chose Nexus-GraphQl as the open source to contribute to as I have been using it for schema management and I like it for being easy to use. I already forked and cloned their github repo so I will start going through their code by the weekend!
Today plan is to work on the project and work on the remaining cards on Trello Board. It's a lot but I will try my best.

Signing off...
Eleventy Partials
Tags: eleventy, jamstack, tutorial, beginners
Published: 2022-06-08 23:05:15

---
canonical_url: https://cloudcannon.com/community/learn/eleventy-beginner-tutorial/eleventy-partials/
series: Eleventy Beginner Tutorial
--- 
By [Mike Neumegen](https://cloudcannon.com)

Brought to you by [CloudCannon](https://cloudcannon.com/eleventy-cms/), the Git-based CMS for Eleventy.

Partials are a way to include a snippet of code into a layout with the goal of reducing repetition or hiding some complexity. In this lesson, we’ll add a navigation bar to the site using a partial. While we could add the nav bar to our existing layout, it’s easier to maintain a site which is broken down into small components rather than sprawling thousand-line files.

Your first partial
------------------

Partials live in the `_includes` directory we’ve already created and typically have a convention of starting the filename with an underscore to distinguish them from layouts. Create `/_includes/_nav.html` with the following contents:

```html
    <nav>
      <ul>
        <li><a href="/">Home</a></li>
        <li><a href="/about/">About</a></li>
      </ul>
    </nav>
```

That’s all there is to the navigation. Now we can include it in our layout. Open `/_includes/page.html` and add the following below `</body>`:

```html
    {% include '_nav.html' %}
```

Render the page and admire your new navigation.

Your second partial
-------------------

Another great use for partials is to hide complexity. Typically the `<head>` will contain all sorts of asset references, SEO tags, social tags, and analytics scripts. I like to pull all of this HTML into a partial to simplify the layout and make the tags easier to find.

Create `/_includes/_meta.html` with the following contents:

```html
    <meta charset="utf-8">
    <title>{{ title }}</title>
    <link rel="stylesheet" href="/assets/main.css">
```

And replace the contents of `<head>` in `/_includes/page.html` with an include:

```html
    {% include '_meta.html' %}
```

The rendered site should look exactly the same, only this time it’s a little bit easier for you to maintain.

What’s next?
------------

In the next lesson we’ll go over the basics of templating using Liquid in Eleventy.
Number of Ways to Buy Pens and Pencils
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 23:00:44

You are given an integer `total` indicating the amount of money you have. You are also given two integers `cost1` and `cost2` indicating the price of a pen and pencil respectively. You can spend **part or all** of your money to buy multiple quantities (or none) of each kind of writing utensil.

Return _the **number of distinct ways** you can buy some number of pens and pencils._

**Example 1:**

**Input:** total = 20, cost1 = 10, cost2 = 5
**Output:** 9
**Explanation:** The price of a pen is 10 and the price of a pencil is 5.
- If you buy 0 pens, you can buy 0, 1, 2, 3, or 4 pencils.
- If you buy 1 pen, you can buy 0, 1, or 2 pencils.
- If you buy 2 pens, you cannot buy any pencils.
The total number of ways to buy pens and pencils is 5 + 3 + 1 = 9.

**Example 2:**

**Input:** total = 5, cost1 = 10, cost2 = 10
**Output:** 1
**Explanation:** The price of both pens and pencils are 10, which cost more than total, so you cannot buy any writing utensils. Therefore, there is only 1 way: buy 0 pens and 0 pencils.

**Constraints:**

*   `1 <= total, cost1, cost2 <= 106`

**SOLUTION:**

    class Solution:
        def waysToBuyPensPencils(self, total: int, cost1: int, cost2: int) -> int:
            ways = 0
            for i in range(1 + total // cost1):
                left = max(total - i * cost1, 0)
                ways += 1 + left // cost2
            return ways
Atom user please
Published: 2022-06-08 22:59:24

The End of Atom
atom logo with setting sun
Today GitHub announced it will archive Atom and all projects under the
Atom organization for an official sunset on December 15, 2022.
Why?
Development on Atom has been slowing for a while now. We see the
effects of that in unresolved bugs. For example, atom/atom#25426 which
prevents installing plugins including WakaTime. The bottom line is other
editors have become more popular and the void that Atom once filled
has disappeared.
What's next?
You can continue using Atom until December 15, 2022 and some things
may still work, but consider switching as soon as possible to another
supported editor. We recommend VS Code since it will feel the most
comfortable when making the transition from Atom.
This email is also an article on the WakaTime blog and open source on
GitHub. Feel free to open a PR
Interactive Resume in Tableau
Tags: dataviz, beginners, career, design
Published: 2022-06-08 22:42:34

After ☝🏽 one week of being "Fun-employed" due to being laid off (happening a lot here lately)  I found myself super bored so...


I took the time to create an interactive resume 👇🏾 in Tableau! This was fun to create! Check it out 👏🏽 and let me know what you think and any tips to improve it!

https://public.tableau.com/shared/TDZSGZRDN?:display_count=n&:origin=viz_share_link

I downloaded my Netflix data to create another Viz (coming soon!). I will try to screen record my process but no promises. 


#tableau #projectmanagement
</Code Motivation Part1 >
Tags: devops
Published: 2022-06-08 22:38:11



>##**Motivation is a key asset to success, as long as you are motivated as long as you will make progress.**
## 

_I live a lot of journeys, ups, downs, sometimes life even forces me to want to give up. But one thing I say often: "Survivors don't back down."
I will tell you how Motivation could change my career_

Having finished my secondary studies in 2017, I opted to enter the faculty of computer science at the Caribbean University of Port au Prince. In 2019, given the phenomena of banditry, the health problems linked to the Corana virus which was raging in the capital and even more my entourage who told me to give up, I had to close my study file and return to my hometown.  

A year had just passed, I couldn't do anything, and here is another bad news, the university, my father, the only financial support I had, was no longer going to be able to help me for lack of means, I I felt helpless, especially since I could not benefit from scholarships because I did not meet the criteria, my grades were below the average required.
I then asked myself this question: **"You resist where you give up?**

 as an answer to this answer you will find it in the second part with one of the books which helped me a lot, L'autoroute du millionaire by M J Demarco.
Making a Home Theatre
Published: 2022-06-08 14:44:16

Your new home theater system could be the best investment you ever make. And we’re here to assist you in making the best decision. Staying at home and entertainment with family members is becoming increasingly enjoyable these days, and having a Home Theater is the perfect way to do so!

A fantastic movie, TV show or playoff game is a nice pull to gather all family like nothing else. Everyone wants to spend a cool and rainy Saturday night at home. The ultimate goal of any home theater should be to create an environment in which the sensory content is so realistic and presentable.

So, just suspend your disbelief for a few hours and accept what’s onscreen as reality. It could be a blockbuster film, a major sporting event, a television series, or a first-person shooter video game, but the capacity to fully immerse oneself in the experience is at the heart of a fantastic speakers for home theater.

Making a Home Theater design and installation are two different things to do. On this platform, we are helping you to get Wireless Ceiling Speakers and In-wall Speakers. The best quality DJ Speakers can convert your outdoor garden into a party environment. [Classical Bass Speakers](https://audiospeaks.com/home-theater/) are also a practical choice for classical music lovers.
MASK.CSS - Mask images and DIVs with ease
Tags: css, opensource, showdev, design
Published: 2022-06-08 22:15:13

The other day I needed some vector shapes to mask images for a theme project. First I played around intensively with the CSS property "mask-image" and then I decided to release a small library.

[DEMO](https://koehlersimon.github.io/maskcss/) | [CONTRIBUTE](https://github.com/koehlersimon/maskcss)

# What does MASK.CSS do?

MASK.CSS works in any website, and is not bound to any framework. Although it also works great with Bootstrap. You just need to include the "mask.css" file, and make sure all vector graphics are stored in the right place.

`<link rel="stylesheet" href="https://cdn.jsdelivr.net/gh/koehlersimon/maskcss@master/mask.css">`

Once you have MASK.CSS included, you can mask objects like images and containers by adding a few simple classes.

`<img class="mask mask-circle mask-repeat mask-size-10" src="img/canyon.jpg" alt="masked image">`

# Demo on Codepen

{% codepen https://codepen.io/typo3-freelancer/pen/YzeJzQy %}

# Get involved!

If you have original ideas for new vector shapes, join the [GitHub](https://github.com/koehlersimon/maskcss) project. I welcome any contributor who brings new ideas and improvements to MASK.CSS!
Array Partition I
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 22:00:46

Given an integer array `nums` of `2n` integers, group these integers into `n` pairs `(a1, b1), (a2, b2), ..., (an, bn)` such that the sum of `min(ai, bi)` for all `i` is **maximized**. Return _the maximized sum_.

**Example 1:**

**Input:** nums = \[1,4,3,2\]
**Output:** 4
**Explanation:** All possible pairings (ignoring the ordering of elements) are:
1. (1, 4), (2, 3) -> min(1, 4) + min(2, 3) = 1 + 2 = 3
2. (1, 3), (2, 4) -> min(1, 3) + min(2, 4) = 1 + 2 = 3
3. (1, 2), (3, 4) -> min(1, 2) + min(3, 4) = 1 + 3 = 4
So the maximum possible sum is 4.

**Example 2:**

**Input:** nums = \[6,2,6,5,1,2\]
**Output:** 9
**Explanation:** The optimal pairing is (2, 1), (2, 5), (6, 6). min(2, 1) + min(2, 5) + min(6, 6) = 1 + 2 + 6 = 9.

**Constraints:**

*   `1 <= n <= 104`
*   `nums.length == 2 * n`
*   `-104 <= nums[i] <= 104`

**SOLUTION:**

    class Solution:
        def arrayPairSum(self, nums: List[int]) -> int:
            nums.sort()
            n = len(nums)
            total = 0
            for i in range(0, n, 2):
                total += min(nums[i:i + 2])
            return total
What's up with the number 4?
Tags: watercooler, meta, writing
Published: 2022-06-08 21:32:05

---
title: What's up with the number 4?
published: true
description: Surprise, surprise that I just found on my email.
tags: #watercooler, #meta, #writing
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2z6ecjvabnf6cmph1w1b.png
---

This week I was checking out my email to catch up with things from the previous week. 

There was nothing out of the ordinary initially. 

But then, I found something that snapped me out of my ordinary email-checking state.

You wanna know what it was?

Well, nothing more and nothing less than a new badge in dev.to.

But not any kind of badge mind you.

It was _THIS_ badge.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/auif0n3tulem6g81ab5v.png)

Yo, that's a big, cool-looking number 4.

"_Can you believe it's been 4 years already?!_"

I couldn't believe it at first. But on further inspection, I found it's true.

It got me doing a trip down memory lane to the second half of 2018.

I remember that I had seen some posts from folks here going around. And after several of them, I ended up thinking "let's just sign up for this site right? why not?"

I didn't have very much activity on the site until August of that year when I wrote about experiences in a short coding boot-camp that I took.

The response I got was pretty positive. Initially, I was just reading/learning from posts and commenting on those, no writing on my part.

It wasn't until the beginning of 2020 that "writing" became part of my "new year resolutions".

I wrote only 2 posts before realizing "damn, this writing thing is actually hard".

Then, the pandemic struck and everything came crashing down.

In June I started writing again after a period of depression and nihilism. Writing on this platform and sharing knowledge was one of the ways I used to cope with the situation and keep moving on.

From there, I've gone to develop my writing skill…

Had writing streaks for many weeks…

Learnt a lot from tech and otherwise…

Met incredibly smart, cool, talented people…

And be part of one of the best communities for developers on the internet.

It's been quite a journey with ups and downs but definitely never a boring one.

I'm looking forward to what may come in the future and hopefully keep doing this challenging, but rewarding activity for more years to come.

So, cheers for this anniversary and another year to come.

And as always… Thanks for reading!

![Cheers](https://media.giphy.com/media/l3c5RJr6yRKyyIw00/giphy-downsized.gif)
Running Sum of 1d Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-08 21:30:40

Given an array `nums`. We define a running sum of an array as `runningSum[i] = sum(nums[0]…nums[i])`.

Return the running sum of `nums`.

**Example 1:**

**Input:** nums = \[1,2,3,4\]
**Output:** \[1,3,6,10\]
**Explanation:** Running sum is obtained as follows: \[1, 1+2, 1+2+3, 1+2+3+4\].

**Example 2:**

**Input:** nums = \[1,1,1,1,1\]
**Output:** \[1,2,3,4,5\]
**Explanation:** Running sum is obtained as follows: \[1, 1+1, 1+1+1, 1+1+1+1, 1+1+1+1+1\].

**Example 3:**

**Input:** nums = \[3,1,2,10,1\]
**Output:** \[3,4,6,16,17\]

**Constraints:**

*   `1 <= nums.length <= 1000`
*   `-10^6 <= nums[i] <= 10^6`

**SOLUTION:**

    class Solution:
        def runningSum(self, nums: List[int]) -> List[int]:
            op = [0]
            for num in nums:
                op.append(op[-1] + num)
            return op[1:]
<h1> is not rendering in all Navbar pages
Published: 2022-06-08 21:26:45

Why my h1 tag is not showing?
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0p6ryizmdjad1ptg5zop.jpeg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7rhmjmpv326e8arivsi7.jpeg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ljp1a2fj3oxvsrquwu6d.jpeg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j4qk3oh5zkoxxctvy99t.jpeg)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yel4mt4b3s2jlqi6h9kd.jpeg)