teleren/devto huggingface dataset:
Goat Latin
Tags: leetcode, dsa, theabbie
Published: 2022-06-11 15:30:40

You are given a string `sentence` that consist of words separated by spaces. Each word consists of lowercase and uppercase letters only.

We would like to convert the sentence to "Goat Latin" (a made-up language similar to Pig Latin.) The rules of Goat Latin are as follows:

*   If a word begins with a vowel (`'a'`, `'e'`, `'i'`, `'o'`, or `'u'`), append `"ma"` to the end of the word.
    *   For example, the word `"apple"` becomes `"applema"`.
*   If a word begins with a consonant (i.e., not a vowel), remove the first letter and append it to the end, then add `"ma"`.
    *   For example, the word `"goat"` becomes `"oatgma"`.
*   Add one letter `'a'` to the end of each word per its word index in the sentence, starting with `1`.
    *   For example, the first word gets `"a"` added to the end, the second word gets `"aa"` added to the end, and so on.

Return _the final sentence representing the conversion from sentence to Goat Latin_.

**Example 1:**

**Input:** sentence = "I speak Goat Latin"
**Output:** "Imaa peaksmaaa oatGmaaaa atinLmaaaaa"

**Example 2:**

**Input:** sentence = "The quick brown fox jumped over the lazy dog"
**Output:** "heTmaa uickqmaaa rownbmaaaa oxfmaaaaa umpedjmaaaaaa overmaaaaaaa hetmaaaaaaaa azylmaaaaaaaaa ogdmaaaaaaaaaa"

**Constraints:**

*   `1 <= sentence.length <= 150`
*   `sentence` consists of English letters and spaces.
*   `sentence` has no leading or trailing spaces.
*   All the words in `sentence` are separated by a single space.

**SOLUTION:**

    class Solution:
        def transform(self, word, i):
            vowels = { 'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U' }
            op = ""
            if word[0] in vowels:
                op += word + "ma"
            else:
                op += word[1:] + word[0] + "ma"
            op += "a" * i
            return op
        
        def toGoatLatin(self, sentence: str) -> str:
            words = sentence.split()
            return " ".join([self.transform(word, i+1) for i, word in enumerate(words)])
Panduan Yii 2.0
Published: 2022-06-11 15:23:28

### Installation
Membuat project bernama **projectname**
`composer create-project --prefer-dist yiisoft/yii2-app-basic    projectname`

### Menjalankan Aplikasi
`php yii serve` port defaultnya adalah 8080
`php yii serve --port=8888`

kemudian akses aplikasi di browser dengan link `http://localhost:8080/` untuk port 8080 disesuaikann
JavaScript - Hoisting
Tags: javascript, webdev, programming, beginners
Published: 2022-06-11 15:13:48

Hello everyone! 👋 Let's talk about hoisting in JS. 

## What is Hoisting in JavaScript?

