teleren/devto huggingface dataset:
How To Move Existing & Store Future Local MongoDB Data From One Drive To Another (Hard) Drive - Windows 10
Tags: mongodb, tutorial, beginners, codenewbie
Published: 2020-07-17 23:34:00

Hello Fellow Codenewbies 👋,

It all started with my computer's lack of space for C: drive. 
Finally, I moved all projects and personal folders to the D: drive to make more space in the C: drive.

And then, the time came when I wanted to continue one of my NodeJS with MongoDB projects.

When I run `mongod`, it throws me a `shutting down with code: 100` error as below.

![mongod shutting down with code 100](https://dev-to-uploads.s3.amazonaws.com/i/7dmnaxrb391x411q4229.jpg)

I faced chains of errors afterward.

I've Googled only to find plenty of results to fix the errors with either Linux or macOS and barely saw anything for Windows 10.

I had two choices:
1. Uninstall and re-install MongoDB with a new database path.
2. Go through a series of trials and errors to adapt the Linux or macOS steps for Windows 10.

As painful as it is, I've chosen the second way so I can help others who want to do the same.

Without further ado, below is how I did it.

***

## What I Want To Achieve
* Move existing MongoDB databases from C: to D: drive
* Store future databases in D: drive

## How I Achieved It

1. Make sure that `mongod` doesn't run in the background. You can close it with `ctrl + c` if it still runs.
1. Create a folder named `data` with subfolder `db` in D: drive (or any other location that you prefer)
2. Run this command in **Windows PowerShell (Admin)**
     
     ```bash
     mongod --dbpath="D:\data\db"
     ```
     Change the path to where you created your new data folder, and make sure you put the path *inside the quote*.
3. Exit `mongod` with `ctrl + c`
4. Copy/cut & paste existing data from the data folder in drive C: to D:
5. Make sure that the `mongod.lock` file is empty. Otherwise, you can delete it. This step won't damage anything and will be automatically regenerated when you run `mongod`. (When it's not empty, it will throw an error & `mongod` will automatically shut down.)
 
✔ Your existing data now should have been moved, and you can start to get your data stored in the new directory when you work with one.

---

