teleren/devto huggingface dataset:
A Memory Trick To Remember When to Use for...of vs for...in
Tags: javascript, webdev, programming, productivity
Published: 2022-01-11 18:00:39

*This article was originally published at https://maximorlov.com/forof-vs-forin-memory-trick/*

A way to loop through a collection in JavaScript is to use the for...in and for...of statements. Depending on whether the collection is an object or an array, you would use either one of these statements.

After 6 years of web development, I *still* couldn't remember which is which — was for...of for objects and for...in for arrays? 🤔

Then the following happened when I used the wrong loop statement:

```js
const skills = { javascript: "good", nodejs: "excellent", php: "poor" };
for (const language of skills) {
	console.log(language);
}

// Uncaught TypeError: skills is not iterable
```

Every. Single. Time. 😓

To save myself the irritation of reaching out to Google whenever I had to loop through a collection (which is often!), I came up with a mnemonic — a memory trick that helps me remember which loop statement I should use with objects and which one with arrays.

## What do for...in and for...of have to do with aliens?
The mnemonic I use that helps me decide which loop statement I need to use for objects vs arrays is to think about aliens.

Aliens?! I hear you say.

Yes, aliens.

Because what do aliens fly in? UFOs! 🛸

UFO stands for Unidentified Fly**in**g **Object**. Therefore, I know that for...**in** is used to iterate through the keys of an **object**.

Aliens -> Unidentified Fly**in**g **Object** -> for...**in** **object**

That's it! 💡

```js
const skills = { javascript: "good", nodejs: "excellent", php: "poor" };
for (const language in skills) {
	console.log(language);
}

// Output:
// "javascript"
// "nodejs"
// "php"
```

Now it works! Yay. 🎉

> Note: A more common use case is to iterate through the values of an object, or both the keys and the values. In that case, I prefer to use `Object.entries()` (or `Object.values()` for values only) which returns an array of key/value pairs which you can deconstruct in a neat way:

>```js
const skills = { javascript: "good", nodejs: "excellent", php: "poor" };
for (const [language, level] of Object.entries(skills)) {
	console.log(`My level of ${language} is ${level}`);
}
```

If for...in is used for objects, then for...of is used to iterate through the elements of an array.

```js
const fruits = ["mango", "pineapple", "kiwi"];
for (const fruit of fruits) {
	console.log(fruit);
}

// Output:
// "mango"
// "pineapple"
// "kiwi"
```

This little memory trick has saved me countless Google searches. I hope you'll remember it next time you have to use for...in or for...of.

Whenever you're iterating through a collection in JavaScript, just think about aliens. 👽 🛸

## Become a skilled Node.js developer

