teleren/devto huggingface dataset:
Find the K-Beauty of a Number
Tags: leetcode, dsa, theabbie
Published: 2022-06-18 09:00:42

The **k-beauty** of an integer `num` is defined as the number of **substrings** of `num` when it is read as a string that meet the following conditions:

*   It has a length of `k`.
*   It is a divisor of `num`.

Given integers `num` and `k`, return _the k-beauty of_ `num`.

Note:

*   **Leading zeros** are allowed.
*   `0` is not a divisor of any value.

A **substring** is a contiguous sequence of characters in a string.

**Example 1:**

**Input:** num = 240, k = 2
**Output:** 2
**Explanation:** The following are the substrings of num of length k:
- "24" from "**24**0": 24 is a divisor of 240.
- "40" from "2**40**": 40 is a divisor of 240.
Therefore, the k-beauty is 2.

**Example 2:**

**Input:** num = 430043, k = 2
**Output:** 2
**Explanation:** The following are the substrings of num of length k:
- "43" from "**43**0043": 43 is a divisor of 430043.
- "30" from "4**30**043": 30 is not a divisor of 430043.
- "00" from "43**00**43": 0 is not a divisor of 430043.
- "04" from "430**04**3": 4 is not a divisor of 430043.
- "43" from "4300**43**": 43 is a divisor of 430043.
Therefore, the k-beauty is 2.

**Constraints:**

*   `1 <= num <= 109`
*   `1 <= k <= num.length` (taking `num` as a string)

**SOLUTION:**

    class Solution:
        def divisorSubstrings(self, num: int, k: int) -> int:
            strnum = str(num)
            n = len(strnum)
            ctr = 0
            for i in range(n - k + 1):
                curr = int(strnum[i:i+k])
                if curr != 0 and num % curr == 0:
                    ctr += 1
            return ctr
Umbraco 10 - Razor Class Library Packages Pt1
Tags: umbraco
Published: 2022-06-18 08:55:37

# Introduction 

> *This is a blazingly fast intro to package targets, razor class libraries and static web assets, if you know what they are skip over to part 2 - where we do something with them*

