teleren/devto huggingface dataset:
How to Dockerize a React app
Tags: beginners, react, docker, short
Published: 2022-06-02 12:04:29

A very simple and short guide to dockerize a React app.

## Create a new React app

```
$ npx create-react-app dockerized-react-app
```

## Cd into your project

```
$ cd dockerized-react-app
```

## Create a file named `Dockerfile`

```
FROM node:alpine

WORKDIR '/app'

COPY ./package.json ./

RUN npm install

COPY . .

CMD ["npm", "run", "start"]
```

## Create a docker-compose file `docker-compose.yml`

```
version: '3'

services:

  app:
    container_name: my-dockerized-react-app
    build:
      context: .
      dockerfile: Dockerfile
    volumes:
      - '.:/app'
      - '/app/node_modules'
    ports:
      - 3000:3000

```

## Build your container

```
$ docker-compose up -d --build
```

Go to [http://localhost:3000/](http://localhost:3000/)
Swap Nodes in Pairs
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 12:00:27

Given a linked list, swap every two adjacent nodes and return its head. You must solve the problem without modifying the values in the list's nodes (i.e., only nodes themselves may be changed.)

**Example 1:**

![](https://assets.leetcode.com/uploads/2020/10/03/swap_ex1.jpg)

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

**Example 2:**

**Input:** head = \[\]
**Output:** \[\]

**Example 3:**

**Input:** head = \[1\]
**Output:** \[1\]

**Constraints:**

*   The number of nodes in the list is in the range `[0, 100]`.
*   `0 <= Node.val <= 100`

**SOLUTION:**

    # Definition for singly-linked list.
    # class ListNode:
    #     def __init__(self, val=0, next=None):
    #         self.val = val
    #         self.next = next
    class Solution:
        def swapPairs(self, head: Optional[ListNode]) -> Optional[ListNode]:
            if head and head.next:
                head.val, head.next.val = head.next.val, head.val
                head.next.next = self.swapPairs(head.next.next)
            return head
Remove One Element to Make the Array Strictly Increasing
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 12:00:24

Given a **0-indexed** integer array `nums`, return `true` _if it can be made **strictly increasing** after removing **exactly one** element, or_ `false` _otherwise. If the array is already strictly increasing, return_ `true`.

The array `nums` is **strictly increasing** if `nums[i - 1] < nums[i]` for each index `(1 <= i < nums.length).`

**Example 1:**

**Input:** nums = \[1,2,10,5,7\]
**Output:** true
**Explanation:** By removing 10 at index 2 from nums, it becomes \[1,2,5,7\].
\[1,2,5,7\] is strictly increasing, so return true.

**Example 2:**

**Input:** nums = \[2,3,1,2\]
**Output:** false
**Explanation:**
\[3,1,2\] is the result of removing the element at index 0.
\[2,1,2\] is the result of removing the element at index 1.
\[2,3,2\] is the result of removing the element at index 2.
\[2,3,1\] is the result of removing the element at index 3.
No resulting array is strictly increasing, so return false.

**Example 3:**

**Input:** nums = \[1,1,1\]
**Output:** false
**Explanation:** The result of removing any element is \[1,1\].
\[1,1\] is not strictly increasing, so return false.

**Constraints:**

*   `2 <= nums.length <= 1000`
*   `1 <= nums[i] <= 1000`

**SOLUTION:**

    class Solution:
        def isIncreasing(self, nums, n):
            for i in range(n - 1):
                if nums[i + 1] <= nums[i]:
                    return False
            return True
        
        def canBeIncreasing(self, nums: List[int]) -> bool:
            n = len(nums)
            for i in range(n):
                if self.isIncreasing(nums[: i] + nums[i + 1 :], n - 1):
                    return True
            return False
Planet Crust released Corteza 2021.9.11! 🖥️🎉
Tags: release, update, lowcode, opensource
Published: 2022-06-02 11:59:00

The Corteza open-source low-code platform has a new point release – 2021.9.11. Check out what are the new fixes: 
👉 https://www.planetcrust.com/corteza-2021-9-11-released
Number of Ways to Divide a Long Corridor
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 11:56:01

Along a long library corridor, there is a line of seats and decorative plants. You are given a **0-indexed** string `corridor` of length `n` consisting of letters `'S'` and `'P'` where each `'S'` represents a seat and each `'P'` represents a plant.

One room divider has **already** been installed to the left of index `0`, and **another** to the right of index `n - 1`. Additional room dividers can be installed. For each position between indices `i - 1` and `i` (`1 <= i <= n - 1`), at most one divider can be installed.

Divide the corridor into non-overlapping sections, where each section has **exactly two seats** with any number of plants. There may be multiple ways to perform the division. Two ways are **different** if there is a position with a room divider installed in the first way but not in the second way.

Return _the number of ways to divide the corridor_. Since the answer may be very large, return it **modulo** `109 + 7`. If there is no way, return `0`.

**Example 1:**

![](https://assets.leetcode.com/uploads/2021/12/04/1.png)

**Input:** corridor = "SSPPSPS"
**Output:** 3
**Explanation:** There are 3 different ways to divide the corridor.
The black bars in the above image indicate the two room dividers already installed.
Note that in each of the ways, **each** section has exactly **two** seats.

**Example 2:**

![](https://assets.leetcode.com/uploads/2021/12/04/2.png)

**Input:** corridor = "PPSPSP"
**Output:** 1
**Explanation:** There is only 1 way to divide the corridor, by not installing any additional dividers.
Installing any would create some section that does not have exactly two seats.

**Example 3:**

![](https://assets.leetcode.com/uploads/2021/12/12/3.png)

**Input:** corridor = "S"
**Output:** 0
**Explanation:** There is no way to divide the corridor because there will always be a section that does not have exactly two seats.

**Constraints:**

*   `n == corridor.length`
*   `1 <= n <= 105`
*   `corridor[i]` is either `'S'` or `'P'`.

**SOLUTION:**

    class Solution:
        def numberOfWays(self, corridor: str) -> int:
            if corridor.count("S") % 2 != 0:
                return 0
            ctr = 0
            pos = []
            for i, c in enumerate(corridor):
                if c == "S":
                    if ctr == 0:
                        pos.append(i)
                    ctr += 1
                if ctr == 2:
                    pos.append(i)
                    ctr = 0
            if len(pos) <= 1:
                return 0
            if len(pos) == 2:
                return 1
            p = 1
            n = len(pos)
            for i in range(1, n, 2):
                if i < n and i + 1 < n:
                    p *= (pos[i + 1] - pos[i])
            return p % ((10 ** 9) + 7)
Minimum Cost of Buying Candies With Discount
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 11:55:59

A shop is selling candies at a discount. For **every two** candies sold, the shop gives a **third** candy for **free**.

The customer can choose **any** candy to take away for free as long as the cost of the chosen candy is less than or equal to the **minimum** cost of the two candies bought.

*   For example, if there are `4` candies with costs `1`, `2`, `3`, and `4`, and the customer buys candies with costs `2` and `3`, they can take the candy with cost `1` for free, but not the candy with cost `4`.

Given a **0-indexed** integer array `cost`, where `cost[i]` denotes the cost of the `ith` candy, return _the **minimum cost** of buying **all** the candies_.

**Example 1:**

**Input:** cost = \[1,2,3\]
**Output:** 5
**Explanation:** We buy the candies with costs 2 and 3, and take the candy with cost 1 for free.
The total cost of buying all candies is 2 + 3 = 5. This is the **only** way we can buy the candies.
Note that we cannot buy candies with costs 1 and 3, and then take the candy with cost 2 for free.
The cost of the free candy has to be less than or equal to the minimum cost of the purchased candies.

**Example 2:**

**Input:** cost = \[6,5,7,9,2,2\]
**Output:** 23
**Explanation:** The way in which we can get the minimum cost is described below:
- Buy candies with costs 9 and 7
- Take the candy with cost 6 for free
- We buy candies with costs 5 and 2
- Take the last remaining candy with cost 2 for free
Hence, the minimum cost to buy all candies is 9 + 7 + 5 + 2 = 23.

**Example 3:**

**Input:** cost = \[5,5\]
**Output:** 10
**Explanation:** Since there are only 2 candies, we buy both of them. There is not a third candy we can take for free.
Hence, the minimum cost to buy all candies is 5 + 5 = 10.

**Constraints:**

*   `1 <= cost.length <= 100`
*   `1 <= cost[i] <= 100`

**SOLUTION:**

    class Solution:
        def minimumCost(self, cost: List[int]) -> int:
            n = len(cost)
            cost.sort()
            curr = 0
            if len(cost) == 1:
                return cost[0]
            while len(cost) > 1:
                b = cost.pop()
                a = cost.pop()
                curr += a + b
                if len(cost) > 0:
                    cost.pop()
            curr += sum(cost)
            return curr
Smallest Good Base
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 11:53:13

Given an integer `n` represented as a string, return _the smallest **good base** of_ `n`.

We call `k >= 2` a **good base** of `n`, if all digits of `n` base `k` are `1`'s.

**Example 1:**

**Input:** n = "13"
**Output:** "3"
**Explanation:** 13 base 3 is 111.

**Example 2:**

**Input:** n = "4681"
**Output:** "8"
**Explanation:** 4681 base 8 is 11111.

**Example 3:**

**Input:** n = "1000000000000000000"
**Output:** "999999999999999999"
**Explanation:** 1000000000000000000 base 999999999999999999 is 11.

**Constraints:**

*   `n` is an integer in the range `[3, 1018]`.
*   `n` does not contain any leading zeros.

**SOLUTION:**

    class Solution:
        def getNum(self, base, l):
            val = 0
            for _ in range(l):
                val = base * val + 1
            return val
        
        def smallestGoodBase(self, n: str) -> str:
            n = int(n)
            for l in range(len("{:b}".format(n)), 1, -1):
                beg = 2
                end = n - 1
                while beg <= end:
                    mid = (beg + end) // 2
                    val = self.getNum(mid, l)
                    if val == n:
                        return str(mid)
                    elif beg == end:
                        break
                    elif val < n:
                        beg = mid + 1
                    else:
                        end = mid
Nth Digit
Tags: leetcode, dsa, theabbie
Published: 2022-06-02 11:53:11

Given an integer `n`, return the `nth` digit of the infinite integer sequence `[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ...]`.

**Example 1:**

**Input:** n = 3
**Output:** 3

**Example 2:**

**Input:** n = 11
**Output:** 0
**Explanation:** The 11th digit of the sequence 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ... is a 0, which is part of the number 10.

**Constraints:**

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

**SOLUTION:**

    class Solution:
        def findNthDigit(self, n: int) -> int:
            prevcumsum = None
            cumsum = 0
            l = 1
            while n >= cumsum:
                prevcumsum = cumsum
                nextcumsum = cumsum + 9 * l * (10 ** (l - 1))
                if nextcumsum >= n:
                    break
                cumsum = nextcumsum
                l += 1
            n -= prevcumsum
            k, n = divmod(n - 1, l)
            num = str(10 ** (l - 1) + k)
            return int(num[n])
Web3 portals for your next web3 job
Tags: web3, blockchain, javascript, react
Published: 2022-06-02 11:52:58

I have been struggling for the past month to grab a new opportunity in web3. From learning solidity, exploring web3 portals and applying to multiple third-party suppliers, finally, I’ve found the portals which you can really grab your next web3 opportunity.

[Youtube video](https://www.youtube.com/watch?v=SE08_2ce7Dk&feature=emb_logo)

Disclaimer
Whenever you are reading this story, please check the publishing time as if you are reading one year later, some portals will not work as expected.

Let’s begin the party —

Angelist
[Angelist job section](https://angel.co/jobs)

Remote3
[Remote3 website](https://remote3.co/)

Reactiflux
[Reactiflux website](https://www.reactiflux.com/)


Web3Jobs
[Web3 jobs portal](https://web3.career/)

Froog
[Froog website](https://froog.co/)

Startup jobs
[startup jobs portal](https://startup.jobs/remote?remote=true&q=web3+)

CryptoJobList
[Crypto jobs list portal](https://cryptojobslist.com/remote+frontend)

DeFi Jobs
[DeFi jobs portal](https://www.defi.jobs/)

PomCryptoJobs
[PomCryptoJobs](https://pompcryptojobs.com/)

**Conclusion**
If you have any other platform in the record, please add it to the comment section, I will update the story simultaneously. It would be very helpful for everyone around the globe to read this story.

Until next time, have a good day, People.

our website - [iHateReading](https://www.ihatereading.in)
What are koans and how can they help level up your dev game?
Tags: coding, koans, tdd
Published: 2022-06-02 18:11:03

---
title: What are koans and how can they help level up your dev game?
published: true
date: 2022-06-02 11:49:22 UTC
tags: Coding,koans,TDD
canonical_url: https://blog.jws.app/2022/what-are-koans-and-how-can-they-help-level-up-your-dev-game/
---

A koan is a story, dialogue, question, or statement which is used in Zen practice to provoke the “great doubt” and to practice or test a student’s progress in Zen.  In the Zen school of Rinzai, the use of koans (often a paradoxical statement) is used to initiate the internal socratic method in the students, to break down prior deeply held notions that hold them back from Enlightenment.  An example of a koan is the question “What do you call the world?”

So, what does this have to do with application development?  There are technology-specific koans out there like [Ruby Koans](http://rubykoans.com/), [ColdFusion Koans](http://blog.bittersweetryan.com/2011/10/introducing-coldfusion-koans-learn.html), [Python Koans](https://github.com/gregmalcolm/python_koans), and a number of different versions of [JavaScript](https://github.com/mrdavidlaing/javascript-koans) [Koans](https://github.com/liammclennan/JavaScript-Koans).  The goals of each project is to teach the particular technology through testing.  A test runner like [Jasmine](https://jasmine.github.io/), [QUnit](https://qunitjs.com/), or [MXUnit](http://mxunit.org/) is usually used.  With koans, you need to run the tests and see them fail, make the tests pass, and then take a moment to reflect upon the test to see what it is teaching you.  In doing this, the hope is that you will become a better coder.

 


The post [What are koans and how can they help level up your dev game?](https://blog.jws.app/2022/what-are-koans-and-how-can-they-help-level-up-your-dev-game/) appeared first on [Blog.jws](https://blog.jws.app).
Hal yang membuat dunia web programming kurang diminati
Published: 2022-06-02 11:48:01

hallo gays, langsung saja kita bahas kenapa ilmu web programming kurang diminati oleh sebagian besar orang.
Yang Pertama, terlalu rumit untuk dipelajari. Dibandingkan dengan ilmu lainnya seperti musik atau melukis, merancang sebuah code pemograman tidak tidak semudah membalikan telapak tangan. Berbeda apabila orang yang mendalami ilmu musik atau seni melukis yang lebih mudah diprakktekan.
Yang kedua. Membutuhkan keahlian dan keteleitian. Bayangkan jika dalam sebiah programing terdapat crash atau kesalahan dalam memasukan elemen kode pasti akan membuat kepala anda pusing karena harus menyusun ulang rancanganya, naka dari itu keahlian dan ketelitian adalah hal yang harus dimiliki oleh seorang web programming.
what do you do when you are on bench?
Tags: discuss, beginners, productivity, motivation
Published: 2022-06-02 11:32:29

I really wanted to know what people in MNCS's or startups do when they are not assigned to any projects or learning tasks?

Things I do :-

1. Read blogs about my favorite programming language
2. Understanding about different JOB roles
3. Create music
4. Exercise more
Erstelle Vergleichstabellen für Amazon mit AAWP
Tags: wordpress, affiliatemarketing, amazon, tabelle
Published: 2022-06-02 16:47:53

---
title: Erstelle Vergleichstabellen für Amazon mit AAWP
published: true
date: 2022-06-02 11:28:31 UTC
tags: WordPress,affiliatemarketing,amazon,tabelle
canonical_url: https://bloggerpilot.com/aawp-vergleichstabellen/
---

![Erstelle Vergleichstabellen für Amazon mit AAWP](https://bloggerpilot.com/wp-content/uploads/2022/06/aawp-tabellen.png)

Das Plugin AAWP dürfte sicher vielen Amazon-Affiliates bereits ein Begriff...

Der Original-Artikel erschien auf [Erstelle Vergleichstabellen für Amazon mit AAWP](https://bloggerpilot.com/aawp-vergleichstabellen/).
Javascript Variable
Tags: javascript
Published: 2022-06-02 10:00:03

4 ways to Declare a Javascript Variable:
- using `var`
- using `let`
- using `const`
- using `nothing`

### What are Variables?
Variable are container for storing data

example:
```
var x = 5;
var y = 6;
var z = x + y;
```

###When to Use JavaScript var?
Always declare Javascript variables with `var`,`let` or `const`.
the `var` keyword is used in all JavaScript code from 1995 to 2015.
the `let` and `const` keywords were added to JavaScript in 2015.
if you want your code to run in older browser, you must use `var`.

###When to Use JavaScript const?
if you want a general rules: always declare variables with `const`.
if you think the value of the variable can change, use `let`.
in this example, `price1`,`price2`, anda `total`, are variables:
```
const price1 = 10;
const price2 = 20;
let total = price1 + price2; //30
```
_noted: the two variables `price1` and `price2` are declared with the `const` keyword. there are constant values and cannot changed. the variable `total` is declared with the `let` keyword._

###JavaScript Identifiers
All JavaScript **variables** mus be **identified** with **unique names**.
The general rules for constructing names for variables are:
- Names can contain letters, digits, underscores, and dollar signs.
- Names must begin with a letters.
- Names can also begin with $ and _.
- names are case sensitive(a and A different variables).
- reserved words cannot be used as names.

###The Assignment operator
In JavaScript, the equal sign(`=`) is an assigment operator, not an `equal to` operator.
```
s = s + 16
```

### Declaring a JavaScript Variable
You can declare a JavaScript variable with the `var` or the `let` keyword:
```
var carName;
or
let carName;
```

###One Statement, Many Variables
```
let name='aji', lastName='dk',address:'Indonesia'
```

### Value = undefined
A variable declared without a value will have the value undefined.
Install Node Version Manager (NVM) without Admin Rights
Tags: tooling, node
Published: 2022-06-02 10:57:00

NVM (Node Version Manager) is the best way to run multiple versions of NodeJS on the same machine.
It's not only for Windows but in this post I will talk about my experience to install NVM on a Windows machine without Admin Rights.
Why? Because at work I have a very restricted access to the operative system and on what can I do on my PC.

## Download NVM for Windows
NVM for Windows is an [opensource project](https://github.com/coreybutler/nvm-windows) mantained by the community to install and manage multiple versions of NodeJS on Windows.
You can find the latest releases at this [link](https://github.com/coreybutler/nvm-windows/releases).
At the moment, the latest version is 1.1.9.
For this special case you can download the file **nvm-noinstall.zip**.
Extract the zip file into your favorite folder for this kind of tool.
On my machine I have a main folder called "tools" on my root with other tools as well, like ngrok or screentogif.
For instance, you can extract the files into the folder c:\tools\nvm.

## Add the environment variables
From the System Properties of your machine, click on the button "Environment Variables".

![Environment Variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/77hrqezz8qijal0uiafy.png)

Add two environment variables, the first one, called NVM_HOME and this is the patch of NVM. In our case is c:\tools\nvm.
The other variable is called NVM_SYMLINK and it must be a directory should not exists, like c:\tools\nvm\nodejs.

![Environment Variables](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/gl5k5g70zl3e5ia5pi84.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ho1kj6qqc4lzk2qx6xyn.png)
 
Now you can update the Patch value with the two new values: %NVM_HOME%;%NVM_SYMLINK%

![Path values](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y2yghzeufkj3e43hzopd.png)
 
If you want you can create a file called "settings.txt" in the nvm directory and it uses that file like User Environment Variables.
It prevents to restart the machine but it's not mandatory.
The example below is the content of my settings.txt file.
As you can see contains the same parameters values of the environment variables.

```
root: C:\tools\nvm 
path: C:\tools\nvm\nodejs
arch: 64 
proxy: none
```

## Launch NVM
Now you are ready to launch and use NVM on your machine.
Open your favorite terminal application and type "nvm".
If everything is configured well, you should see a screen like this one below.

![nvm up & running](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kdmx63wgdez5kkjid0q4.png)
Set Windows Applications to Run as Administrator
Tags: discuss, windows, windowsadministrator, beginners
Published: 2022-06-02 10:38:15

1.Tap the Windows Key to display Start Menu.

![Start Menu](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/80xabu8qj55rl4cjwe7d.png)
2.Right-click on your application, and then select Open File Location in the context menu. A new window will open with your application shortcut.
3.Right-click on the application or its shortcut, and then select Properties in the context menu.

![Properties](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1m1cseand6vejzs9ivq3.png)
4.Under the Compatibility tab, check the “Run this program as an administrator” box and click OK.

![Compatibility](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yyzdidegil4qlu9xk82k.png)
5.From now on, double-click on your application or shortcut and it should automatically run as administrator.