teleren/devto huggingface dataset:
Starting routine of every RPA bot
Tags: rpa, servicenow, automation
Published: 2022-06-10 09:31:48

When you create a new RPA unattended or attended bot you want to test it directly from the Studio. To do that, you can use the common action 'ImpersonateAsRobot'. So if you want to test your Robot out of your Studio it will impersonate the robot, but if you start the Robot from ServiceNow, we don't need the impersonate anymore. So we will check with the action 'isRunningFromStudio' from where the bot has started.

After that you can have a decision with 'isTrue' where you set the true path to the impersonate and the false path to the next action. Following screenshot shows the hole sequence:

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4g2d9m6hf4jnpfizpq8f.png)
Run script on files changes using nodemon
Tags: node, tips, scripts
Published: 2022-06-11 09:26:10

---
title: Run script on files changes using nodemon
published: true
date: 2022-06-10 09:30:55 UTC
tags: node, tips, scripts
canonical_url: https://krzysztofzuraw.com/blog/2022/script-nodemon/
---

I recently was setting up workflow for developing email templates and I need a way to copy files from `src` directory into `dist` build folder. It turns out that you can use for this [nodemon](https://nodemon.io/). Script below is using [glob](https://www.npmjs.com/package/glob) library to watch for all `.txt` files under source directory and copy them from to build output directory. In addition to that it flattens the path - so if file is under `src/plaintext/plaintext.txt` the path in output will be `dist/plaintext.txt`.

```js
import { copyFileSync, existsSync, mkdirSync } from "fs";
import glob from "glob";
import { basename, join } from "path";

const directory = "dist";

if (!existsSync(directory)) {
  mkdirSync(directory);
}

glob("src/**/*.txt", (err, files) => {
  if (err) {
    console.error("Error", err);
  }

  files.forEach((file) => {
    copyFileSync(file, join(directory, basename(file)));
  });
});
```

How to run this script? I' using `nodemon copy-plaintext.mjs --ext txt --watch src` command in my `package.json`. It looks for all files with `txt` extension under `src` folder - if they change I'm running `copy-plaintext.mjs`.
Remove Digit From Number to Maximize Result
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 09:30:40

You are given a string `number` representing a **positive integer** and a character `digit`.

Return _the resulting string after removing **exactly one occurrence** of_ `digit` _from_ `number` _such that the value of the resulting string in **decimal** form is **maximized**_. The test cases are generated such that `digit` occurs at least once in `number`.

**Example 1:**

**Input:** number = "123", digit = "3"
**Output:** "12"
**Explanation:** There is only one '3' in "123". After removing '3', the result is "12".

**Example 2:**

**Input:** number = "1231", digit = "1"
**Output:** "231"
**Explanation:** We can remove the first '1' to get "231" or remove the second '1' to get "123".
Since 231 > 123, we return "231".

**Example 3:**

**Input:** number = "551", digit = "5"
**Output:** "51"
**Explanation:** We can remove either the first or second '5' from "551".
Both result in the string "51".

**Constraints:**

*   `2 <= number.length <= 100`
*   `number` consists of digits from `'1'` to `'9'`.
*   `digit` is a digit from `'1'` to `'9'`.
*   `digit` occurs at least once in `number`.

**SOLUTION:**

    class Solution:
        def removeDigit(self, number: str, digit: str) -> str:
            n = len(number)
            pos = []
            for i in range(n):
                if number[i] == digit:
                    pos.append(i)
            maxVal = float('-inf')
            for j in pos:
                currVal = int("".join([number[i] for i in range(n) if i != j]))
                maxVal = max(maxVal, currVal)
            return str(maxVal)
Integrating requestly mobile debugger in PostBook App
Tags: requestly, postbook, mobile, debugger
Published: 2022-06-10 09:29:27

Hello Everyone, My name is Samanvay Arya and I am developing android applications for more than 1 year.
I recently came to know about a wonderful tool developed by 'requestly' named [requestly mobile debugger](https://app.requestly.io/mobile-debugger).
I read about it and gather some information from the wonderful [documentation](https://docs.requestly.io/) given by requestly. 
After reading and researching, I was excited to test it so, I created *[PostBook](https://github.com/Samanvay-Arya/requestly_SamanvayArya)* (a mobile App) which shows fake posts posted by fake users. 
<u>

## Picture of the application is attached to this post.
</u>

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




points to use in PostBook
  1. you can check the comments and also hide them with a single tap.

2. App has edge case also covered like if you use it without internet then it will show retry message.
   ![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oubn0zdeq5nqabxlqtb7.png)
3. you can check the [video](https://youtu.be/iBCby-n3JBY) for more details.
     

<u>

## Steps for implementing *requestly debugger* in *PostBook*
</u>
  1. go to app.requestly.io
  2. select mobile debugger on the window.
  3. create a new app and generate an SDK key for your app.
  4. you will be given 5 lines of code. paste the first two lines in your build. gradle file of the android app.
  5. paste the rest of the 3 lines to the activity where you have called the API.
  6. Now run the app and copy the deviceId given in the notification on the mobile and paste that on the requestly panel.
  7. Now you can see the API information on both websites and on your mobile phone as well.

**

## Some screenshots of **requestly** analysis on the mobile phone.
**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8ebbhebw2h6rbsu5w2kc.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9a0rqwc4mn4y1n893wq3.png)
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5xk2q77aci5mwgwclb01.png)

<u>

## *Conclusion:-*
</u> *[requestly mobile debuggers](https://app.requestly.io/mobile-debugger)* is a brilliantly designed tool to help and reduce the work of a mobile app developer.
Eneftimbu Sürecimiz
Tags: blockchain, nft, avax, augmentedreality
Published: 2022-06-10 09:17:21

Geleceğin getirdiklerini keşfetmeye hazır mısınız? Çok yakında sizlerleyiz.

Herkese selam bu yazımda Mert Can ZÜMRÜT ve Ahmet Melih NARİN arkadaşlarımla beraber üzerinde uğraştığımız  eneftimbu projesinin devam eden sürecinden bahsedeceğim.
 
Mayıs 2022 de "Eneftimbu" Projesinin Yürütücüsü Mert Can ZÜMRÜT ve Tasarımcısı Ahmet Melih NARİN arkadaşım ile KTÜ TTM 15. Düşünden Gerçeğine Proje Pazarı'na katıldık. Ben ise   Unity`de Augmented reality(AR Vuforia) teknolojisini kullanarak geliştirdiğim basit uygulamayı projeye dahil ederek yazılım kısmını devraldım.
Dart Good Practice: separate Model, UI view and controller logic
Published: 2022-06-10 09:02:53

MVC architecture is a design pattern to separate the application into three parts, namely: the model part, the view and the controller.

In day to day code review, it is noticed that developers tend to directly use unprocessed model data into the UI view. Not only that this will create a lot of extra `if-else` null checking logic in the final compiled code, it make the code looks very verbose. 

See the example with pseudocode below: 

Not Recommended:
```dart
   Text(_ctrl.sales?.amount ?? ''),
   Text(_ctrl.sales?.quantity ?? ''),
   Text(_ctrl.sales?.month ?? ''),
```

Good
controller.dart
```dart
late SaleModel sales;

onFetch() async {
  var res = await fetch('https://abc.com/sales');
  if (null != res.data && null != res.data.sales) {
    sales = SaleModel.fromJson(res.data.sales);
  } else {
    // declare a named constructor which return SaleModel with blank string
    sales = SaleModel.blank();
  }
}
```

UI view
```dart
   Text(_ctrl.sales.amount),
   Text(_ctrl.sales.quantity),
   Text(_ctrl.sales.month),
```
Are you a YARNer or a NPMer?
Tags: javascript, webdev, react, productivity
Published: 2022-06-10 09:01:14

## An age old debate about package managers

Each have their pros & their cons 

I personally prefer **Yarn** - I think it's general installation of packages is quicker and I REALLY appreciate its peer dependency resolution it saves _LOADS_ of time.

So - what is your go-to package manager and why?
Last Substring in Lexicographical Order
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 09:00:44

Given a string `s`, return _the last substring of_ `s` _in lexicographical order_.

**Example 1:**

**Input:** s = "abab"
**Output:** "bab"
**Explanation:** The substrings are \["a", "ab", "aba", "abab", "b", "ba", "bab"\]. The lexicographically maximum substring is "bab".

**Example 2:**

**Input:** s = "leetcode"
**Output:** "tcode"

**Constraints:**

*   `1 <= s.length <= 4 * 105`
*   `s` contains only lowercase English letters.

**SOLUTION:**

    class Solution:
        def lastSubstring(self, s: str) -> str:
            n = len(s)
            maxSub = ""
            for i in range(n):
                maxSub = max(maxSub, s[i:])
            return maxSub
Drag-and-drop React UI builder?
Tags: react
Published: 2022-06-10 08:55:53

I want to build my own web-based version of MS Paint using React. I have the basic javascript canvas code written and now I want to make a nice gui with a menu bar across the top, and a section on the left to select which tool to use, etc.

Can anyone recommend a drag-and-drop software with pre-made components like button, menu bar etc, to make it easy for me to make a professional-looking user interface? Alternatively, some tips on what my workflow should be like would be much appreciated.
A Minute of Understanding POM
Tags: java
Published: 2022-06-10 08:51:06

---
title: A Minute of Understanding POM
published: true
description: A random write-up of sorts
tags: java
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---

### Follow Me, Shout Out, or Give Thanks! 
Please :sparkling_heart: this article. a small thing to keep me motivated =)
Twitter: [@djjasonclark](https://twitter.com/djjasonclark)
Linkedin: [in/clarkngo](https://www.linkedin.com/in/clarkngo/)

When you are going to build a project with Java and ended up choosing Maven, you will encounter POM. The `pom.xml` file.

If you want a sample of a that `pom.xml` file, go ahead.
Go to [Spring Initializer](https://start.spring.io/) site

Choose the defaults and make sure to select Maven Project.
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pbrh6ev4vqe5oc1vr4ne.png)
 
```
demo
|_ HELP.md
|_ mvnw.xml
|_ mvnw.cmd
|_ pom.xml
|_ src
```

There is a lot to unpack when we talk about POM.
For starters, its to manage dependencies in your project.

-- TO BE CONTINUED -- 
Feel free to leave comments on how this live article show move forward.
The 5 online coding and development tools you need to know
Tags: programming, productivity, codepen, 100daysofcode
Published: 2022-06-10 08:50:58

Online Coding and development tools make our experience with development a lot fun and easier.

In this article, I outlined 5 online coding and development tools I find super cool.

What are yours? Let me know in the comment section of the article☺️

https://medium.com/@gloriaasuquo/the-5-online-coding-and-development-tools-you-need-to-know-20b6e13329dd
Fix NX Node executor ERR_REQUIRE_ESM Error
Tags: nx, node, esm, cjs
Published: 2022-06-10 08:47:02

---
title: Fix NX Node executor ERR_REQUIRE_ESM Error
published: true
description: Fix NX Node executor ERR_REQUIRE_ESM Error
tags: nx,node,esm,cjs
# cover_image: https://direct_url_to_image.jpg
# Use a ratio of 100:42 for best results.
---


昨晚睡前踩了個雷，來分享一下：

NX 新專案忘了裡面已經裝過 `nanoid`，重裝了一次，然後 `@nrwl/node:node` 就開始報錯，找到引用 `nanoid` 的 model，在 sequelize hooks 裡，用報錯的解法改用 dynamic import 可以解決，查 NX issue 也看到幾個 node executor 不支援 static import ESM 的問題。

然後剛剛去看 `nanoid`，3 天前 `nanoid@4` migrate 到純 ESM 不支援 CJS 了⋯⋯降級回 `nanoid@3` 就解決了，等 NX issue #10414 merge 看有沒有改善吧。

## Reference
- https://bobbyhadz.com/blog/javascript-error-err-require-esm-require-of-es-module-not-supported
- https://github.com/nrwl/nx/issues/10565
Developer Path #2 - Choosing the tech-stack
Tags: frontend, programming, react, javascript
Published: 2022-06-10 08:40:48


Developer Path #2 - Choosing the tech-stack

Choosing the tech-stack was quite easy. In the frontend I chose react (vite) for its easiness, velocity and big community which answered already most of the questions I will get to face. For the frontend-design aspect I chose mantine-ui for its compatibility with react, nice hooks and much more. Choosing between firebase and supabase was not an easy descision, however I decided to begin with firebase. 

I am looking forward to having fun by building this project and learning a lot from it.
Evaluate Division
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 08:30:47

You are given an array of variable pairs `equations` and an array of real numbers `values`, where `equations[i] = [Ai, Bi]` and `values[i]` represent the equation `Ai / Bi = values[i]`. Each `Ai` or `Bi` is a string that represents a single variable.

You are also given some `queries`, where `queries[j] = [Cj, Dj]` represents the `jth` query where you must find the answer for `Cj / Dj = ?`.

Return _the answers to all queries_. If a single answer cannot be determined, return `-1.0`.

**Note:** The input is always valid. You may assume that evaluating the queries will not result in division by zero and that there is no contradiction.

**Example 1:**

**Input:** equations = \[\["a","b"\],\["b","c"\]\], values = \[2.0,3.0\], queries = \[\["a","c"\],\["b","a"\],\["a","e"\],\["a","a"\],\["x","x"\]\]
**Output:** \[6.00000,0.50000,-1.00000,1.00000,-1.00000\]
**Explanation:** 
Given: _a / b = 2.0_, _b / c = 3.0_
queries are: _a / c = ?_, _b / a = ?_, _a / e = ?_, _a / a = ?_, _x / x = ?_
return: \[6.0, 0.5, -1.0, 1.0, -1.0 \]

**Example 2:**

**Input:** equations = \[\["a","b"\],\["b","c"\],\["bc","cd"\]\], values = \[1.5,2.5,5.0\], queries = \[\["a","c"\],\["c","b"\],\["bc","cd"\],\["cd","bc"\]\]
**Output:** \[3.75000,0.40000,5.00000,0.20000\]

**Example 3:**

**Input:** equations = \[\["a","b"\]\], values = \[0.5\], queries = \[\["a","b"\],\["b","a"\],\["a","c"\],\["x","y"\]\]
**Output:** \[0.50000,2.00000,-1.00000,-1.00000\]

**Constraints:**

*   `1 <= equations.length <= 20`
*   `equations[i].length == 2`
*   `1 <= Ai.length, Bi.length <= 5`
*   `values.length == equations.length`
*   `0.0 < values[i] <= 20.0`
*   `1 <= queries.length <= 20`
*   `queries[i].length == 2`
*   `1 <= Cj.length, Dj.length <= 5`
*   `Ai, Bi, Cj, Dj` consist of lower case English letters and digits.

**SOLUTION:**

    class Solution:
        def calcEquation(self, equations: List[List[str]], values: List[float], queries: List[List[str]]) -> List[float]:
            graph = {}
            n = len(equations)
            for i in range(n):
                a, b = equations[i]
                graph[a] = graph.get(a, []) + [(b, values[i])]
                graph[b] = graph.get(b, []) + [(a, 1 / values[i])]
            op = []
            for c, d in queries:
                found = False
                paths = [(c, 1, {c})]
                while len(paths) > 0:
                    curr, prod, visited = paths.pop()
                    if curr not in graph:
                        break
                    if curr == d:
                        op.append(prod)
                        found = True
                        break
                    for j, div in graph.get(curr, []):
                        if j not in visited:
                            paths.append((j, prod * div, visited.union({j})))
                if not found:
                    op.append(-1.0)
            return op
[CSS Trick] Create Responsive Layouts without @media Query
Tags: css, rwd, responsive
Published: 2022-06-10 08:17:21

We can use auto-fit to create a simple responsive layout of items without writing any @media query code by  setting grid columns like: 

```css
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
```
The above means:
Each grid column has minimum width of 150px, and maximum width of 1 faction unit; 
Auto-fit FITS the CURRENTLY AVAILABLE columns into the space by expanding them so that they take up any available space.



**Example:**

```html
<div class="container">
  <div class="item">ITEM 1</div>
  <div class="item">ITEM 2</div>
  <div class="item">ITEM 3</div>
  <div class="item">ITEM 4</div>
  <div class="item">ITEM 5</div>
  <div class="item">ITEM 6</div>
  <div class="item">ITEM 7</div>
  <div class="item">ITEM 8</div>
</div>
```

```css
.container {
  background-color: violet;
  padding: 30px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  grid-gap: 15px;
}

.item {
  background-color: lightseagreen;
  padding: 10px;
  height: 300px;
}

```


**Result:**

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

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

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ien3fajbfh6ia5nktw90.png)
Base 7
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 08:00:41

Given an integer `num`, return _a string of its **base 7** representation_.

**Example 1:**

**Input:** num = 100
**Output:** "202"

**Example 2:**

**Input:** num = -7
**Output:** "-10"

**Constraints:**

*   `-107 <= num <= 107`

**SOLUTION:**

    class Solution:
        def convertToBase7(self, num: int) -> str:
            if num == 0:
                return "0"
            sign = ""
            if num < 0:
                sign = "-"
                num *= -1
            op = ""
            while num > 0:
                d = num % 7
                num = num // 7
                op = str(d) + op
            return sign + op
A Quick 10-Second Programming Joke For Today
Tags: jokes, dailydeveloperjokes
Published: 2022-06-10 08:00:08

---
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
---

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/5e12588592f15.png)

---

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

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

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

<!--
Joke text:
___Q:___ Why did the security conscious engineer refuse to pay their dinner bill?

___A:___ Because they could not verify the checksum.
 -->
How to mock function that called inside module
Tags: jest, testing, javascript, node
Published: 2022-06-10 07:58:22

## Problem
Iets say you have the file
```javascript
// file.js

export function b() {
	return 'B'
}

export function a() {
	return b()
}

module.exports = {
	a,
	b,
}
```
function **a** is calling function **b** internally. To mock the function b can be very difficult.

You will probably do something like this in your test

### Using jest.mock method
```javascript
jest.mock('./file', () => {
	const original = jest.requireActual('./file')
	return {
		...orignial,
		b: jest.fn()
	}
})

const f = require('./file')

test('a', () => {
	f.b.mockReturnValue('C')
	
	expect(f.a()).toBe('C')
	// this will failed, it got 'B'
})
```
### Using jest.spyOn method
```javascript
const f = require('./file')

test('a', () => {
	jest.spyOn(f, 'b').mockReturnValue('C')
	
	expect(f.a()).toBe('C')
	// it sill failed!, it got 'B'
})
```

This is not a bug, above 2 methods are working fine. The main reason is because the reference point. Once the function is mocked and print it out you will see something like this.

```
[Function: b] {
	_isMockFunction: true,
	getMockImplementation: [Function (anonymous)],
	mock: [Getter/Setter],
	mockClear: [Function (anonymous)],
	mockReset: [Function (anonymous)],
	mockRestore: [Function (anonymous)],	
	...
	...
}
```
Now you try print out the function b that called in function a. And, run the test again.

```javascript
export function a() {
	console.log(b) // it will print [Function: b] (without the mock property)
	return b()
}
```

## Solution 1
Move function b to another file.
```javascript
// b.js
export function b() {
	return 'B'
}
```
```javascript
// file.js
import {b} from "./b"

export function a() {
	return b()
}
```
In this case, just mock b will do. I believe you know better than me.

## Solution 2
Using the same reference point. This could be abit ugly to you codebase. I think is fine for me.
```javascript
// file.js

export function b() {
	return 'B'
}

export function a() {
	return module.exports.b() // magic here
}

module.exports = {
	a,
	b,
}
```
Or you can do something like, if this is the way you define your module.
```javascript
// file.js

module.exports = {
	b: () => {
		return 'B'
	},
	a: () => {
		return this.b() // this magic
	}
}
```
Both are achive the same result and same principle.
Self Dividing Numbers
Tags: leetcode, dsa, theabbie
Published: 2022-06-10 07:30:47

A **self-dividing number** is a number that is divisible by every digit it contains.

*   For example, `128` is **a self-dividing number** because `128 % 1 == 0`, `128 % 2 == 0`, and `128 % 8 == 0`.

A **self-dividing number** is not allowed to contain the digit zero.

Given two integers `left` and `right`, return _a list of all the **self-dividing numbers** in the range_ `[left, right]`.

**Example 1:**

**Input:** left = 1, right = 22
**Output:** \[1,2,3,4,5,6,7,8,9,11,12,15,22\]

**Example 2:**

**Input:** left = 47, right = 85
**Output:** \[48,55,66,77\]

**Constraints:**

*   `1 <= left <= right <= 104`

**SOLUTION:**

    class Solution:
        def selfDividingNumbers(self, left: int, right: int) -> List[int]:
            op = []
            for i in range(left, right + 1):
                curr = i
                valid = True
                while curr != 0:
                    d = curr % 10
                    if d == 0 or i % d != 0:
                        valid = False
                        break
                    curr //= 10
                if valid:
                    op.append(i)
            return op