teleren/devto huggingface dataset:
How to Run Emulator Outside Android Studio
Tags: python, django, webdev, programming
Published: 2023-02-04 05:44:36

Watch the following [tutorial](https://youtu.be/ZHFJOcLpjrs) to run your android emulator outside android studio.
You can then use the emulator with another application such as visual studio code, or even the terminal when hacking i.e. if you are in a hacking environment such as Kali linux and Parrot OS.

https://youtu.be/ZHFJOcLpjrs
Git Rebase
Tags: git, webdev, programming, beginners
Published: 2023-02-04 05:13:51

Git rebase is a powerful command that allows you to reapply your changes on top of another branch. This can be useful for cleaning up your Git history, resolving conflicts, and synchronizing your branch with the upstream branch. In this article, we will look at how to use the Git rebase command with an example.

**What is Git rebase:**
Git rebase is a command that allows you to reapply your changes on top of another branch. When you run the Git rebase command, Git will take your branch and reapply each commit one by one on top of the target branch. This results in a linear Git history, where all the changes are in a single sequence.

**Example:**
Let's look at an example to see how Git rebase works. In this example, we have two branches: feature and master. The feature branch has three commits, and the master branch has two commits.

```
A - B - C (feature)
 \
  D - E (master)
```

We want to rebase the feature branch on top of the master branch, so that our Git history looks like this:

```
A - B - C (feature)
          \
           D - E (master)
```

To do this, we run the following command:

```
$ git checkout feature
$ git rebase master
```

**Explanation:**
In this example, we first checked out the feature branch with the git checkout command. Then, we ran the git rebase command, passing in the master branch as the target branch.

Git then reapplied each commit in the feature branch one by one on top of the master branch. Since there were no conflicts, the rebase was successful, and the feature branch now has the latest changes from the master branch.

**Conclusion:**
The Git rebase command is a powerful tool for cleaning up your Git history and resolving conflicts. In this article, we looked at an example of how to use the Git rebase command to reapply your changes on top of another branch. If you have any questions or would like to learn more about Git rebase, feel free to ask in the comments below.
LeetCode #141 Linked List Cycle with JavaScript
Tags: javascript, algorithms, leetcode
Published: 2023-02-04 05:04:21

Solutions to LeetCode's [141. Linked List Cycle] (https://leetcode.com/problems/linked-list-cycle) with JavaScript.

Solution 2 also addresses the following follow-up.
**Follow up: Can you solve it using O(1) (i.e. constant) memory?**

## Solution 1
```js
/**
 * @param {ListNode} head
 * @return {boolean}
 */
const hasCycle1 = (head) => {
  const list = [];
  while (head) {
    if (list.includes(head.val)) return true;
    list.push(head.val);
    head = head.next;
  }
  return false;
};
```
- Time complexity: O(n)
- Space complexity: O(n)

Space complexity is O(n), so change to address follow-up.

## Solution 2
```js
/**
 * @param {ListNode} head
 * @return {boolean}
 */
const hasCycle = (head) => {
  let fast = head;
  let slow = head;
  while (fast && fast.next) {
    fast = fast.next.next;
    slow = slow.next;
    if (fast == slow) return true;
  }
  return false;
};
```
- Time complexity: O(n)
- Space complexity: O(1)

fast is 2 steps at a time, slow is 1 step at a time, and the list is put in a while loop to execute the search.
Managing Complex State with useReducer: A Comprehensive Guid
Tags: react, webdev, javascript, beginners
Published: 2023-02-04 04:55:27

**Introduction:**
React hooks are a powerful tool for building modern React applications. They allow you to add state and other React features to your functional components without having to convert them to class components. One of the most useful hooks is the useReducer hook, which is used for managing complex state logic in your components.

**What is useReducer:**
The useReducer hook is a way to manage state in React components. It's similar to the useState hook, but it's more powerful and can handle more complex state updates. It takes two arguments: a reducer function and an initial state. The reducer function takes the current state and an action, and it returns the new state. The useReducer hook returns an array with two values: the current state and a dispatch function that can be used to update the state.

**Example:**
Let's look at a simple example to see how useReducer works. We'll create a counter component that increments and decrements the count using the useReducer hook.

**Code:**

```
import React, { useReducer } from 'react';

const reducer = (state, action) => {
  switch (action.type) {
    case 'increment':
      return { count: state.count + 1 };
    case 'decrement':
      return { count: state.count - 1 };
    default:
      return state;
  }
};

const Counter = () => {
  const [state, dispatch] = useReducer(reducer, { count: 0 });

  return (
    <div>
      <h2>Count: {state.count}</h2>
      <button onClick={() => dispatch({ type: 'increment' })}>
        Increment
      </button>
      <button onClick={() => dispatch({ type: 'decrement' })}>
        Decrement
      </button>
    </div>
  );
};

```
**Explanation:**
In this example, we first create a reducer function that takes the current state and an action, and returns the new state. The reducer function has a switch statement that handles different action types. For the "increment" action type, it returns a new state with the count increased by one. For the "decrement" action type, it returns a new state with the count decreased by one.

In the Counter component, we use the useReducer hook and pass it the reducer function and the initial state. The hook returns an array with two values: the current state and the dispatch function. We use the current state to display the count and the dispatch function to update the state when the increment or decrement buttons are clicked.

**Conclusion:**
The useReducer hook is a powerful tool for managing complex state in your React components. It's similar to the useState hook, but it's more powerful and can handle more complex state updates. In this tutorial, we've looked at a simple example of how to use the useReducer hook to create a counter component that increments and decrements the count. If you have any questions, feel free to ask in the comments below.
Using useRef in ReactJS: A Beginner's Guide
Tags: react, javascript, beginners, programming
Published: 2023-02-04 04:50:00

Hi everyone and welcome to my ReactJS tutorial series. In this tutorial, we're going to learn about useRef and how it can be used in React applications.

**What is useRef:**
The useRef hook is used to access the DOM elements in ReactJS applications. It provides a way to reference a DOM node in our component and keep track of its value between renderings.

**Example:**
Let's create a simple example to understand how useRef works. We'll create a simple input form and use useRef to focus the input field when the component is rendered.

**Code:**
```
import React, { useRef } from 'react';

const Example = () => {
  const inputRef = useRef(null);

  useEffect(() => {
    inputRef.current.focus();
  }, []);

  return (
    <div>
      <input type="text" ref={inputRef} />
    </div>
  );
};
```

**Explanation:**
We first import the useRef hook and the useEffect hook from the React library. In our component, we create a constant named "inputRef" using the useRef hook and initialize it with a value of null.

In the useEffect hook, we use the "current" property of the useRef hook to access the input field and call its "focus" method to set the focus on the input field when the component is rendered.

Finally, we return a simple input field with a ref attribute set to our "inputRef" constant.

**Conclusion:**
That's it for this tutorial on useRef in ReactJS. I hope you have a better understanding of how this hook works and how you can use it in your React applications. If you have any questions, feel free to ask in the comments section below.

Thanks for reading!
REAL LIFE Scenario Based Manual Testing Interview Questions and Answers Part 1
Tags: webdev, beginners, programming, tutorial
Published: 2023-02-04 04:36:50

Scenario Based Manual Testing Interview Questions and Answers: In this video we are going to discuss Scenario Based Manual Testing Interview Questions and Answers which you may face in your next interview.

{% embed https://youtu.be/hXoaUutgx1E
 %}

👉Become an Software Tester even as a Fresher.
https://thetestingacademy.com


I will share the Handy things that you need to have in your PC to crack Manual Testing easily.

👉 Download Manual Testing Templates
✅ Test Case -  https://sdet.live/tc-template

✅ Test plan -  https://sdet.live/notes

✅ Download RTM -  https://scrolltest.com/rtm

✅ Bug Report -  https://sdet.dorik.io/bug-report-temp...


✅ Download Notes -  https://sdet.live/notes

✅ New Batch - https://go.scrolltest.com/manual


✅ Join Facebook Group :  http://bit.ly/learntesting2019

✅ Website:   https://scrolltest.com

✅ Website:   https://thetestingacademy.com

✅ Twitter: https://twitter.com/itstechmode

🚀 Tools and services I recommend:
Some of the courses that I recommend to become better Automation Tester 🙌🙌

✅API Testing - 
https://www.learnapitesting.com


✅Cypress Tutorial with LIVE Projects -
http://cypresstutorial.com


#scenariobasedmanualtestinginterviewquestionsandanswers #scenariobasedmanualtestinginterviewquestionsandanswersforexperienced #scenariobasedmanualtestinginterviewquestionsandanswersand
567. Leetcode solution in Python
Tags: python
Published: 2023-02-04 03:30:20

==============================================================

Description:
Given two strings s1 and s2, return true if s2 contains a permutation of s1, or false otherwise.

In other words, return true if one of s1's permutations is the substring of s2.

 

Example 1:

Input: s1 = "ab", s2 = "eidbaooo"
Output: true
Explanation: s2 contains one permutation of s1 ("ba").
Example 2:

Input: s1 = "ab", s2 = "eidboaoo"
Output: false
 

Constraints:

1 <= s1.length, s2.length <= 104
s1 and s2 consist of lowercase English letters.
==============================================================
Solution:

```python
class Solution(object):
    def checkInclusion(self, s1, s2):
        """
        :type s1: str
        :type s2: str
        :rtype: bool
        """
        counts = collections.Counter(s1)
        l = len(s1)
        for i in xrange(len(s2)):
            if counts[s2[i]] > 0:
                l -= 1
            counts[s2[i]] -= 1
            if l == 0:
                return True
            start = i + 1 - len(s1)
            if start >= 0:  
                counts[s2[start]] += 1
                if counts[s2[start]] > 0:
                    l += 1
        return False
```
==============================================================
#leetcode
#challenge
Here is the link for the problem:
https://leetcode.com/problems/permutation-in-string/
Unlock the Secrets to Better React Performance: A Guide to React.memo
Tags: react, webdev, javascript, reactperformance
Published: 2023-02-04 02:37:24

Up your #ReactJS game with our latest article! Discover how to optimize your components and take advantage of the power of #ReactMemo. Learn from the best in #WebDevelopment and #JavaScript. #ReactPerformance #ReactTips
Link: https://aaron-janes.medium.com/unlock-the-power-of-react-memo-learn-to-optimize-your-components-and-boost-your-react-performance-59d57a33ce65
Median of Two Sorted Arrays
Tags: leetcode, javascript, programming
Published: 2023-02-04 01:35:32

It's a very easy problem if we ignore the time complexity condition. Merge the two arrays, sort it and return the middle element if the merged array length is odd. And if the merged array length is even, add two middle elements and divide it by 2 and return the result.

But we should maintain the logarithmic time complexity, e.g: O(log(m+n))

So we should use any algorithm or technique that gives us logarithmic time complexity. And that is none other than Binary Search!


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


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


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


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


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

```
/**
 * @param {number[]} nums1
 * @param {number[]} nums2
 * @return {number}
 */
var findMedianSortedArrays = function(nums1, nums2) {
    let [a, b] = [nums1, nums2]
    const total = nums1.length + nums2.length
    const half = Math.floor(total/2) 

    if (a.length > b.length) {
        [a, b] = [nums2, nums1] 
        // we always do binary search in the smaller array which gives us time complexity O(log(min(m, n)))
    }

    let [left, right] = [0, a.length - 1]

    while(true) {
        let middleOfA = Math.floor((left + right) / 2)
        let middleOfB = half - middleOfA - 2 

        /*
        In left partition, if middle value is not found - that means middle index is less than 0(zero).
        That's why we are using -Infinity in this case.
        And vice-versa in the right partition.
        */
        let aLeft = a[middleOfA] !== undefined ? a[middleOfA] : -Infinity
        let aRight = a[middleOfA + 1] !== undefined ? a[middleOfA + 1] : Infinity
        let bLeft = b[middleOfB] !== undefined ? b[middleOfB] : -Infinity
        let bRight = b[middleOfB + 1] !== undefined ? b[middleOfB + 1] : Infinity

        if (aLeft <= bRight && bLeft <= aRight) {
            // that means our partition is correct
            if (total % 2 !== 0) return Math.min(aRight, bRight)
            else return (Math.max(aLeft, bLeft) + Math.min(aRight, bRight)) / 2 || 0.00
        } else if (aLeft > bRight) {
            // so we need to reduce the size of aLeft
            right = middleOfA - 1
        }else { 
            // bLeft > aRight, increase the size of aLeft
            left = middleOfA + 1
        }
    }
};
```
Use Azure Key Vault to retrieve secured parameters during Azure deployment.
Published: 2023-02-04 00:38:20

---
title: Use Azure Key Vault to retrieve secured parameters during  Azure deployment.
published: true
description: 
tags: 
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
# published_at: 2023-02-03 23:58 +0000
---

You have an ARM template to deploy, and you need to pass secure parameters. Instead of storing secure values in the parameter file, you can just retrieve these values from Key Vault.

To be able to access the key vault by the resource manager you need to change access policy to allow "Azure Resource Manager for template deployment", as shown here.

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

Or you can do it from Powershell:

```powershell
// to update an existing key vault
Set-AzKeyVaultAccessPolicy -VaultName MyVaultName -EnabledForTemplateDeployment

// to create a new key vault with this feature enabled
New-AzKeyVault `
  -VaultName MyVaultName `
  -resourceGroupName myresourcegroup `
  -Location centralus `
  -EnabledForTemplateDeployment
```

## How to use it?

in the deployment parameter file specify the location of the secured string to be the `keyvault` as follows:

```json
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "location": {
            "value": "eastus"
        },

        "adminUsername": {
            "value": "companyAdmin"
        },
        "adminPassword": {
            "reference": {
        "keyVault": {
          "id": "/subscriptions/<subscription-id>/resourceGroups/<rg-name>/providers/Microsoft.KeyVault/vaults/MyVaultName"
        },
        "secretName": <the name of the secret>
      }
        }
    }
}

```
Permissions to run deployments:

The beauty of this feature is the user who is doing deployment doesn't need to have access to the secrets, even read access. Just need a special permission called deploy permission, or more specifically this permission
```
Microsoft.keyVault/Vaults/deploy/action
```
To assign this permission to the user, it is easier if we create a custom role with this permission and then assign this role to any user want to deploy.  
First we create a json to represent the definition of the custom role:

```json
{
  "Name": "TemplateDeploymentForResourceManagerRole",
  "IsCustom": true,
  "Description": "Lets you deploy a resource manager template with the access to the secrets in the Key Vault.",
  "Actions": [
    "Microsoft.KeyVault/vaults/deploy/action"
  ],
  "NotActions": [],
  "DataActions": [],
  "NotDataActions": [],
  "AssignableScopes": [
    "/subscriptions/<your subscription id>"
  ]
}
```

And then create the role and assign it to the user.  
This powershell script does this:  

```powershell
New-AzRoleDefinition -InputFile "<path-to-role-file>"
New-AzRoleAssignment `
  -ResourceGroupName ExampleGroup `
  -RoleDefinitionName "TemplateDeploymentForResourceManagerRole" `
  -SignInName <user-principal-name>
```
Gestão de Projetos: Como Aplicar Métodos Ágeis para Obter Sucesso
Tags: productivity
Published: 2023-02-03 23:28:47

Gestão de Projetos: Como Aplicar Métodos Ágeis para Obter Sucesso
A gestão de projetos é uma atividade fundamental para garantir o sucesso de qualquer projeto, seja ele grande ou pequeno. Ela envolve a definição de objetivos claros, a definição de escopo, o planejamento e a monitoração do andamento do projeto.

Com o aumento da complexidade dos projetos, é necessário buscar abordagens mais flexíveis e eficientes para garantir o sucesso do projeto. É aqui que entram os métodos ágeis.

O que são métodos ágeis
Os métodos ágeis são abordagens iterativas e adaptativas para o desenvolvimento de projetos. Eles se baseiam em princípios como a colaboração, a entrega frequente de valor e a flexibilidade ante mudanças.

Esses métodos são uma alternativa aos métodos tradicionais de gestão de projetos, que se baseiam em planos rigorosos e cronogramas definidos desde o início do projeto.

Como aplicar métodos ágeis na gestão de projetos
A aplicação dos métodos ágeis na gestão de projetos envolve a adaptação de algumas práticas já conhecidas, como o planejamento, o gerenciamento de escopo e o gerenciamento de riscos.

Por exemplo, no planejamento, é necessário definir objetivos claros e metas para o projeto, mas sem se prender a um cronograma rígido. O gerenciamento de escopo deve ser realizado de maneira flexível, levando em conta as mudanças que possam surgir durante o desenvolvimento do projeto.

Além disso, é importante envolver todas as partes interessadas no projeto, incluindo o cliente, em todas as etapas do processo. A colaboração é fundamental para garantir que todas as necessidades sejam atendidas e que o projeto seja bem-sucedido.

Vantagens dos métodos ágeis na gestão de projetos
A aplicação dos métodos ágeis na gestão de projetos pode trazer vários benefícios, tais como:

Melhora na qualidade do produto final, uma vez que as necessidades do cliente são atendidas de maneira mais eficiente;
Redução de riscos, uma vez que o processo é mais flexível e adaptat
Setting up Netlify Redirects with Astro
Tags: astro, netlify, javascript
Published: 2023-02-04 00:20:36

---
title: Setting up Netlify Redirects with Astro
published: true
description: Making Netlify Redirects work with Astro is a quick one-line change!
tags: astro, netlify, javascript
cover_image: https://images.unsplash.com/photo-1483213097419-365e22f0f258?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxwaG90by1wYWdlfHx8fGVufDB8fHx8&auto=format&fit=crop&w=2070&q=80
canonical_url: https://cassidoo.co/post/netlify-redirects-astro
---

I struggled recently setting up [Netlify Redirects](https://docs.netlify.com/routing/redirects/) with [Astro](https://astro.build/), until I realized I needed to copy the file from the root of my directory to the built output.

Luckily, this is a very small change to make in your `package.json` for your project! First of all, make sure you have a `_redirects` file at the top level of your project.

Under your `scripts`, change the `build` command to include `cp` (copy) to the final built folder. I'm just using the default naming here (`dist`), but you can use whatever your site uses:

```json
	"scripts": {
		// ...
		"build": "astro build && cp _redirects dist/_redirects",
		// ...
	},
```

And voilà! That's all you need to get it working!

## Working example

Here's [an example repository](https://github.com/cassidoo/astro-redirects-example) for this. The website (just using a basic Astro template) is deployed at [astro-redirects-example.netlify.app](https://astro-redirects-example.netlify.app/), and you can go to `/fart` and it'll redirect you to `/fish`.

The [`_redirects` file](https://github.com/cassidoo/astro-redirects-example/blob/main/_redirects) shows you a couple options (and a fallback) for how you can set it up, and [here's what the little script looks like](https://github.com/cassidoo/astro-redirects-example/blob/main/package.json#L9) in context!

**Update after talking to the Astro team:** Putting the `_redirects` file in the `public/` directory works now for purely statically generated sites. I think if you use server-side rendering, then you still have to do a script like the above. There's also a [Build Plugin](https://github.com/BryceRussell/netlify-plugin-append-redirects) made by one of the Astro contributors, [Bryce Russell](https://brycerussell.com/), that can solve this for you!