Thank you for reading!
Last, you can find me on [Twitter](https://twitter.com/@AdiatiAyu). Let's connect! 😊
Which video game did you first modify and how?
Tags: discuss, programming, gamedev, game
Published: 2020-07-17 23:19:23

---
title: Which video game did you first modify and how?
published: true
description: The first game I modified was Monster Truck Madness. I changed the physics of my vehicle to make the game ridiculous. What did you do?
tags: #discuss #programming #gamedev #game
//cover_image: https://direct_url_to_image.jpg
---
The first game I modified was Monster Truck Madness. I changed the physics of my vehicle to make the game ridiculous. What did you do?
Automated Cross-Platform Git Hooks with npm
Tags: git, hooks, npm, node
Published: 2020-07-17 23:10:58

[Git hooks](https://git-scm.com/docs/githooks) are a convenient way to help developers sanitize code automatically. Git supports a hook for virtually every Git action. A popular use case is leveraging `pre-commit` to lint code.

For better or for worse, Git hooks are not committed as part of the repository. Every developer manually installs the team's Git hooks for that repo. There must be a better way.

Not wanting to reinvent this wheel, I searched for [pre-made solutions](https://githooks.com/) but they didn't meet my requirements: simple, cross-platform, no additional third-party tools. Their typical requirements or limitations:
* Manual creation of YAML or `.rc` configuration files, or scripts in a non-native hook format.
* Installation of heavy dependencies (Python, Ruby...). Remember, every developer who works on the repo has to install those dependencies.
* Platform-specific scripts (*NIX or Windows only, not both).

## Getting out of the way

Ramp up time is crucial. Don't burden new developers with dozens of manual setup steps. Let the computer do the grunt work so that humans can get stuff done.

Projects that use npm or yarn are very likely to have Node installed, and I leveraged that for cross-platform support.

[node-git-hooks](https://github.com/peacechen/node-git-hooks) is deployment- and CI-friendly. It won't install the hooks if your library is used by another project, avoiding the error `Appears to be a git repo or submodule`.

## Installation

> npm install node-git-hooks --save

Writing Git hooks should be fast and straight-forward. I kept it as close to the metal as possible. The hooks files are written exactly the same as they exist in the `.git/hooks` folder. Create a `.githooks` folder and place hooks files inside. An example `pre-commit` script that performs linting:
```
#!/bin/sh
# Lint all files under the `src` directory
./node_modules/.bin/eslint src
```

Perhaps surprisingly, the above hook works on both *NIX and Windows. I recommend using a current version of npm or yarn. Older versions may not be as cross-platform friendly.

Finally, add the following `prepare` script to package.json:
```
"scripts": {
  "prepare": "node-git-hooks"
},
```

With the above steps in place, running `npm install` (or `npm run prepare`) copies the hooks files from `.githooks` to `.git/hooks`.  The hooks files may be committed to the repo and will be automatically installed to other devs' repos when they run `npm install`.

## Summary

I hope that this helps more teams adopt Git hooks. Source code is available at [node-git-hooks](https://github.com/peacechen/node-git-hooks). Comments and PRs are welcome!
Você entra em flow programando?
Tags: ptbr, productivity, psychology
Published: 2020-07-17 22:53:22

Flow, também conhecido como estado de fluxo, é um estado mental em que o indivíduo está totalmente imerso no que está fazendo, despertando um sentimento de envolvimento e enorme satisfação no decorrer da atividade.

_Conceito criado pelo psicólogo húngaro Mihaly Csikszentmihalyi_
Can we retry failed tests with testng? IRetryAnalyzer
Tags: testing, java, testng, selenium
Published: 2020-07-17 22:42:40

Automation runs could fail for an endless number of reasons:
- Flaky tests,
- Running environment not steady,
- Bugs,
- Changes in selectors,
- Framework problems,
- And so on and so forth...

One of the aspects we definitely need to take into count is to investigate the **root causes** why the testcases fail, but in this post I want to bring up another topic.

If the team wants to rerun the failing tests under certain conditions, the different frameworks and programming languages usually offer diverse mechanisms that could let us re-run testcases programmatically.

Knowing that "Selenium-java" is still relevant and many people still use frameworks such as **testng**, I want to bring up the specific feature that **testng** offers, because it's a feature that's been available for quite a long time, and one I hadn't taken advantage of it, up to recently.

It's pretty straight forward, all what we have to do is to add the **retryAnalyzer** property to the test decorator and create the class that handles the logic for the retry.

Let's look at the following chunck of code as an example:

1. First we add the property.

```java
@Test(retryAnalyzer = DynamicRetryAnalyzer.class)
    public void verifyWidgetOnPage()  {
        runTheTest();
    }
```

2. Then we create the class with the logic to retry your tests.

```java

import org.testng.IRetryAnalyzer;
import org.testng.ITestResult;

public class DynamicRetryAnalyzer implements IRetryAnalyzer {

    int count = 1;
    int maxRetryCount=2;

    @Override
    public boolean retry(ITestResult iTestResult) {
        if(count<maxRetryCount){
            count++;
            return true;
        }
        return false;
    }
}
```

In this specific example the framework will retry a fail test an extra time no matter what (just if it fails). The example is kind of simple, but, I think we get the picture. If we need any specific logic to evaluate wether we should rerun a test or not, we do it by changing the logic inside the **public boolean retry(ITestResult iTestResult)** method. 

The only thing we need to make sure is to implement the **IRetryAnalyzer** interface and override the **retry(ITestResult iTestResult)** method with the logic that we need to evaluate if we should rerun the test or not.

I hope this helps anyone!

> *"A test which fails is not always flaky!"*
Need suggestions in creating a JavaScript
Tags: googlecloud, javascript
Published: 2020-07-17 22:38:15

I want to work with two Google sheets at once. I have a row of data from cell B2 to G2. Everytime I open the sheet, I add another row under this one. I want to write a script to copy cell B2 to cell C4 of another sheet (let's call anothe sheet as sheet2). Similarly, for cell C2 to Cell D4 of sheet2 and so on.
I want all the cells till G2 to be copied to desired cells in sheet2 with the help of this script mapped to a button.I want the script to reset once the contents are pasted in sheet2 such that the counter sets to B3 now. 

Furthermore, I want a script in a button to clear the contents of the desired cells by clicking once.

Any suggestions?

Many Thanks
One time URL or Hidden URL?
Tags: url, urlshortner, privatelink, privacy
Published: 2020-07-17 22:33:27

---
title: One time URL or Hidden URL?
published: true
description: Have you ever wanted to share an URL without actually showing the exact URL?
tags: URL, urlshortner, privatelink, privacy
//cover_image: https://direct_url_to_image.jpg
---

Have you ever wanted to share an URL without actually showing the exact URL? I mean, just a one-time URL. The receiver won't get a chance to access it again. Also, the receiver is unable to save it, bookmark it, or memorize it and access it.

https://safenote.co/private-link

I know this is something new, something innovative. I'm just asking your support to brand this correctly. Please feel free to share your ideas.
Recap / Summary of the week #29
Tags: devjournal, azure, opensource, showdev
Published: 2020-07-17 22:26:27

---
title: Recap / Summary of the week #29
published: true
date: 2020-07-17 22:22:00 UTC
tags: devjournal,azure,opensource,showdev
canonical_url: http://www.frankysnotes.com/2020/07/recap-summary-of-week-29.html
---

Every Friday, I will share a recap of the week and at the same time a summary of my streams. Those videos are at least two hour longs, so I thought a short summary to know if topic interest you could be useful.

{% youtube xArPcMSwKOQ %}  

#### Useful Links:

- Stream 111 - Back to TinyBlazorAdmin: [c5m.ca/stream-ep111](https://c5m.ca/stream-ep111)
- Stream112 Learning Node.js for the first time: [c5m.ca/stream-ep112](https://c5m.ca/stream-ep112)
- 5 ways to Manage Azure Resources: [c5m.ca/ep-61](https://c5m.ca/ep-61)
- My Twitch: [twitch.tv/fboucheros ](https://www.twitch.tv/fboucheros%C2%A0)
- Microsoft DeveloperTwitch: [twitch.tv/microsoftdeveloper](https://www.twitch.tv/microsoftdeveloper)

  

~☁️
Leverage tree shaking with modular Lodash
Tags: javascript, tutorial, webdev
Published: 2020-07-17 22:21:26

A follow up to [replacing Redux with React Components](https://dev.to/rsa/replacing-redux-with-react-contexts-1hj8), I'm using the [ES module version of Lodash](https://www.npmjs.com/package/lodash-es) to leverage tree shaking with [Parcel](https://parceljs.org/).

---

[Lodash](https://lodash.com/) is the Swiss army knife of Javascript, but being so useful makes it huge. Analyzing our bundle with [Bundle Buddy](https://bundle-buddy.com/bundle) reveals Lodash is responsible for 70 KB of the bundle. Not the largest chunk, but one we can easily fix: it is not being tree shaken.

[Tree shaking](https://developer.mozilla.org/en-US/docs/Glossary/Tree_shaking) is the concept of removing dead code (that is, code paths that are never accessed) from the final bundle. We use only 8 functions from Lodash, namely: `groupBy`, `keyBy`, `isEqual`, `sortBy`, `times`, `uniq`, `uniqBy` and `xor`. Lodash has hundreds of functions and we don't need everything.

There are several manners of doing that, my chosen one is replacing with [lodash-es](https://www.npmjs.com/package/lodash-es) and leaving dead code elimination to the bundler. You can also use [babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash) but I didn't find that as easy to set up.

I then ran `sed -i -e "s/'lodash'/'lodash-es'/" src/**.ts*` to replace all imports, after replacing the package in `package.json`.

This reduced the JS bundle by over 50 KB, with `lodash-es` now using only 19 KB!

Cover image by Johann Siemens ([see in Unsplash](https://unsplash.com/photos/EPy0gBJzzZU)).
Linux by example - Grep and Bash
Tags: linux
Published: 2020-07-17 22:19:50

---
title: Linux by example - Grep and Bash
published: true
description: We are in our new Linux environment and create BASH the Bourne Again SHell that we will use for our command-line environment and grep to find text using regular expressions.
tags: linux
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/kypsvjk20ok0wnem19sg.jpg
---

{% youtube LtlovbPZXU0 %}

We are in our new Linux environment and create BASH the Bourne Again SHell that we will use for our command-line environment and grep to find text using regular expressions.
A web-based desktop environment
Tags: node, typescript, react, linux
Published: 2020-07-17 22:00:44

For the last 2 weeks I have been working on a new project of mine called "web desktop environment" (temporary name) and now I finally feel like the project is in a stage where it is ready to be shared with the world so...

{% github https://github.com/shmuelhizmi/web-desktop-environment %}


# ❓ so what exactly is "web desktop environment"

So one big thing that sperate a typical Linux server from a regular PC is that your PC probably run something called a ["desktop environment"](https://en.wikipedia.org/wiki/Desktop_environment) while a server main interface would probably be a [text-based command line](https://en.wikipedia.org/wiki/Command-line_interface) or some sort of a [Control Panel](https://en.wikipedia.org/wiki/Web_hosting_control_panel),
the reason for that is that the typical visual desktop environments will be too "heavy" and is most likely not design to run on something so performance optimizes like a server.

now the target of the "web desktop environment" software is to provides an easy to use, slim visual desktop environment that is designed to run on something like a server or any sort of small Linux machine. That way server management can become something that even less savvy people can do too, since they no longer need to deal with a command line.


# 🏞 a dark theme screenshot

![Dark theme](https://dev-to-uploads.s3.amazonaws.com/i/fh1xfy9juo7qec8bu8um.png)

# 🎥 demo video

{% vimeo https://vimeo.com/439549021 %}


# 👨🏾‍💻 👩🏾‍💻 So let's get into the details
"web desktop environment" is made out of two main packages a NodeJS server app - for the server and a React web app - for the client both are written in Typescript and are using [Mce/Reflow](https://github.com/mceSystems/reflow) to communicate between them.

# 🙃 I'm currently looking for a better name

the project name is currently "web desktop environment" which is a bit dry if you have any better idea for a name it will be great if you can comment it in the discussion below, thanks!!


# More....
If all or just some of that sounds interesting for you fill free to check the project out in [`github/shmuelhizmi/web-desktop-environment`](https://github.com/shmuelhizmi/web-desktop-environment).

{% github https://github.com/shmuelhizmi/web-desktop-environment %}

# Continue reading ->
{% link https://dev.to/shmuelhizmi/a-web-based-desktop-environment-two-months-later-48go %}
A awesome integrated continuous testing tool
Tags: tdd, testing, javascript
Published: 2020-07-17 21:42:45

---
title: A awesome integrated continuous testing tool
published: true
description: Wallaby.js as integrated continuous testing tool
tags: TDD, Testing, Javascript 
//cover_image: https://img.devrant.com/devrant/rant/r_1969391_w5WBp.jpg
---

Using tests to stamp out my ideas into functional code has worked well for me. Sometimes I use TDD (Test Driven Development) sometimes I take more of a BDD (Behaviour Driven Development) approach. 

I am not going into much detail on test driven development here, there are already great resources for that online. To quickly summarise, TDD is a software development practice where you write a test/behaviour before the code that will make them pass. Once the test passes you clean up the code and start with the next test. Also known as the Red Green Refactor cycle.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/x4d7mpdo6p8q98fkbq80.jpeg)


To be honest, I used to think TDD was just a good idea in theory, but never had enough time to really use it on my work projects as there were always pressures of deadlines and tight budgets. I slowly began to use TDD on my side projects using tools that continuously watched my test and ran them in the terminal watching for test failures. Then I discovered [Wallaby.js](https://wallabyjs.com/), a tool that allowed me to see my test fail in real time. 

I use Visual Studio Code as my editor with the [Wallaby extension](https://marketplace.visualstudio.com/items?itemName=WallabyJs.wallaby-vscode) installed. Real time in-line test feedback is shown directly in the IDE.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bnav52orwoj5tn6fp5dz.png)

What I also find very useful is the instant feedback on any console logs to inspect the object right there in the editor.

When opening the code being tested, you can quickly see the affected lines that have failed tests.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2qqa09za2ub0z4k2wq6k.png)

This tool has made writing my test so easy and fun and I honestly can not think of working without it. 

I don't normally spend money on dev tools. But this is one purchase that's not too hard to justify when you discover how productive you can work with it. They do have a [free trial](https://wallabyjs.com/download/) that you can use to kick the tires.

After digging around I found a similar tool for the .net world called [NCrunch](https://www.ncrunch.net/). 

I'm hoping to see more of these type of tooling in the future which can ultimately make testing a first-class citizen in the IDE.
tic tac toe for absolute beginners in python
Tags: t
Published: 2020-07-17 21:37:48

bod = ["0","1","2",
       "3","4","5",
       "6","7","8"]
def board():

    print(bod[0],'|',  bod[1],'|',  bod[2], '|')
    print('----------------')
    print(bod[3],'|',  bod[4],'|',  bod[5], '|')
    print('----------------')
    print(bod[6],'|',  bod[7],'|',  bod[8], '|')

def game():

    while True:
        board()
        spot = int(input("choose a spot(x):"))
        bod[spot] = "x"
        """if bod[spot] == "x" or bod[spot] == "o":
            print("---spot taken---")"""
        board()
        spot_two = int(input("choose a spot(o):"))
        bod[spot_two] = "o"
        """if bod[spot] == "x" or bod[spot] == "o":
            print("---spot taken---")"""

            #player_one checks
        if bod[0] == bod[1] == bod[2] =="x":
            print("player one (x) won")
            break
        if bod[3] == bod[4] == bod[5] == "x":
            print("player one (x) won")
            break
        if bod[6] == bod[7] == bod[8] == "x":
            print("player one (x) won")
            break
        if bod[0] == bod[3] == bod[6] == "x":
            print("player one (x) won")
            break
        if bod[1] == bod[4] == bod[7] == "x":
            print("player one (x) won")
            break
        if bod[2] == bod[5] == bod[8] == "x":
            print("player one (x) won")
            break
        if bod[0] == bod[4] == bod[8] == "x":
            print("player one (x) won")
            break
        if bod[6] == bod[4] == bod[2] == "x":
            print("player one (x) won")
            break

        #player_two checks
        if bod[0] == bod[1] == bod[2] =="o":
            print("player two (o) won")
            break
        if bod[3] == bod[4] == bod[5] == "o":
            print("player two (o) won")
            break
        if bod[6] == bod[7] == bod[8] == "o":
            print("player two (o) won")
            break
        if bod[0] == bod[3] == bod[6] == "o":
            print("player two (o) won")
            break
        if bod[1] == bod[4] == bod[7] == "o":
            print("player two (o) won")
            break
        if bod[2] == bod[5] == bod[8] == "o":
            print("player two (o) won")
            break
        if bod[0] == bod[4] == bod[8] == "o":
            print("player two (o) won")
            break
        if bod[6] == bod[4] == bod[2] == "o":
            print("player two (o) won")
            break
        else:
            print("---it is a draw---")
            
game()
Stop using Redux, cache requests
Tags: react, javascript, redux
Published: 2020-07-17 21:37:47

In this article, I don’t want to talk about the new state management library or compare Redux with Context API. I just want to say, in some situations, you don’t need to Redux and you can handle it by other solutions.

Imagine we have a PWA and it’s an online shop. Usually, we navigate between products and check them. When you like a product, you may check it many times and it has a bad experience if every time you should wait for getting product data from the server. We have two solutions to have a better experience.

### One. Using Redux (Not recommended)
We can use Redux and have a state to push the product data in this state. But when you have developed a large scale application, It’s not a good solution.

### Two. Cache Requests (Recommended)
CACHE REQUESTS. Why using Redux until you can cache requests?

We can have cache storage to store the requests data and when an API request called, first we looking for the response in the cache storage, and if we don’t have it, now we need to call the API request.

We have many ways to implement this feature and I will show you some of them.

You can implement it as the following:

```
class CacheRequests {
  constructor() {
    this.caches = new Map();
  }

  set(url, response) {
    this.caches.set(url, response);
  }

  get(url) {
    return this.caches.get(url);
  }

  has(url) {
    return this.caches.has(url);
  }
}

const cache = new CacheRequests();

const Request = (url, options) => {
  if (cache.has(url)) {
    return cache.get(url);
  }
  fetch(url, options).then((response) => {
    console.log(response);
    cache.set(url, response);
  });
}
```

Or if you are using [axios](https://www.npmjs.com/package/axios), you can also use [axios-extensions](https://www.npmjs.com/package/axios-extensions) or [axios-cache-adaptor](https://www.npmjs.com/package/axios-cache-adapter) packages.