teleren/devto huggingface dataset:
Bedtime stories by AI
Tags: discuss, ai, unity3d, vitualreality
Published: 2021-06-04 06:28:05

It's not just another interactive narrative. We are talking artificial intelligence to dynamically produce story which is never repeated and is made to experience on VR.

The experience consists of two choices of agents ai, game AI and reinforcement learning. Game AI carries the story line while Reinforcement learning driven by neural networks is to change their behavior.

The project is made open source and the github repo is available at the website. Not only that, the program also calls for developers who can help build on the project.

[https://www.agence.ai/](https://www.agence.ai/)
Day 82 of 100 days of swiftui
Tags: swiftt, 100daysofcode
Published: 2021-06-04 06:22:01

I just completed day 82 of 100 days of SwiftUI. Today, I started working on the HotProspect app. I added implemented a TabView and also basic filtering in the app.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nv9w9gnuyvg6g48l80zk.png)
Highlight Highest and Lowest Value in Excel Using Java
Tags: java, excel
Published: 2021-06-04 06:19:16

As introduced in my previous article, the Free Spire.XLS for Java is able to [highlight the duplicate and unique values in Excel](https://dev.to/jazzzzz/highlight-dulicate-and-unique-values-in-excel-using-java-466n). Now this article will give another example of how to use it to highlight the highest and lowest value in a cell rang.

**Import the jar dependency**
**Method 1:** Download the [Free Spire.XLS for Java](https://www.e-iceblue.com/Download/xls-for-java-free.html) and unzip it, then add the Spire.Xls.jar file to your project as dependency.

**Method 2:** Directly add the jar dependency to maven project by adding the following configurations to the pom.xml.
```xml
<repositories>
        <repository>
            <id>com.e-iceblue</id>
            <name>e-iceblue</name>
            <url>http://repo.e-iceblue.com/nexus/content/groups/public/</url>
        </repository>
</repositories>
<dependencies>
    <dependency>
        <groupId>e-iceblue</groupId>
        <artifactId>spire.xls.free</artifactId>
        <version>3.9.1</version>
    </dependency>
</dependencies>
```

**Sample Code**
```java
import com.spire.xls.*;

import java.awt.*;

public class HighlightTopBottom {

    public static void main(String[] args) {

        //Create a Workbook object
        Workbook workbook = new Workbook();

        //Load the sample Excel file
        workbook.loadFromFile("test.xlsx");

        //Get the first worksheet
        Worksheet sheet = workbook.getWorksheets().get(0);

        //Apply conditional formatting to range "D1:D9" to highlight the highest value
        ConditionalFormatWrapper format1 = sheet.getCellRange("D1:D9").getConditionalFormats().addCondition();
        format1.setFormatType(ConditionalFormatType.TopBottom);
        format1.getTopBottom().setType(TopBottomType.Top);
        format1.getTopBottom().setRank(1);
        format1.setBackColor(Color.red);

        //Apply conditional formatting to range "D1:D9" to highlight the lowest value
        ConditionalFormatWrapper format2 = sheet.getCellRange("D1:D9").getConditionalFormats().addCondition();
        format2.setFormatType(ConditionalFormatType.TopBottom);
        format2.getTopBottom().setType(TopBottomType.Bottom);
        format2.getTopBottom().setRank(1);
        format2.setBackColor(Color.CYAN);

        //Save the document
        workbook.saveToFile("output/HighestLowestValue.xlsx", ExcelVersion.Version2016);
    }
}
```

**Output**
![HighestLowestValue](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/pcjr0zkno4vatj1rw4fj.jpg)
374. Guess Number Higher or Lower
(javascript solution)
Tags: algorithms, javascript
Published: 2021-06-04 06:09:54

###Description:
We are playing the Guess Game. The game is as follows:

I pick a number from 1 to n. You have to guess which number I picked.

Every time you guess wrong, I will tell you whether the number I picked is higher or lower than your guess.

You call a pre-defined API int guess(int num), which returns 3 possible results:

-1: The number I picked is lower than your guess (i.e. pick < num).
1: The number I picked is higher than your guess (i.e. pick > num).
0: The number I picked is equal to your guess (i.e. pick == num).
Return the number that I picked.

###Solution:
Time Complexity : O(nlog(n))
Space Complexity: O(1)

```javascript
var guessNumber = function(n) {
    let left = 1, right = n
    
    while(left < right) {
        const mid = left + Math.floor((right-left)/2)
        const current = guess(mid)
        if(current === 0) return mid
        if(current === -1) right = mid
        else left = mid+1
    }
    return left
};
```
🔥 Function Call in JavaScript - Part 1
Tags: javascript
Published: 2021-06-04 06:07:51

A call to execute the statement which are present inside and method is called function call/function invoke. 

Ex: Below example has a function expression by name greet() which accepts the parameters "name". greet("Tej") is the method call to execute all those statement which are in between { } which is called as function scope. 

☑️ Part 1: 

Part one takes about the function returning variables(char, string, number, boolean as the return data type

There are several types of function calls as mentioned below. 

☑️1. The called function returning value

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

Output: 
![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a6cv7vnvb1qyl0fi9duk.png)
 
 
☑️2. The called function not returning value

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/02o5jp1zshhpwcdrz2ct.png)

Output: 

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

☑️3. The called function returning variable as value

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/10ho3zrprf3c38gmygd6.png)

Output: 

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

☑️☑️☑️ More Examples:  


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

 Output: Try it out

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

Output: Try it out

☑️Note: Part 1 consists of #1, #2 and #3 from the above examples.
Roadmap of Frontend Developer
Tags: webdev, html, css
Published: 2021-06-04 06:04:53

Welcome to my 2nd blog, today we talked about roadmap of Frontend Development, So let get started.

![Roadmap of Frontend Developer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rb9gu386f4slbigqh644.png)

The above image is the roadmap of Frontend Development, which is decided to be followed.

The main topic are as follows:-
- Internet
- HTML
- CSS
- Java Script
- Version Control System
- Package Manager
- Build tools 
- Any Framework
- Modern CSS
- Any CSS Framework
- Testing app

These above topic are some main topic that I will focus. 

If you want complete roadmap than click this link below:-
https://roadmap.sh 

I hope you understand the roadmap of a web developer. So that's all for now, and I'll see you in the next blog.
Project 75 of 100 - An Introduction to Three.js
Tags: javascript, 3d, vite
Published: 2021-06-04 05:45:53

*Hey! I'm on a mission to make 100 React.js projects. Please follow my dev.to profile or my [twitter](https://www.twitter.com/jwhubert91) for updates and feel free to reach out if you have questions. Thanks for your support!*

Link to today's deployed app: [Link](https://100-react-projects-day-75-three-js-planet-plane.netlify.app/)
Link to the repo: [github](https://github.com/jwhubert91/100daysofreact/tree/master/day-75-three-js-intro)

No long post today because I just ran a half-marathon and am completely beat. You're also going to get mad at me because this is a pure Javascript project and not React. But wait- is it possible there's some link here between Vanilla JS and React?

One of the biggest takeaways for me from this project is Vite, a lightweight bundler that allows you to use node packages in your project without React. No configuring webpack like the old days, just type `npm run dev` in your browser and you're ready to code. It was remarkably easy to use and felt familiar to create-react-app.

Here ([link](https://www.youtube.com/watch?v=Q7AOvWpIVHU)) is the wicked tutorial from Fireship on Three.js- I had an absolute blast making this. Tomorrow maybe a React version?

The only issue I ran into is that Vite seems to perform a chunking operation on build that doesn't allow any dependencies to be above 500k, which is why some cool graphics are not showing on the live project site (link at top).

Still though, I couldn't help but think of all of the wonderful possibilities for Three.js- from [Oneohtrix Point Never](https://www.youtube.com/watch?v=deNNFkbO5xg) to [Homer Simpson](https://www.youtube.com/watch?v=KphaTbU7-Iw).

**If you like projects like this and want to stay up to date with more, check out my Twitter [@jwhubert91](https://twitter.com/jwhubert91), I follow back! See you tomorrow for another project.**
Why CRM is Important for Every Business
Published: 2021-06-04 05:45:19

We'd all like to improve our customer relations. 
We want to get the information we need about our customers as soon as possible. You can learn more about [What is CRM](https://www.prosoftly.com/what-is-crm/)?
But how are we going to accomplish it? Is it really necessary to do all of this with CRM? 
Here's why CRM (Customer Relationship Management) is so important:

[CRM Software](https://www.prosoftly.com/) is critical since it gives organizations a competitive advantage. It essentially solves certain fundamental pain points that businesses often struggle to solve.

Managing information flow is one of these annoyances. You'll have customer data and market intelligence on a single cloud-based platform if you use a CRM. If you're working with a lot of data (for example, if you have hundreds of thousands of customers), this signifies a lot. This could be the most essential reason to invest in CRM software. It improves operational efficiency by decreasing wasted time spent attempting to obtain additional information about customers. There will be no data loss because it is on a cloud-based platform. Furthermore, these are very secure technologies that can keep your personal information safe. 

CRM aids you in better understanding your customers when it comes to marketing. Using CRM's increased analysis, you'll know exactly what customers want, need, and demand from you. You'll be able to readily uncover fresh sales chances if you understand your customers' wants. This is the beginning of a cycle. To begin, you use some of the system's functions, such as marketing automation, to contact your potential customers. It's fantastic if you create a sales opportunity. Then you'll share information about that customer with other business. As a result, everyone will be aware of it.
BEST MUSTARD MUDCLOTH IN CALIFORNIA

Published: 2021-06-04 05:20:51

From our makers to the homes of our customers, Mali Empire Mudcloth is all about family. It is with great pleasure that we bring hand-woven, organic cotton fabric to you - the pride of our country. Our warehouse/showroom is now located in thriving downtown Los Angeles.

[mali mud cloth](https://www.malimudclothinc.com/)
Eval is evil - Why we should not use eval in JavaScript
Tags: javascript, node, security
Published: 2021-06-04 05:14:08


> *Eval is evil.* - Some frustrated JavaScript engineer

I recently read this quote on the internet and although it is funny, it got me thinking *why would someone say this?* Thus this post. In this post, we will see why we should not use eval in JavaScript.

## Introduction to eval

To understand why to avoid eval, we first need to understand what eval is. We are not going deep into what eval is and why it exists. We will see its definition and a simple example. If you want to learn more about eval, here is a [great post on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/eval).

> The eval() function evaluates JavaScript code represented as a string.

Eval is a function in JavaScript that expects a string as a parameter and executes that string as code. If you pass an expression to it, it will execute that expression. If you pass multiple JavaScript statements to it, it will execute those statements. As simple as that. Let us check an example to understand more.

```jsx
console.log(eval('2 + 2'));
// Output: 4
```

## Why not use eval?

After learning about the eval, you might be wondering why this post is against using eval? After all, it is such a powerful feature.

But as we all know, **Great power comes at a cost.** In eval’s case, the costs are performance, security, and difficulties in debugging. Let us look at them one by one.

### Performance

As we can see, the string passed to eval for execution is dynamic. So there is no way our JavaScript code knows about this string. That is why, when JavaScript wants to execute this string, it has to interpret/compile that string at runtime. This tends to be very expensive in terms of performance if the string is complex.

### Security risks

Usage of eval involves pretty high risks of running malicious code. Let us say you are accepting an expression from the user in an input box. And some mischievous user types in an infinite loop. This is going to be very dangerous especially if eval is used on the server-side.

### Difficulties in debugging

Let us all admit that we have spent hours debugging the smallest bugs like missing semicolons. Imagine finding bugs that are caused by the dynamic code that JavaScript is trying to execute. If the eval is causing some side effects in your runtime environment, it gives us very little room for finding the issues.

## Are there any other alternatives?

Fortunately, there is an alternative with [window.Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function) which will almost do the same thing. But this is a simple alternative. There are things that are only possible with eval. But be sure to be very careful when using eval and only use it if it is an absolute necessity. You will probably find better alternatives on StackOverflow.


*This article was [originally published here](https://www.amitkhonde.com/blog/why-we-should-not-use-eval-in-javaScript). For more such interesting reads, [visit my blog](https://www.amitkhonde.com/blog).*
How To Get Current User Location in Laravel 8?
Tags: laravel, php, programming, tutorial
Published: 2021-06-04 04:18:00

<p>Hi Guys</p>

<p>Hello friends today i will share you how to get current user location in laravel 8 and other version in laravel ,so you can just following to the my alfl step and learn to the get current user location in laravel.</p>

<p>In this tutorial i am going to show you how we can track user ip address and can find user location information from ip address.</p>

more..

https://codingtracker.blogspot.com/2021/06/how-to-get-current-user-location-in.html
How to take command line arguments in NodeJS?
Tags: node, javascript, terminal, terminalcommand
Published: 2021-07-23 14:01:02

---
title: How to take command line arguments in NodeJS?
published: true
date: 2021-06-04 04:07:54 UTC
tags: Nodejs,JavaScript,terminal,terminalcommand
canonical_url: https://livecode247.com/how-to-take-command-line-arguments-in-nodejs
---

Taking arguments from the command line is very common. You can take certain arguments you need as variables, certain flags, etc. In NodeJS, it's very easy

## Process Object

NodeJS exposes an array of argument values in the form of `process.argv`.

## Example

`index.js`

```
console.log(process.argv)

```

`Command Line`

```
node index.js arg1 arg2 arg3

```

`Output`

```
[
  '/usr/local/Cellar/node/16.0.0/bin/node',
  '/Users/username/Code/arg/index.js',
  'arg1',
  'arg2',
  'arg3'
]

```

The first element of the array is the Node Executable file in your machine. The second element is the file you're running. You can now take the arguments with indexes 2, 3, 4, etc. like `process.argv[2]`, `process.argv[3]`, etc.

But a nicer way would be to remove the first two elements from the array like so`index.js`

```
const args = process.argv.slice(2)
console.log(args)

```

`Output`

```
['arg1', 'arg2', 'arg3']

```

You can also use this way to take flags from the command line like `-s,`-o`,`--help`, etc, like in my [Airtable Url CLI](https://github.com/kavin25/airtable-url-cli).
But, a better way would be to use a third party library like`yargs`. It can really make this much easier and with lesser code.

## Reference

1. https://nodejs.org/en/knowledge/command-line/how-to-parse-command-line-arguments/
10+ Best JavaScript Animation Libraries to Use in 2021
Tags: javascript, beginners, design, css
Published: 2021-06-04 03:44:45

🚀 Anime.js

JavaScript Animation libraries.

Let’s start this list of JavaScript animation libraries with Anime.js. This lightweight animation library clocks 35K+ stars on GitHub. Working from a single powerful API, you can use it to animate HTML, CSS, JS, SVG and DOM attributes.

🚀 Velocity.js

Velocity.js combines the best of jQuery and CSS transitions. It rates close to 17K stars on GitHub and boasts of prominent users like WhatsApp and Mailchimp. Looping, reversing, delaying, hiding/showing elements, property math (+, -, *, /), and hardware acceleration, all form part of the features.

🚀 Popmotion

At close to 18K stars, Popmotion is a functional animation library for any JavaScript environment. It can work with just about any API that accepts numbers as inputs such as React, Three.js, A-Frame.

{% link https://dev.to/priteshbhoi/the-8-best-programming-languages-to-learn-in-2021-3ce1 %}

🚀 Three.js

Three.js tops this list of JavaScript animation libraries with 60K+ stars on GitHub. It’s dependent on WebGL to create and render 3D animations in the browsers.


🚀 GreenSock JS

GreenSock’s GSAP works with a set of small JavaScript files that make animations look great in all major browsers.

🚀 AniJS

Among the JavaScript libraries in this list, AniJS is somewhat unique. It allows you to add animations to elements in a simple ‘sentence-like’ structure, great for folks new to animation. 

🚀 Mo.js

Motion graphics has a big part to play in animations, and Mo.js is one option with which you can make an impact. With a number of tutorials and demos to help out, beginners may not find it hard to create geometrical shapes and time animations to the dot.

🚀 Vivus.js

If you wish to mimic a pen drawing on a screen in real-time, you’ll hit the mark with Vivus. It lets you animate SVGs giving the impression of being drawn. 

🚀 ScrollReveal JS

If you wish to animate your web elements as they scroll into view, ScrollReveal won’t disappoint. This easy to learn animation library has zero dependencies and 18.5K+ stars on GitHub.

🚀 Typed.js

Typed.js is a simple library (more of a plugin, really) to animate typing on your screen.

🚀 Lottie by AirBnB

Lottie is a lightweight animated graphics format that balances high quality graphics against the cost of rendering them. It makes applications smaller and includes dynamic features. 
Thanks ❤️

{% link  https://dev.to/priteshbhoi/how-much-do-developers-make-2nml %}
Type-Safe Relation Expression for TypeORM
Published: 2021-06-04 03:10:18

[TypeORM](https://typeorm.io/) is an amazing JavaScript/TypeScript ORM library. With TypeORM, you can safely query any database to fetch whatever data you want.

However, [`relations` option](https://typeorm.io/#/find-options/) in `find` API, which is used when you need other entities connected by foreign constraints at the same time, is just typed as `string[]`. This may cause unexpected regression when you alter table column names.

Let's take a typical data model of `User`s and `Organization`s for example.

```typescript
type Organization = {
  id: number;
  name: string;
  users: User[];
}

type UserRole = {
  id: number;
  type: string;
};

type User = {
  id: number;
  name: string;
  organization: Organization;
  roles: UserRole[];
};
```

Assume you have `User`'s id and want to retrieve all `User`s that belong to its organization with their roles, then you need to pass `"organization.users.roles"` to `relations` option.

```typescript
userRepository.find({
  where: { id },
  relations: ["organization.users.roles"],
});
```

TypeScript provides no support at all! :scream:

This problem can be solved with TypeScript's new feature called [template literal types](https://www.typescriptlang.org/docs/handbook/2/template-literal-types.html).

```typescript
type RelationInner<
  T,
  Key,
  Depth extends number,
  CurrentDepthArray extends unknown[]
> = Key extends keyof T & string
  ? T[Key] extends Function | string | number | symbol
    ? never
    :
        | Key
        | (CurrentDepthArray["length"] extends Depth
            ? never
            : `${Key}.${RelationInner<
                T[Key] extends (infer R)[] ? R : T[Key],
                keyof (T[Key] extends (infer R)[] ? R : T[Key]),
                Depth,
                [unknown, ...CurrentDepthArray]
              >}`)
  : never;
type Relation<T, Depth extends number> = RelationInner<T, keyof T, Depth, []>;
```

Template literal types enables developers to concatenate or split arbitrary strings in a similar syntax to JavaScript's template literals.

Together with [distributive conditional types](https://www.typescriptlang.org/docs/handbook/2/conditional-types.html#distributive-conditional-types), you can recursively join deeply buried property names with periods.

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

Don't forget to limit recursion depth! Otherwise you will end up getting errors like `Type instantiation is excessively deep and possibly infinite`.
Code Smell 74 - Empty Lines
Tags: codenewbie, tutorial, oop, programming
Published: 2021-06-04 03:06:52

*Breaking the code to favor readability asks for refactor.*

> TL;DR Don't add empty lines to your methods. Extract them!

# Problems

- Readability

- Kiss

- Low Reuse

# Solutions

1. Extract Method

2. Refactor

3. Remove unneeded lines.

# Sample Code

## Wrong

[Gist Url]: # (https://gist.github.com/mcsee/3e7f0a453f04d443a98d3ffd99d9bfde)
```php
<?

function translateFile() {
    $this->buildFilename();
    $this->readFile();
    $this->assertFileContentsAreOk();
    //A lot of lines more
    
    //Empty space to pause definition    
    $this->translateHiperLinks();
    $this->translateMetadata();
    $this->translatePlainText();
    
    //Yet Another empty space
    $this->generateStats();
    $this->saveFileContents();
    //A lot of more lines
}
```

## Right

[Gist Url]: # (https://gist.github.com/mcsee/13ce5551b29a588db5dbb9903d714b84)
```php
<?

function translateFile() {
    $this->readFileToMemoy();
    $this->translateContents();
    $this->saveFileContents();  
}
```

# Detection

This is a policy smell. Every linter can detect blank lines and warn us.

# Tags

- Readability

- Long Methods

# Conclusion

Empty lines are harmless, but show us an opportunity to break the code into small steps.

If you break your code with comments, it is also a code smell asking for a refactor.

# Relations

{% post https://dev.to/mcsee/code-smell-03-functions-are-too-long-4hji %}

# Credits

Photo by <a href="https://unsplash.com/@sigmund">Sigmund</a> on <a href="https://unsplash.com/s/photos/empty">Unsplash</a>
  

* * *

> It’s OK to figure out murder mysteries, but you shouldn’t need to figure out code.  You should be able to read it.

_Steve McConnell_
 
{% post https://dev.to/mcsee/software-engineering-great-quotes-26ci %}

* * *

This article is part of the CodeSmell Series.

{% post https://dev.to/mcsee/how-to-find-the-stinky-parts-of-your-code-1dbc %}