Every other Tuesday I send an email with tips on building solid Node.js applications. If you want to grow as a web developer and move your career forward with me, [drop your email here 💌](https://maximorlov.ck.page/0076aaf499).
How do I play online?
Published: 2022-01-11 17:59:56

My name is Roger, I am a game developer. Experienced in leveraging agile frameworks to provide a robust code for high level development and have a confident command over Unity3D, C#, C++, Cg/HLSL, Java working in games involving AI, Animations, UI, 3Cs, Optimization, Shader Graph, VR/AR and other technologies. 

Apart from developing games, I play a lot of games for research purposes and also love to read about them and their analysis. I am also an aspiring writer and I spend a large amount of my free time exploring the latest technology advancements in the game development world.

Most games make it really easy to play against other people online. There will probably be a “Multiplayer” option on the main menu: just click on that and follow the instructions. You may get a choice of playing “co-op” (with your friends against computer-controlled enemies) or “competitive” (playing against other people). 
At [**LF.Group**](https://lf.group/) you can  find new teammates in your favorite online games. No matter what games you play mostly - there are definitely people who perfectly match your time slots and in-game goals.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ddhcjjsem49cutxtwylc.gif)
Code Your First Rest API in Golang
Tags: go
Published: 2022-01-11 17:47:54

This tutorial would explain you about how you're going to code a basic rest api in golang,
We'd be using [gin](https://github.com/gin-gonic/gin) a http web server framework.

Let's begin.

# Getting Started

Open up your shiny Terminal,
Run the Commands
```sh
go mod init gin-tutorial
touch main.go
go get -u github.com/gin-gonic/gin
```

![Terminal](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/js2km281eaavgctg29wl.png)

Now, Let's Navigate to our main.go and start writing code with [vscode](https://code.visualstudio.com/)


On top of the file, Describe the package

```go
package main
```


Now, We'd be importing gin,

```go
package main

import "github.com/gin-gonic/gin"
```

Make sure you install gin via the command `go get -u github.com/gin-gonic/gin`

Now, We'll start making our router,

```go
package main

import "github.com/gin-gonic/gin"

func main() {
	r := gin.Default()
	r.SetTrustedProxies([]string{"192.168.1.2"})
	r.Run()
}
```
Read more about setTrustedProxies [here](https://github.com/gin-gonic/gin#dont-trust-all-proxies)


So, If we run `go run main.go`, This is what we're gonna get...

```
[GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.

[GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
 - using env:	export GIN_MODE=release
 - using code:	gin.SetMode(gin.ReleaseMode)

[GIN-debug] Environment variable PORT is undefined. Using port :8080 by default
[GIN-debug] Listening and serving HTTP on :8080

```
Now, Open up `localhost:8080` on your browser, You'd see a `404 page not found` response, Yes, Because we haven't created any routes yet.

# Creating Routes

## Get Requests
- Get requests are handled as <Router>.GET, Same applies for all types of requests, Just replace GET with the type of Request,


Let's create a test route:
```
r.GET("/get", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"status": "healthy",
		})
	})
```

So, If you now navigate to `localhost:8080/get`, You see a JSON Response
```
{"status":"healthy"}
```

Perfect!

Congratulations, You Just Learned to Create Your First Rest API With Golang.
Package.json dependencies to Markup Table Online Converter
Tags: node, javascript
Published: 2022-01-11 17:37:41

I use a lot of markup tools lately. For example JIRA, Dev.to, and others. And sometimes I have to review package.json to see what dependencies and devDependencies are not useful anymore. Or what has to be updated.

Therefore, some time ago I have written a simple tool that converts package.json, and generates a nice markup table you can use and fill with your notes.

The tool is free, and you can find a link to it below. You can also buy me a coffee if you like it, or would like more tools like this to be shared by me. Or, also, if you want any feature to be added!


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

The tool: [tool](https://tomasz-smykowski.com/tools/package-json-to-markdown-table/)
linkedin clone
Published: 2022-01-11 17:35:13

**[linkedin clone](https://www.omninos.in/LINKEDIN-clone-app-development.php)**:- LinkedIn is connecting a colossal number of master all over the planet. It has helped incredible numerous specialists open the doorway of new opportunities! The principle disservice of the stage is it's amazingly nonexclusive in nature. Our LinkedIn clone content will help you with building a compelling changed casual local area for capable. A phase zeroing in on unequivocal industry claim to fame of specialists. It will help you with acquiring authority around the assigned business strength quickly, quality traffic, more data trades, and month to month unique customers. Might you want to roll out the accompanying improvement in the business.

Read More:- **[https://www.omninos.in/LINKEDIN-clone-app-development.php](https://www.omninos.in/LINKEDIN-clone-app-development.php)**
Why I am finishing my degree
Published: 2022-01-11 17:34:02

Not only is people saying that a degree is useless, but actually not getting it.

In tech Twitter, I have seen this phenomena

I will explain why I am getting a degree and why I think it is a good deal.

### A reasonable cost for a degree

Getting my bachelor is not as costly as getting one in the US. 

Here in my country, a complete degree (excluding labs, books, and important stuff) is less than 500$, that´s worth it, considering that these are 5 years.

Also, the university is the best forming engineers in my country.

### A job without one it´s REALLY HARD

I know about opportunities overseas.

But here virtually every job description in my country requires a degree

And equivalent experience is really hard to find.

Also for the best jobs is useful for have a degree.

If I want to move abroad, a degree could be useful too, especially considering a young man doesn´t have a lot of experience.
Powerful options in cURL
Tags: webdev, programming, beginners, curl
Published: 2022-01-11 17:29:15

Most of us use cURL for GET requests.

Few less used but powerful options in cURL. A curly thread 🧵

1. Verbose output with -v
`curl -v www.cnn.com`
![verbose](https://pbs.twimg.com/media/FI4ba6FVIAI3vrw?format=jpg&name=medium)

2. Follow redirects with -L
`curl -L www.cnn.com`
![redirect](https://pbs.twimg.com/media/FI4bbJFVkAISTxo?format=jpg&name=medium)

3. Download a file with a new name with -o
`curl -o myfile.csv https://example.com/file.csv`
![download](https://pbs.twimg.com/media/FI4bbVtUcAEa8eO?format=jpg&name=medium)

4. Resume an interrupted download with -C -
`curl -C - -O https://images.unsplash.com/photo-1641762256336-16cb15d5850a`
![resume-download](https://pbs.twimg.com/media/FI4bbiyVIAEYKAX?format=jpg&name=medium)

5. Store website cookie in file with --cookie-jar
`curl --cookie-jar cnncookies.txt https://www.cnn.com/index.html -O`
![cookie jar](https://pbs.twimg.com/media/FI4bbwrUcAUUkp_?format=jpg&name=medium)

6. Send website cookies with --cookie
`curl --cookie cnncookies.txt https://www.cnn.com/index.html`
![send cookie](https://pbs.twimg.com/media/FI4bb_cVcAAitIS?format=jpg&name=medium)

7. Retry on failure with --retry
`curl --retry 5 --retry-max-time 120 https://www.cnn.com/index.html`
![retry](https://pbs.twimg.com/media/FI4bcMvVgAMrBVP?format=jpg&name=medium)


8. Use proxy for curl with or without authentication with -x and -U
`curl -x proxy.yourdomain.com:8080 -U user:password -O https://yourdomain.com/yourfile.tar.gz`
![proxy](https://pbs.twimg.com/media/FI4bcaRVIAMsXPK?format=jpg&name=medium)

9. Modify Name Resolution with --resolve
`curl --resolve www.example.com:80:localhost https://www.example.com`
![name resolution](https://pbs.twimg.com/media/FI4bcr7UUAUTUWl?format=jpg&name=medium)


10. Retrieve particular byte range with -r
`curl -r 0-20000 -o myfile.png https://images.unsplash.com/photo-1641762256336-16cb15d5850a`
![byte range](https://pbs.twimg.com/media/FI4bc4cVgAEfmRj?format=jpg&name=medium)


Want to know more. There's an actual gitbook you can refer -

Read https://everything.curl.dev


Any other powerful cURL usage which we should know ?
Yummiz
Tags: atlashackathon
Published: 2022-01-11 16:59:31




### Overview of My Submission
A web application that lists different varieties of food recipe in which users can add their own recipe as well as get data of whole process with intergradient and other info.

### Submission Category: Own Adventure

### Link to Code

Backend : (https://github.com/Naeema21/api-yummiz.git)
Frontend: (https://github.com/Naeema21/yummiz.git)


### Additional Resources / Info

Technologies 
Backend : Nodejs , express (REST API)
Database: MongoDB 
Frontend : React Js

Link to Preview :(https://yummizz.herokuapp.com/)

**Screenshots**
Home page
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tsx90qw5un4d3kdhcj32.png)

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

Recipe Details 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rnmcmcbvtrribr8lc7ks.png)
Windows - How to allow script execution on Windows
Tags: windows, script, executionpolicy, powershell
Published: 2022-01-11 16:58:58

---
title: Windows - How to allow script execution on Windows
published: true
description: Allown script execution on Windows
tags: 'windows, script, executionPolicy, powerShell'
cover_image: 'https://raw.githubusercontent.com/campelo/documentation/master/posts/assets/cover.png'
canonical_url: null
id: 951798
---

###### :postbox: Contact :brazil: :us: :fr:

[Twitter](https://twitter.com/campelo87)
[LinkedIn](https://www.linkedin.com/in/flavio-campelo/?locale=en_US)

---

## How to allow script execution on Windows

If you're trying to execute an script and you receive a message like that

![Image 1](https://raw.githubusercontent.com/campelo/documentation/master/posts/windows/allow-script-executing/assets/img1.png)

You can change your policies manually to be able to execute them. 

```PowerShell
# This sample will enable the current user to execute all of signed scripts.
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
```

![Image 2](https://raw.githubusercontent.com/campelo/documentation/master/posts/windows/allow-script-executing/assets/img2.png)

You can find further details about ExecutionPolicy on [this page](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy) from the Microsoft documentation.

## Typos or suggestions?

If you've found a typo, a sentence that could be improved or anything else that should be updated on this blog post, you can access it through a git repository and make a pull request. If you feel comfortable with github, instead of posting a comment, please go directly to https://github.com/campelo/documentation and open a new pull request with your changes.
1 line of code: How to convert spaces to tabs
Tags: javascript, webdev, productivity, codequality
Published: 2022-01-11 16:55:19

```javascript
const spacesToTabs = (str, tabsize = 4) =>
  str.replace(new RegExp(` {${tabsize}}`, "g"), "\t");
```

Returns the string and replaces all tabs with the given amount of spaces (`tab size`).

---

## The repository & npm package

You can find the all the utility functions from this series at [github.com/martinkr/onelinecode](https://github.com/martinkr/onelinecode)
The library is also published to [npm as @onelinecode](https://www.npmjs.com/package/@onelinecode/onelinecode) for your convenience.

The code and the npm package will be updated every time I publish a new article.

---

Follow me on [Twitter: @martinkr](http://twitter.com/_martinkr) and consider to [buy me a coffee](https://www.buymeacoffee.com/martinkr)

Photo by [zoo_monkey](https://unsplash.com/@zoo_monkey) on [Unsplash](https://unsplash.com/s/photos/fuji)

---

[![Subscribe to the weekly modern frontend development newsletter](https://modernfrontend.dev/banner/banner_583-111.png)](https://modernfrontend.dev/)

---
Date Between Query In Mysql
Published: 2022-01-11 16:51:57

[Get This Code: ](https://laratuto.com/date-between-query-in-mysql/)## 1: The following query:

 SELECT * FROM `users` 
 WHERE (DATE_COLUMN_NAME BETWEEN '2022-01-12 00:00:00' AND '2022-01- 
 12 00:00:00');

## 2: Second Following Query:
SELECT *
FROM `users`
WHERE (DATE_COLUMN_NAME BETWEEN '2022-01-12 00:00:00' AND '2022-01-12 00:00:00')

## 3: Third Following Query: 
Your query should be another have date as....

select * from users between `FIRST_DATE` and `TO_DATE`;
Answer: React Native backgroundColor overlay over image. How To Make a Colour Overlay on an Image in react native
Tags: reactnative, mobileappdev, reactnativetutorial, reactnativelearning
Published: 2022-01-11 16:51:19

{% stackoverflow 70670373 %}

Make an overlay on react native image background: If you want to make an overlay on the background image ONLY in react native and not affect other elements that are inside the < ImageBackground> tag, do this:

```
//Fetching the background image from online, you can use any image source of your choice.

const GoProImageBackGd = { uri: "https://images.pexels.com/photos/2462402/pexels-photo-2462402.jpeg?auto=compress&cs=tinysrgb&dpr=2&h=650&w=940" };

// Setting the background image for the view:

 <View style={styles.GoProBox}>
            <ImageBackground source={GoProImageBackGd} resizeMode='cover' style={styles.goProBgImage}>
            <View style={styles.overlayView}/>
            <Text style={styles.goProText}> Want to join the hot section? Go hot with Pro!</Text>
            <GoProButton />
            </ImageBackground>


//Stylesheet

const styles = StyleSheet.create({
GoProBox: {
        width: '95%',
        height: 200,
        margin: 5,
        backgroundColor: '#00cc00',
        borderRadius: 10,
        alignSelf: 'center',
        overflow: 'hidden'

    },
goProBgImage: {
        width: '100%', height: '100%',


    },

    goProText: {
        textAlign: 'center',
        fontSize: 20,
        marginTop: 10,
        fontWeight: 'bold',
        padding: 10,
        color: 'white'

    },
GoProButton: {
        height: 60,
        width: 200,
        backgroundColor: 'red',
        borderRadius: 15,
        alignSelf: 'center',
        justifyContent: 'center',
        top: 50
    },
overlayView: {
        height: "100%",
        width: "100%",
        position: 'absolute',
        backgroundColor: 'rgba(0, 204, 0, 0.5)',

    }

})
```
Upwork Clone App
Tags: upworkclone
Published: 2022-01-11 16:48:47

[**Upwork Clone**](https://www.omninos.in/upwork-clone-app-script.php):-

A beginner-friendly freelance job platform.To get started, create a free profile and filter between domestic and international jobs. Upwork uses its own virtual currency called Connects, which allow you to apply to jobs. You get ten Connects with the basic free plan, but if you upgrade your plan, you get 80 each month.. We Can Make a Upwork Clone Application for you.


**Read More**:- [https://www.omninos.in/upwork-clone-app-script.php](https://www.omninos.in/upwork-clone-app-script.php)
Fiverr Clone App
Tags: fiverr
Published: 2022-01-11 16:46:12

[Fiver Clone](https://www.omninos.in/Fiverr-clone-app-script.php):-Fiverr is a company built on the model of listing temporary work positions. Freelancers work in a variety of workplaces, ranging from home to office. Fiverr serves as e-commerce platform to freelancers and companies to sell their services by using their gigs
Read More: Fiverr Clone || Fiverr Clone Script || Fiverr Clone App
For More Information:
Call US: +1 585 457 5655
Email US: info@omninos.com
Visit: [https://www.omninos.in/Fiverr-clone-app-script.php](https://www.omninos.in/Fiverr-clone-app-script.php)
Thumb Rules of Unit Testing
Tags: testing, codequality, programming, computerscience
Published: 2022-01-11 16:45:07

My ideas on writing meaningful unit tests were crystallized when I read ["The Practical Test Pyramid"](https://martinfowler.com/articles/practical-test-pyramid.html#UnitTests) today.

As a novice programmer, I went in mindlessly, not knowing how to test my code.

The Practical Test Pyramid is an excellent guide, but I want to emphasize unit testing today.


## Why Write Unit Tests?
As the name suggests - you test a **"unit"** of your code.

Unit tests are beneficial in ensuring the code works as intended - it is the first step towards being confident about the logic.

> _Unit tests have the narrowest scope of all the tests in your test suite._

A service accesses a database to perform **a set of computations**; the unit tests will cover all edge cases for the performed computations. The access to the database is **"assumed"**.

## How to Write Good Unit Tests?

### Cover Non-Trivial Cases
Test for all edge cases in the code.

Typically, you won't test if input deserialization works unless you've written the library itself.

> _When it comes to unit testing, aim for **confidence coverage** and not code coverage._


### Test for Observable Behavior
Loosely couple tests and code. Refactoring code is a common practice, but refactoring unit tests is stressful.

Unit tests should always answer two questions -

> What is the input?
> _Is the output expected?_


### Structure
Tests, like your code, should be easy to read and understand.

Most supporters of TDD derive code from tests. Hence, a readable structure goes a long way in translating behaviour into code.

Use ["Given, When, Then"](https://martinfowler.com/bliki/GivenWhenThen.html)

- Given an input X
- When function Y executes
- Then the outcome is Z

Ensure you maintain a delicate balance between **DRY(Don't Repeat Yourself)** and **DAMP(Descriptive and Meaningful Phrases)**.

[Read more about why repetition is acceptable in tests.](https://stackoverflow.com/questions/6453235/what-does-damp-not-dry-mean-when-talking-about-unit-tests)


### TestDoubles
We can use various [TestDoubles](https://martinfowler.com/bliki/TestDouble.html) to replace production objects for testing purposes.

- Use _stubs_ in cases where branching logic doesn't matter. 
  We don't care if the database write fails.
- Use _mocks_ when the order and the output matter. 
  We care if the database write fails the second time.

More at [Mocks aren't Stubs.](https://martinfowler.com/articles/mocksArentStubs.html)

Let me know how you write unit tests in the comments!
I made a Peer to peer file sharing tool (DropAll)🤓
Published: 2022-01-11 16:38:09

Hi everyone, I hope you all are safe and doing great!

Dropall setups peer to peer connection between two peers using WebRTC to share files data.

To share files:
 - Create a room
 - Share QR code or the room link to anyone you want
 - Drop file 
 - Then receiver can download the file

# Features
 - Share file
 - Share Text messages

# URL
 [https://dropall.herokuapp.com/](https://dropall.herokuapp.com/)

# GitHub
 [https://github.com/notshekhar/P2P-File-Sharing](https://github.com/notshekhar/P2P-File-Sharing)

Thank you for reading 🐨🎉 Let me know your thoughts comments.

You can follow me on GitHub [@notshekhar](https://github.com/notshekhar) and Twitter [@notshekhar](https://twitter.com/notshekhar)

Bye! stay safe🌻