Ever since i saw [Jason Elkin's amazing talk on Razor class libraries at Umbraco Together confrence](https://www.youtube.com/watch?v=Pxs5YNiKG4s), I've been itching to see how far we can take Razor class libraries and Umbraco packages. 

---

### This post is part of a series: 
- Part 1 : Intro to Razor class library packages in Umbraco (this)
- [Part 2 : Creating an Umbraco Razor class library package](https://dev.to/kevinjump/umbraco-10-razor-class-library-packages-pt2-58an)
- [Part 3: Converting an exiting Umbraco package](https://dev.to/kevinjump/umbraco-10-razor-class-library-packages-pt3-40bb)
- [Part 4: Things I now do differently] (https://dev.to/kevinjump/umbraco-razor-class-library-packages-pt4-15f4) 🌟 New 🌟


---

## Package .targets files. 

At the moment when you develop an Umbraco package for Umbraco 9/10 you have to make sure you have a well formatted `packagename.targets` file in your package that copied all of your app_plugins files into the right place when a developer builds or publishes your package. 

this on the whole is ok and it works, but its no ideal, it has some side effects and it can be confusing; 

* You are writing files into the sites project with little or no say from the dev.
* The files get mysteriously wiped or overwritten when a clean build or rebuild is done.
* Get the target's wrong and you could easily loose a day figuring it out. 

## Razor class libraries

[Razor class libraries](https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-6.0&tabs=visual-studio) have been developed mainly as a way of embedding razor views (and blazor etc) files into a dll so they can be packaged and used on a site without additional files floating around, and even just for this they are really cool. 

### Static web assets 

Razor class libraries also contain another trick called [static web assets](https://docs.microsoft.com/en-us/aspnet/core/razor-pages/ui-class?view=aspnetcore-6.0&tabs=visual-studio#create-an-rcl-with-static-assets-1). which let you embed any old file into your nuget package and get them consumed by the website that it is installed on. 

with Static web assets you get a number of things: 
-  the files appear in the web project without actually being in the project (for development they are served from the nuget cache)
- the files are put in the right place at publication time (with a dotnet publish)
- the files can be overwritten by putting 'real' files in the locations they exit. 

_internally static web assets are actually using targets files, but those files are generated and managed by the build process so you don't have to worry about them_
Match Substring After Replacement
Tags: leetcode, dsa, theabbie
Published: 2022-06-18 08:30:40

You are given two strings `s` and `sub`. You are also given a 2D character array `mappings` where `mappings[i] = [oldi, newi]` indicates that you may **replace** any number of `oldi` characters of `sub` with `newi`. Each character in `sub` **cannot** be replaced more than once.

Return `true` _if it is possible to make_ `sub` _a substring of_ `s` _by replacing zero or more characters according to_ `mappings`. Otherwise, return `false`.

A **substring** is a contiguous non-empty sequence of characters within a string.

**Example 1:**

**Input:** s = "fool3e7bar", sub = "leet", mappings = \[\["e","3"\],\["t","7"\],\["t","8"\]\]
**Output:** true
**Explanation:** Replace the first 'e' in sub with '3' and 't' in sub with '7'.
Now sub = "l3e7" is a substring of s, so we return true.

**Example 2:**

**Input:** s = "fooleetbar", sub = "f00l", mappings = \[\["o","0"\]\]
**Output:** false
**Explanation:** The string "f00l" is not a substring of s and no replacements can be made.
Note that we cannot replace '0' with 'o'.

**Example 3:**

**Input:** s = "Fool33tbaR", sub = "leetd", mappings = \[\["e","3"\],\["t","7"\],\["t","8"\],\["d","b"\],\["p","b"\]\]
**Output:** true
**Explanation:** Replace the first and second 'e' in sub with '3' and 'd' in sub with 'b'.
Now sub = "l33tb" is a substring of s, so we return true.

**Constraints:**

*   `1 <= sub.length <= s.length <= 5000`
*   `0 <= mappings.length <= 1000`
*   `mappings[i].length == 2`
*   `oldi != newi`
*   `s` and `sub` consist of uppercase and lowercase English letters and digits.
*   `oldi` and `newi` are either uppercase or lowercase English letters or digits.

**SOLUTION:**

    from collections import defaultdict
    import re
    
    class Solution:
        def matchReplacement(self, s: str, sub: str, mappings: List[List[str]]) -> bool:
            reachable = defaultdict(set)
            for a, b in mappings:
                reachable[a].add(b)
            for c in sub:
                reachable[c].add(c)
            regex = ""
            for c in sub:
                if len(reachable[c]) > 1:
                    regex += "("
                    regex += "|".join(reachable[c])
                    regex += ")"
                else:
                    regex += c
            return re.compile(regex).search(s)
How to Publish Website on Internet Free | How to Host a Website on Internet for Free
Tags: devops, webdev, hosting, htmlcss
Published: 2022-06-18 08:24:44


In this Post I will show you How to Publish Website on Internet Free of cost. if you want to run a test website, you’re not expecting much of it, and you don’t want to invest any money in the project at all, then free website hosting might indeed work for you! 

## Full Tutorial Watch:

{% youtube XY1XET-B5Ok %}

There are many online sites which provide free webhosting services for your website project.
 Just keep in mind that There are some limitations of free website hosting service. 

For example: Free hosting providers may place restrictions on storage space and bandwidth, limiting your site’s growth and traffic capacity . Your personal website or business website may also have slow performance. There is a site named 000WebHost.com is a free web hosting platform where you can host your website for free.

## How to create single page website (Source Code):
 
{% youtube KDaGjYQTDF0 %}

how to host an HTML website on Liver server for free,
how to upload webpage on internet free 000webhost,
how to launch html website on internet free,
how to publish html website on internet free in hindi,
how to upload your website on internet for free,
how to host a website free on github,
how to host a website on google for free,
how to host a website for free in 000webhost,
how to host a wordpress website for free,
how to host a free website with infinityfree,
how to host a static website for free,
how to host a website for free code with harry,
how to host a html website for free in hindi,
how to host a html website free,
how to host a react website for free,
how to host java web application free,
how to host a web application for free,
how to host an html website for free,
how to host asp.net website for free,
how to free hosting website bangla,
how to host a website free easy,
how to host a website free episodes,
how to host a website free english,
how to upload a website on internet for free,
upload website on internet browser,
how can i upload my website on internet free,
upload website to internet,
upload website on internet for free,
XOR Operation in an Array
Tags: leetcode, dsa, theabbie
Published: 2022-06-18 08:00:40

You are given an integer `n` and an integer `start`.

Define an array `nums` where `nums[i] = start + 2 * i` (**0-indexed**) and `n == nums.length`.

Return _the bitwise XOR of all elements of_ `nums`.

**Example 1:**

**Input:** n = 5, start = 0
**Output:** 8
**Explanation:** Array nums is equal to \[0, 2, 4, 6, 8\] where (0 ^ 2 ^ 4 ^ 6 ^ 8) = 8.
Where "^" corresponds to bitwise XOR operator.

**Example 2:**

**Input:** n = 4, start = 3
**Output:** 8
**Explanation:** Array nums is equal to \[3, 5, 7, 9\] where (3 ^ 5 ^ 7 ^ 9) = 8.

**Constraints:**

*   `1 <= n <= 1000`
*   `0 <= start <= 1000`
*   `n == nums.length`

**SOLUTION:**

    class Solution:
        def xorOperation(self, n: int, start: int) -> int:
            op = start
            for i in range(1, n):
                op = op ^ (start + 2 * i)
            return op
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes, watercooler
Published: 2022-06-18 08:00:09

---
title: "A Quick 10-Second Programming Joke For Today"
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/5e1259d077252.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:___ Which programming language is the shortest?

___A:___ HTML. Because it doesn't have a neck between its `<head>` and `<body>`.
 -->
Search Insert Position
Tags: leetcode, dsa, theabbie
Published: 2022-06-18 07:30:38

Given a sorted array of distinct integers and a target value, return the index if the target is found. If not, return the index where it would be if it were inserted in order.

You must write an algorithm with `O(log n)` runtime complexity.

**Example 1:**

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

**Example 2:**

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

**Example 3:**

**Input:** nums = \[1,3,5,6\], target = 7
**Output:** 4

**Constraints:**

*   `1 <= nums.length <= 104`
*   `-104 <= nums[i] <= 104`
*   `nums` contains **distinct** values sorted in **ascending** order.
*   `-104 <= target <= 104`

**SOLUTION:**

    import bisect
    
    class Solution:
        def searchInsert(self, nums: List[int], target: int) -> int:
            return bisect.bisect_left(nums, target)
This week’s newsletter is out! (18-06-2022) - Swimming against the current
Tags: javascript, tech, webdev, discuss
Published: 2022-06-18 07:01:50

---
title: This week’s newsletter is out! (18-06-2022) - Swimming against the current
published: true
description: Another week of great javascript, tech and web development links.
tags: javascript, tech, webdev, discuss
---

Swimming against the current

https://markjgsmith.substack.com/p/mark-smiths-newsletter-18-06-2022?s=w

Would love to hear any comments and feedback you have.

[@markjgsmith](https://twitter.com/markjgsmith)
Integer Replacement
Tags: leetcode, dsa, theabbie
Published: 2022-06-18 07:00:43

Given a positive integer `n`, you can apply one of the following operations:

1.  If `n` is even, replace `n` with `n / 2`.
2.  If `n` is odd, replace `n` with either `n + 1` or `n - 1`.

Return _the minimum number of operations needed for_ `n` _to become_ `1`.

**Example 1:**

**Input:** n = 8
**Output:** 3
**Explanation:** 8 -> 4 -> 2 -> 1

**Example 2:**

**Input:** n = 7
**Output:** 4
**Explanation:** 7 -> 8 -> 4 -> 2 -> 1
or 7 -> 6 -> 3 -> 2 -> 1

**Example 3:**

**Input:** n = 4
**Output:** 2

**Constraints:**

*   `1 <= n <= 231 - 1`

**SOLUTION:**

    class Solution:
        def integerReplacement(self, n: int) -> int:
            if n == 1:
                return 0
            if n == 3:
                return 2
            if n & 1:
                if (n + 1) & 3 == 0:
                    return 3 + self.integerReplacement((n + 1) >> 2)
                else:
                    return 2 + self.integerReplacement((n - 1) >> 1)
            else:
                return 1 + self.integerReplacement(n >> 1)
How I moved to hashnode?
Tags: webdev, showdev, portfolio, programming
Published: 2022-06-18 06:16:53

I moved my blog from dev.to to hashnode.

Hashnode has amazing feature that blew my mind like:

* I own my content and all traffic goes to me.

* I can add my own domain later.

* I can have static pages like about, projects, etc.. so it's like a portfolio and blog all in one.

* Free In-built newsletter.

* Custom page rules for creating customized URLs or redirects.

* I can enable listen to audio feature.

* I can show views count on my articles.

So, I transferred my articles from there using the hashnode dev.to importer and updated my articles on dev.to to have a canonical url to refer to my hashnode articles so my hashnode articles can be ranked higher in search engines.

Now if I want to cross post to dev.to I can use the [RSS feed importer from dev.to](https://dev.to/settings/extensions) and mark my hashnode to be the canonical url.

So, you can subscribe to my newsletter in my hasnode blog here:
[amrelmohamady.hashnode.dev](https://amrelmohamady.hashnode.dev/)
Meu primeiro post
Tags: beginners, programming, webdev
Published: 2022-06-18 06:14:55

Este é meu primeiro post de teste.

> Aqui é um texto de citação

`aqui um inline code`

```js
const div = document.createElement('div');
div.innerHtml = 'Aqui é um bloco de código'
document.body.appendChild(div)
```
---
```jsx
import React from 'react';
import { fn } from "fn";

export const Component = () => {
    // Aqui um comentário
    return (
        <h1>Here is a title</h1>
    );
}
```

[Aqui um link](https://jeanmolossi.com.br/blog)

**Aqui um texto em negrito**

_Aqui um em itálico_

* Aqui
* uma
* lista

1. Aqui
2. outra
3. lista

<u>Texto sublinhado</u>

~~Texto com strike~~

---

Depois de um divisor

![A bigger image of twitter stock with elon musk](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yzy6dohq6fy5st7z1ayj.png)
Convert Integer to the Sum of Two No-Zero Integers
Tags: leetcode, dsa, theabbie
Published: 2022-06-18 06:00:44

**No-Zero integer** is a positive integer that **does not contain any `0`** in its decimal representation.

Given an integer `n`, return _a list of two integers_ `[A, B]` _where_:

*   `A` and `B` are **No-Zero integers**.
*   `A + B = n`

The test cases are generated so that there is at least one valid solution. If there are many valid solutions you can return any of them.

**Example 1:**

**Input:** n = 2
**Output:** \[1,1\]
**Explanation:** A = 1, B = 1. A + B = n and both A and B do not contain any 0 in their decimal representation.

**Example 2:**

**Input:** n = 11
**Output:** \[2,9\]

**Constraints:**

*   `2 <= n <= 104`

**SOLUTION:**

    class Solution:
        def getNoZeroIntegers(self, n: int) -> List[int]:
            for a in range(1, n):
                if "0" not in str(a) and "0" not in str(n - a):
                    return [a, n - a]
Java @Annotations
Tags: java
Published: 2022-06-27 04:30:37

---
title: Java @Annotations
published: true
date: 2022-06-18 06:00:00 UTC
tags: java,java
canonical_url: https://jsedano.dev/java/2022/06/18/java-annotations.html
---

If you have been using Java for about a week (probably even less) chances are you have already seen some annotations. Let’s review some stuff about them.

As explained on [https://docs.oracle.com/javase/tutorial/java/annotations/](%5Bhttps://docs.oracle.com/javase/tutorial/java/annotations/%5D) we can use annotations to:

- **Give information to the compiler** : so we can detect errors or even suppress warnings.
- **Compile-time and deployment-time processing** : we can generate code, xml files and so on.
- **Runtime processing** : some annotations can be reviewed at runtime (using reflection).

Annotations can be used anywhere you use a type.

One interesting fact is that annotations can potentially generate code, but they **can not modify it**. If you use tools like [lombok](%5Bhttps://projectlombok.org%5D) you know that they actually modify the code, but they usually achieve this by accessing internal libraries.

Annotations are defined with the **@interface** keyword like so:

```
public @interface Version {
  int mayor();
  int minor();
}
```

They can receive any primitive types, enums, other annotations and arrays of those previously mentioned. Let’s define an enum:

```
public enum Usage {
  UTILITY,
  DTO,
  DAO,
  SERVICE
}
```

Then let’s create another annotation:

```
public @interface Info {
  String[] authors();
  Usage usage();
  Version version();
}
```

Now we use it:

```
@Info(
    authors = {"jsedano", "weirderror"},
    usage = Usage.UTILITY,
    version = @Version(mayor = 1, minor = 0))
public class VeryUtil {}
```

You can specify if the annotation needs to be retained by the virtual machine at run time or not; or even if they are to be discarded by the compiler. This is achieved by using a `meta-annotation`, meta-annotations are annotations that are applied to another annotations.

You can also define where the annotation can be used, for example in methods, in constructors and so on.

Let’s look at how the **@Override** annotation is defined (@Override is a predefined annotation that is use to mark methods that are using method overriding):

```
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.SOURCE)
public @interface Override {
}
```

As you can see the meta-annotation **@Target** is used to say that this particular annotation can only be used above a method declaration and the **@Retention** annotation is saying that this annotation will not be recorded in the class file and will not be available at runtime.

In order to actually define functionality for an annotation type we need to implement an [AbstractProcessor](https://dev.to/jsedano/a-custom-annotation-to-apply-currying-in-java-1l68).
Generics function as an argument of another function
Tags: go, generic
Published: 2022-06-18 05:57:03



```

type genericType Interface{
 type1 | type2 | type3
}
type genericFn[T genericType](req, resp T) T

func test[T genericType](fn genericFn[T]) {}

```

appreciate guys do me a big favor.
I am wondering how to pass a function supporting generictype as an argument to another function?

I got problems when I passed a parameter with type1 among the genericType, then compiler told me type1 is not the type of genericType. 

As I passed a function implemented genericFn, I cannot passed any argument in it. 

does anybody know what’s going on or willing to share some use case?

thanks a lot !
Install Playwright in a few mins
Tags: javascript, playwright, automation, beginners
Published: 2022-06-18 05:53:26

Getting started with Playwright

What is Playwright?
Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox, and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable, and fast.

For detail how we do set-up see the blog

https://kailash-pathak.medium.com/getting-started-with-playwright-67a6eac64a21
Path Sum II
Tags: leetcode, dsa, theabbie
Published: 2022-06-18 05:30:37

Given the `root` of a binary tree and an integer `targetSum`, return _all **root-to-leaf** paths where the sum of the node values in the path equals_ `targetSum`_. Each path should be returned as a list of the node **values**, not node references_.

A **root-to-leaf** path is a path starting from the root and ending at any leaf node. A **leaf** is a node with no children.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/01/18/pathsumii1.jpg)

**Input:** root = \[5,4,8,11,null,13,4,7,2,null,null,5,1\], targetSum = 22
**Output:** \[\[5,4,11,2\],\[5,8,4,5\]\]
**Explanation:** There are two paths whose sum equals targetSum:
5 + 4 + 11 + 2 = 22
5 + 8 + 4 + 5 = 22

**Example 2:**

![](https://assets.leetcode.com/uploads/2021/01/18/pathsum2.jpg)

**Input:** root = \[1,2,3\], targetSum = 5
**Output:** \[\]

**Example 3:**

**Input:** root = \[1,2\], targetSum = 0
**Output:** \[\]

**Constraints:**

*   The number of nodes in the tree is in the range `[0, 5000]`.
*   `-1000 <= Node.val <= 1000`
*   `-1000 <= targetSum <= 1000`

**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 pathSum(self, root: Optional[TreeNode], targetSum: int) -> List[List[int]]:
            paths = [(root, [root.val] if root else 0)]
            i = 0
            op = []
            while i < len(paths):
                curr, val = paths[i]
                if curr:
                    if not curr.left and not curr.right:
                        if sum(val) == targetSum:
                            op.append(val)
                    if curr.left:
                        paths.append((curr.left, val + [curr.left.val]))
                    if curr.right:
                        paths.append((curr.right, val + [curr.right.val]))
                i += 1
            return op