The term *hoist* means to "raise (something)" and in JS it is used to describe the behaviour of JS interpreter whereby the use of classes, functions and variables before their declaration does not cause the error: `Uncaught ReferenceError: X is not defined`. This is because *hoisting* **appears** to have moved the declaration up to the top. (The variables and functions are actually saved in memory during the creation phase of the Execution Context, you can read more about it [here](https://www.freecodecamp.org/news/execution-context-how-javascript-works-behind-the-scenes/).) 

Below, I will talk about the difference between variable hoisting and function hoisting.

### Variable Hoisting

When you declare a variable, you can use `var`, `let` and `const`. Both `let` and `const` get *hoisted* but do not get initialized with a default value, this means that you can still get `ReferenceError` if you use the variables before its declaration. However, for `var`, when it gets *hoisted* it also gets initialized with a default value of `undefined` so you will not get an error.

Example:

```js
console.log(varThing); // undefined

var varThing = "testingVar";

console.log(letThing);

let letThing = "testingLet"; // Uncaught ReferenceError: Cannot access 'letThing' before initialization

```

### Function Hoisting

When a function gets *hoisted* this means that you can call/use the function safely without error, this only applies to function created with `function` keyword and not function expressions.

Example: 

```js

console.log(getRandomNumber(2, 5)); // 2

function getRandomNumber(min, max) {
  return Math.floor(Math.random() * (max - min) + min);
}

console.log(getRandom()); // Uncaught TypeError: getRandom is not a function 

var getRandom = function () {
  return Math.floor(Math.random() * 10)
}

```

In the example, you can see that the `getRandomNumber` function can be called before its declaration, this is due to *hoisting*. However, with `getRandom`, it has been hoisted as a variable, specifically with value `undefined` and so you get a `TypeError` when you try to use it as a function.

## Summary 

*Hoisting* is the term used to describe the process in which declarations of classes, functions and variables get saved in memory during the Execution Context. This allows for the program to read (use) these values before declaring them. It can cause some problems so it is good to know what kind of error it can cause but also why certain things work even before you declare them. 

It is always best to declare your classes, expression functions and variables before using them to avoid initialization errors.

Thank you for reading, leave a comment if you found it helpful or have any feedback. 😀
![Alphone from FMA](https://static.wikia.nocookie.net/fma/images/0/00/Alphonse_Elric_human.jpg/revision/latest?cb=20180630022928)
Maximum Product of Word Lengths
Tags: leetcode, dsa, theabbie
Published: 2022-06-11 15:00:44

Given a string array `words`, return _the maximum value of_ `length(word[i]) * length(word[j])` _where the two words do not share common letters_. If no such two words exist, return `0`.

**Example 1:**

**Input:** words = \["abcw","baz","foo","bar","xtfn","abcdef"\]
**Output:** 16
**Explanation:** The two words can be "abcw", "xtfn".

**Example 2:**

**Input:** words = \["a","ab","abc","d","cd","bcd","abcd"\]
**Output:** 4
**Explanation:** The two words can be "ab", "cd".

**Example 3:**

**Input:** words = \["a","aa","aaa","aaaa"\]
**Output:** 0
**Explanation:** No such pair of words.

**Constraints:**

*   `2 <= words.length <= 1000`
*   `1 <= words[i].length <= 1000`
*   `words[i]` consists only of lowercase English letters.

**SOLUTION:**

    class Solution:
        def maxProduct(self, words: List[str]) -> int:
            n = len(words)
            lens = [len(word) for word in words]
            words = [set(word) for word in words]
            mprod = 0
            for i in range(n):
                for j in range(n):
                    if i != j:
                        if len(set.intersection(words[i], words[j])) == 0:
                            mprod = max(mprod, lens[i] * lens[j])
            return mprod
Paracetamol.js💊| #139: Explica este código JavaScript
Tags: javascript, spanish, programming, webdev
Published: 2022-06-11 14:52:57

## **<center>Explica el siguiente código JavaScript</center>**
#### <center>**Dificultad:** <mark>Intermedio</mark></center>

```js
console.log([..."555"])
console.log([...555])
```

A. `[ 5,5,5 ]`, `Uncaught TypeError: 555 is not iterable`
B. `[ 555 ]`, `Uncaught TypeError: 555 is not iterable`
C. `[ 5,5,5 ]`, `[ 5,5,5 ]`
D. `555`, `555`

Respuesta en el primer comentario.

---
Increasing Subsequences
Tags: leetcode, dsa, theabbie
Published: 2022-06-11 14:30:39

Given an integer array `nums`, return all the different possible increasing subsequences of the given array with **at least two elements**. You may return the answer in **any order**.

The given array may contain duplicates, and two equal integers should also be considered a special case of increasing sequence.

**Example 1:**

**Input:** nums = \[4,6,7,7\]
**Output:** \[\[4,6\],\[4,6,7\],\[4,6,7,7\],\[4,7\],\[4,7,7\],\[6,7\],\[6,7,7\],\[7,7\]\]

**Example 2:**

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

**Constraints:**

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

**SOLUTION:**

    class Solution:
        def getSeq(self, nums, i, n):
            if i >= n:
                return [[]]
            op = []
            used = set()
            for j in range(i + 1, n):
                if nums[j] >= nums[i] and nums[j] not in used:
                    val = self.getSeq(nums, j, n)
                    op += [[nums[i], nums[j]]]
                    op += [[nums[i]] + v for v in val]
                    used.add(nums[j])
            return op
        
        def findSubsequences(self, nums: List[int]) -> List[List[int]]:
            n = len(nums)
            op = []
            used = set()
            for i in range(n):
                if nums[i] not in used:
                    op += self.getSeq(nums, i, n)
                    used.add(nums[i])
            return op
How to Become a Freelance Content Writer in India
Tags: webdev, javascript, beginners, programming
Published: 2022-06-11 14:23:28

There are a few things you can [How to become a freelance content writer in India](https://www.ravi-gupta.com/). 

First, start by building up your portfolio of writing samples. This can be anything from articles you've written for school projects or blogs, to marketing materials or website content.

Once you have a strong portfolio, start networking with other writers and editors. Attend writer's conferences and workshops, join writing groups on social media, and reach out to editors at online publications and magazines. 

Finally, start [pitching](https://community.codenewbie.org/raviguptaseoexprt/how-become-a-freelance-content-writer-in-india-1nk) your services to potential clients and build up a client base. The more experience and clients you have, the better your chances of finding regular work as a freelance content writer.

Bluehost is a well-known provider of best [WordPress hosting in australia](https://www.ravi-gupta.com/best-wordpress-hosting-in-australia/) and for good reason. They offer a range of features that are perfect for small businesses and bloggers alike. These include automatic WordPress updates, daily backups, malware scanning, and more. Best of all, Bluehost is affordable and easy to use.

Hi, am [Ravi Gupta ](https://www.ravi-gupta.com/)a professional SEO Specialist, the Affiliate marketer & Entrepreneur.  I have started this blog so that you can get the latest updated and informative news of SEO updates and trends, articles about affiliate marketing, and much more interesting stuff.



![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xlj67spskw27ynhgkm7t.jpg)
Day 14 - Mappings
Tags: 100daysofcode, solidity, web3, blockchain
Published: 2022-06-11 13:45:00

{% embed https://github.com/Envoy-VC/30-Days-of-Solidity noreadme %}

This is Day `14` of `30` in Solidity Series
Today I Learned About Mappings in Solidity.

Mapping in Solidity acts like a hash table or dictionary in any other language. These are used to store the data in the form of key-value pairs, a key can be any of the built-in data types but reference types are not allowed while the value can be of any type. Mappings are mostly used to associate the unique Ethereum address with the associated value type.

**Syntax:**
```solidity
mapping(key => value) <access specifier> <name>;
```
Example:
```solidity
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.7;

contract Mappings {
    struct Student {
        string name;
        string subject;
        uint marks;
    }

    mapping(address => Student) public addressToStudent;
    Student student1;

    function addDetails() public {
        student1 = Student("Daniel","Maths",85);
        addressToStudent[0x5B38Da6a701c568545dCfcB03FcB875f56beddC4] = student1;
    }
}
```

Here we map a `address` to a `Student` struct.and the function `addDetails` adds the details of the student to struct student1 and then maps it to address 0x5B38Da6a701c568545dCfcB03FcB875f56beddC4.

Output when we pass the above address in addressToStudent mapping:
```solidity
{
	"0": "string: name Daniel",
	"1": "string: subject Maths",
	"2": "uint256: marks 85"
}
```

---
The danger of juggling numerous OpenSource projects and the danger of retweets
Tags: opensource, twitter, marketing, lifehacks
Published: 2022-06-11 14:19:21

#OpenSource and Twitter is an amazing combination, which can really help you to help the community and grow into a key person in the world of IT.



However, like with anything else, even #OpenSource and Twitter can be used in a wrong way, in terms of stealing your time with a very limited result.



I am worried about people wasting their time while they think they actually follow my advice.



Therefore I have created this video, I hope it helps :)

{% embed https://www.youtube.com/watch?v=uwZHVaDEehY %}
Maximum Length of Repeated Subarray
Tags: leetcode, dsa, theabbie
Published: 2022-06-11 14:00:54

Given two integer arrays `nums1` and `nums2`, return _the maximum length of a subarray that appears in **both** arrays_.

**Example 1:**

**Input:** nums1 = \[1,2,3,2,1\], nums2 = \[3,2,1,4,7\]
**Output:** 3
**Explanation:** The repeated subarray with maximum length is \[3,2,1\].

**Example 2:**

**Input:** nums1 = \[0,0,0,0,0\], nums2 = \[0,0,0,0,0\]
**Output:** 5

**Constraints:**

*   `1 <= nums1.length, nums2.length <= 1000`
*   `0 <= nums1[i], nums2[i] <= 100`

**SOLUTION:**

    class Solution:
        def LongestCommonSubarray(self, X, Y, m, n):
            common = [[0 for k in range(n+1)] for l in range(m+1)]
            result = 0
            for i in range(m + 1):
                for j in range(n + 1):
                    if (i == 0 or j == 0):
                        common[i][j] = 0
                    elif (X[i-1] == Y[j-1]):
                        common[i][j] = common[i-1][j-1] + 1
                        result = max(result, common[i][j])
                    else:
                        common[i][j] = 0
            return result
        
        def findLength(self, nums1: List[int], nums2: List[int]) -> int:
            return self.LongestCommonSubarray(nums1, nums2, len(nums1), len(nums2))
Docker series (Part 8): Images from Docker Hub
Tags: docker
Published: 2022-06-09 17:00:03

You can go to this webpage: https://hub.docker.com
and create your account. Now, search for nginx

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

You may find this. 

 ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g1znz1981sbxqvvyz6q0.png)
Look at these..these are all tags. so, you need to be sure while pulling any image. Need to be sure which image you want to pull. Here 1.21.6 & latest means the same tag.
You can see your own system.

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

You have images which have the tag "latest".
this latest is the latest version too. but to install any particular image, you can follow this format.

```
docker pull <image>:<image version>
```
for example,
docker pull nginx:1.11.9

Official image lists are added here: https://github.com/docker-library/official-images/tree/master/library

**What is this image?**
Images are basically layers after layers.
if you check your nginx:latest ones history

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gxeiets3ss8pfjdnlgq3.png)
You can see that there are layers after layer changes and the last change came 3 weeks back.

Assume that, we have an image of ubuntu. It has just 1 layer now

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fh9a4y99g7tn61cpsy5a.png)
Adding 1 more layer over it

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rw51xoy0s9pjj2h4sbu9.png)
Also, another image may have these layers

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

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

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

So, these are the basics of image
Construct the Rectangle
Tags: leetcode, dsa, theabbie
Published: 2022-06-11 13:30:39

A web developer needs to know how to design a web page's size. So, given a specific rectangular web page’s area, your job by now is to design a rectangular web page, whose length L and width W satisfy the following requirements:

1.  The area of the rectangular web page you designed must equal to the given target area.
2.  The width `W` should not be larger than the length `L`, which means `L >= W`.
3.  The difference between length `L` and width `W` should be as small as possible.

Return _an array `[L, W]` where `L` and `W` are the length and width of the web page you designed in sequence._

**Example 1:**

**Input:** area = 4
**Output:** \[2,2\]
**Explanation:** The target area is 4, and all the possible ways to construct it are \[1,4\], \[2,2\], \[4,1\]. 
But according to requirement 2, \[1,4\] is illegal; according to requirement 3,  \[4,1\] is not optimal compared to \[2,2\]. So the length L is 2, and the width W is 2.

**Example 2:**

**Input:** area = 37
**Output:** \[37,1\]

**Example 3:**

**Input:** area = 122122
**Output:** \[427,286\]

**Constraints:**

*   `1 <= area <= 107`

**SOLUTION:**

    class Solution:
        def constructRectangle(self, area: int) -> List[int]:
            i = 1
            minDiffBox = 1
            while i * i <= area:
                if area % i == 0:
                    minDiffBox = i
                i += 1
            return [area // minDiffBox, minDiffBox]
NestJS - Providers
Published: 2022-06-11 13:09:17

In the **MVP** in additional **View** and **Controller**, there are also **Model**. **Model** contain main and additional logic, and also contain logic for working with DB and third-party APIs. In NestJS, this function is assigned to **Providers**.

**Providers** in NestJS are registered in Modules they belong to. And also can be exported from the Module to be available in other parts of the application.

```
import { Module } from '@nestjs/common';

import { ProductsService } from './products.service';
import { ProductsController } from './products.controller';

@Module({
  controllers: [ProductsController],
  providers: [ProductsService],
})
export class ProductsModule {}
```

One of the features of a provider is that the provider is injected, for example, into the controller's constructor for further application work.

```
import { Controller, Get } from '@nestjs/common';

import { ProductsService } from './products.service';

@Controller('products')
export class ProductController {
  constructor(private productsService: ProductsService) {}

  @Get()
  getAllProducts(): Product[] {
    // Code...
    return this.productsService.getAll();
  }
}
```

Providers are ES6 classes wrapped with the @Injectable() decorator, which is imported from '@nestjs/common'.

The provider can be created using the CLI command

`nest g service products`

```
import { Injectable } from '@nestjs/common';

import { Product } from './interfaces/product.interface';

@Injectable()
export class ProductsService {
  private readonly products: Product[] = [];

  getAll(): Product[] {
    // Some code...
    return this.products;
  }

  create(product: Product) {
    // Your Code...
  }

  update(id: number) {
     // Some code...
  }

  // Other methods...
}
```

Thus, the **Module** is a separate part of the application with isolated logic. **Controller** - the entry point to this Module, which is called when a request is received for a specific URL and calls the methods of the Provider. And the **Provider** contains all the main and additional business logic necessary for the application to function.

Thanks for your attention!
How to scan and get visibility and reporting on RBAC in your clusters with default security rules
Published: 2022-06-11 13:06:10

Krane is a simple Kubernetes RBAC static analysis tool. It identifies potential security risks in K8s RBAC design and makes suggestions on how to mitigate them. Krane dashboard presents current RBAC security posture and lets you navigate through its definition.

Appvia Slack community: appvia-community.slack.com/
GitHub: github.com/appvia/krane

{% embed https://youtu.be/eyrC1iCeKc0 %}
How we do self-service cloud resources: Terranetes / AWS
Tags: terraform, aws, cloudskills
Published: 2022-06-11 13:03:09

Terranetes unblocks developers by allowing them to self-serve cloud resources through terraform with a Kubernetes terraform controller. Get apps to market securely and more quickly with open-source Terranetes. Get the code on GitHub. https://github.com/appvia/terranetes

{% embed https://youtu.be/MV4QEjP3YM4 %}
Masala
Tags: masala, cpp, uzbek, programming
Published: 2022-06-11 13:02:11

**N1-->**
Ikki nuqta orasidagi masofani hisoblab beradigan funksiya tuzing.
- nomi: `distance`
- parametrlari: int aX, int aY, int bX, int bY
- qaytarishi: shu ikki nuqta orasidagi masofani *float* sifatida qaytaradi.
Answer:
```cpp
#include <iostream>
#include <cmath>

using namespace std;

  float distance(int aX, int aY, int bX, int bY)
{
  int a= aY - bY;
  int b= aX - bY;

  int cKvadrat = a*a + b*b;

  int c = sqrt(cKvadrat); //square root

  return c;
  //return sqrt(pow(aY - bY,2)+ pow(aX - bY,2))
}

int main() 
{
  cout << distance(5,6,2,2);
 return 0;
}
```
**N2-->**
Berilgan nuqta aylana ichidami yo'qmi aniqlaydigan funksiya tuzing.
- nomi: pointIsInCircle
- parametrlar:
 - aylana markazini anglatuvchi int cX, int cY
 - aylana radiusini anglatuvchi int cRadius
 - nuqta koordinasini anglatuvchi int pX, int pY
- qaytarishi: berilgan nuqta aylana ichida bo'lsa `true` yo'qsa `false` qaytaradi. 
- `yuqorida yaratilgan distance funksiyasidan foydalaning.`

Answer:
```cpp
#include <iostream>
#include <cmath>

using namespace std;
float distance(int aX, int aY, int bX, int bY)
{
  int a= aY - bY;
  int b= aX - bY;

  int cKvadrat = a*a + b*b;

  int c = sqrt(cKvadrat); //square root

  return c;
  //return sqrt(pow(aY - bY,2)+ pow(aX - bY,2))
}
bool pointIsInCircle(int cX, int cY, int cRadius, int pX, int pY)
{
  return distance(cX, cY, pX, pY) < cRadius;
}

int main() 
{
  cout << pointIsInCircle(3,3,2,5,5) << endl;
 return 0;
}
```