teleren/devto huggingface dataset:
Array.map & parseInt in JavaScript
Tags: javascript, webdev
Published: 2020-08-18 16:50:40

I saw something today posted by someone on Twitter and I thought to write a short post about it in a simple manner as the newbie that I am myself.

If you're new to JavaScript, I am sure many things look like they make sense, only to realize that the output of your code is something totally unexpected. 

What I saw was this: 

```javascript
['1', '2', '10'].map(parseInt)
```
We know that: 
1. **parseInt** function parses a string and returns an integer.
2. **map** function creates a new array with the results of calling a function for every array element.

Now, if you expected the above to output this:
```javascript
[1, 2, 10]
```
it actually outputs this:
```javascript
[1, NaN, 2]
```

This is where understanding how things behave in Javascript will come very handy.


We know that **parseInt** expects 2 arguments:
* **_string_**: The value to parse.
* **_radix_**: An integer between 2 and 36 that represents the radix (the base in mathematical numeral systems) of the string.

We also know that **map** method expects a callback as an argument. The callback itself can accept 3 arguments:
* **_the value of the element_**
* **_the index of the element_** 
* **_and the array object being mapped_**

So what happens in the example above?

Long story short, because we didn't pass the radix number (base) to parseInt, and parseInt is the callback in map, the second argument of the callback in map being the index of each element in the array, the index is passed down to parseInt as its second argument and parseInt "thinks" it is the radix (base) number.

So **_parseInt_** being the callback in **_map_**, will do this for each element of the array:
```javascript
parseInt('1', 0) 
parseInt('2', 1)
parseInt('10', 2)
```
Which will result in: 
```javascript
[1, NaN, 2]
```
For '1' in base 0, parseInt evaluates 0 as falsey and the effect is the same as not passing a radix argument and it defaults to 10 so it is like writing it parseInt('1', 10) 

For '2' in base 1, it returns NaN, because radix must be an integer between 2 and 36. 

For '10' in base 2, it evaluates to 2. 

If you want to convert array string values to integer values you could do this: 
```javascript
['1', '2', '10'].map(elem=> parseInt(elem, 10))
//output [1, 2, 10]
```


I hope this makes sense.

Happy coding!
Ruby, Videosgames & DrangonRuby Engine
Tags: ruby, gamedev, motivation
Published: 2020-08-18 16:47:56

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

As part of ongoing research on Ruby, I wanted to know what was possible with Ruby, to what extend we can push the language and the outcomes. Along with researching Ruby, I researched other languages like Python, Java, JavaScript, and C along with C++. There are many game engines for Ruby like: 

-  Gosu
-  Shoes
-  ruby 2d
-  gioco
-  rubygame
-  gamebox 

check out the [ruby toolbox](https://www.ruby-toolbox.com/categories/game_libraries) to learn more about each library. 

Although we have many libraries for Ruby, there has not been many popular games released. We have to understand why. Most games on consoles or mainstream games have dedicated engines. Example: [Frostbite Engine ](https://www.ea.com/frostbite) & [Unity](https://unity.com) are built with *c++* . These two engines are extremely powerful.

Of all the ruby engines, [DragonRuby](https://dragonruby.itch.io/dragonruby-gtk) seems to be the most developed well executed, easy to understand engine. Some game were released in the [App store](https://apps.apple.com/us/developer/amirali-rajan/id736683064) for IOS and now Nintendo Switch. 

It is a difficult task to build a Ruby Engine, Amirali Rajan explains why in this [video](https://youtu.be/o0d4sjcUfCg). Essentially, we need low level computing languages to build a structure that can then be manipulated by a high-level language like Ruby. 

So, what’s next? Does time mean there will never be a powerful engine like [Frostbite Engine ](https://www.ea.com/frostbite) or [Unity](https://unity.com) for ruby? There is a glimmer of hope. 
Ruby was never meant to be fast; it was meant to make the developers happy, but slowly and surely ruby has gotten faster. With the release of Ruby 3 (or 3x3), Ruby claims to be 3 time faster than Ruby 2.0. Ruby 3.0 is expected to be released Q4, 2020, however it is not set in stone.  This leads me to believe we could have a bright future for development for be it, mobile apps, or game application with Ruby. I cannot foresee the future, but I only hope this user-friendly (Ruby) language gets the push that it needs.
The 7 Most Popular DEV Posts from the Past Week
Tags: top7
Published: 2020-08-18 16:44:24

---
title: The 7 Most Popular DEV Posts from the Past Week
published: true
description: A round up of the most-read and most-loved contributions from the community this past week.
tags: icymi
cover_image: https://thepracticaldev.s3.amazonaws.com/i/sfwcvweirpf2qka2lg2b.png
---
Every Tuesday we round up the previous week's top posts based on traffic, engagement, and a hint of editorial curation. The typical week starts on Monday and ends on Sunday, but don't worry, we take into account posts that are published later in the week. ❤️

---

### Get progressive

@dfiredeveloper walks us through turning our already existing website into a Progressive Web App (PWA). Helpful!

{% link https://dev.to/dfiredeveloper/how-to-easily-turn-your-website-to-a-progressive-web-app-pwa-2nm4 %}

### Turning “failure” into community learnings

@raulfdm generously reflects on a recent interview that didn’t result in a job in order to share helpful takeaways.

{% link https://dev.to/raulfdm/i-failed-an-interview-because-of-an-algorithm-3f9k %}

### Shortcuts for longterm efficiency

These VS Code shortcuts were part of a talk @hannahgooding gave entitled "Why The F*** Didn't I Know This Sooner?!" 😁

{% link https://dev.to/hannahgooding/vs-code-shortcuts-and-tricks-that-i-wish-i-knew-sooner-3mcj %}

### Developer burnout: the risks, signs, and “cures”

Thanks for the reminder that burnout as a developer is an all-too-common phenomenon, @nirbhayvashisht. This post is full of super practical and actionable tips for all levels!

{% link https://dev.to/nirbhayvashisht/burnout-as-a-developer-experience-symptoms-prevention-and-cure-20e2 %}


### Sage advice

In this post, @thisismanaswini poses and explores a question we should all be asking ourselves! 

{% link https://dev.to/thisismanaswini/things-i-d-do-differently-if-i-had-to-start-with-programming-all-over-again-33m8 %}

### The elegance of the hedgehog

@rakshakannu shares a great way of looking at productivity through an unexpected metaphor.

{% link https://dev.to/rakshakannu/productivity-are-you-a-fox-or-a-hedgehog-3i72 %}

### Get active

@devdevcharlie built a Github action to automatically detect potentially toxic comments and PR reviews. Awesome! And if you’re interested in creating your own GitHub action/utilizing existing ones for a new workflow, we’re currently running a [GitHub Actions hackathon](https://dev.to/devteam/announcing-the-github-actions-hackathon-on-dev-3ljn) with GitHub!

{% link https://dev.to/devdevcharlie/creating-a-github-action-to-detect-toxic-comments-using-tensorflow-js-13bo %} 



_That's it for our weekly wrap up! Keep an eye on DEV this week for daily content and discussions...and if you miss anything, we'll be sure to recap it next Tuesday!_
How to set headers to a request dynamically in Postman
Tags: javascript, postman, prerequestscripts
Published: 2020-08-18 16:36:54

I came across a situation where I wanted to set a cookie in headers of a request dynamically using the current timestamp. I use Postman, and found that it already has newly introduced a way to modify request before sending it. 

Pre-request scripts are really helpful when you want to dynamically set your request attributes. 

[Their Sandbox](https://learning.postman.com/docs/writing-scripts/script-references/postman-sandbox-api-reference/) is  a great tool to make web development easier.

So, coming back to the challenge, setting headers dynamically in postman.

First let's start with looking at the way we can get headers of a request.

## How to get headers
It is simple, from their docs:
```
pm.request.headers
```
This code would return a list of headers in key-value pairs.
Now, how do we set a header, use 
```
pm.request.headers.upsert({key: yourKeyName, value: yourValueName})
``` 
That's it. `upsert` is better than using `add`, as `add` would just add header key but now the vaue, `upsert` adds the key value pair, but also if the key is already present, it would update the value for that key withe the newly provided one in `pm.request.headers.upsert` method.

## How to get timestamp
```
var date = new Date();
var tStamp = date.getTime();
```

now combining both code snippets to set headers, we have:
```
var tStamp = date.getTime();

pm.request.headers.upsert({
    key: "time_stamp",
    value: tStamp
});
```

And it is done, now the request would have header `time_stamp` set with the request's timestamp set as value.
To check if the headers are set correctly, just console out the headers as `pm.request.headers`.
Exploring The TileDB Universal Data Engine - Episode 146
Published: 2020-08-18 15:15:09

<p>Most databases are designed to work with textual data, with some special purpose engines that support domain specific formats. TileDB is a data engine that was built to support every type of data by using multi-dimensional arrays as the foundational primitive. In this episode the creator and founder of TileDB shares how he first started working on the underlying technology and the benefits of using a single engine for efficiently storing and querying any form of data. He also discusses the shifts in database architectures from vertically integrated monoliths to separately deployed layers, and the approach he is taking with TileDB cloud to embed the authorization into the storage engine, while providing a flexible interface for compute. This was a great conversation about a different approach to database architecture and how that enables a more flexible way to store and interact with data to power better data sharing and new opportunities for blending specialized domains.</p><p><a href='https://www.dataengineeringpodcast.com/tiledb-universal-data-engine-episode-146/'>Listen Now!</a></p>
Countdown to Hacktoberfest 2020 has started!
Tags: webdev, discuss, hacktoberfest
Published: 2020-08-18 16:27:24

---
title: Countdown to Hacktoberfest 2020 has started!
published: true
description: 
tags: webdev, discuss, hacktoberfest
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/m0vn0mhsn945jxz9121p.png
---
With more than a month to go, the countdown to Hacktoberfest 2020 has just started: [Subscribe to Hacktoberfest 2020 updates](https://hacktoberfest.digitalocean.com/?utm_medium=email&utm_source=hacktoberfest&utm_campaign=pre-launch_&utm_content=pp).

This year they offer an environmentally friendly choice: Participants can choose the ‘pick trees, not tees’ option to replace a Hacktoberfest T-shirt with a planted tree in celebration of your accomplishments.

Last year more than 60k devs completed the challenge.
Will you participate this year?
How Do You Avoid Burnout?
Tags: beginners, productivity, career, discuss
Published: 2020-08-18 16:12:18

Whether you have over a decade of experience as a software engineer or you've just started your career as one, how do you avoid burnout?

How do you manage work, side projects, family and friends, and more? 

To the engineers with many years of experience, do you have any advice for those just starting their careers?
Concept Learning & Find-S algorithm in Machine Learning
Tags: machinelearning, datascience, 100daysofcode, tutorial
Published: 2020-08-18 16:04:54

##Concept
The concept is a Boolean-valued function defined over a large set of objects or events.

##Concept Learning
Concept Learning is defined as inferring a Boolean-valued function from training examples of input and output of the function.

##Concept Learning can be represented using-
* **Instance x:** It is said to be a collection of attributes.
* **Target function c:** For example, X -> [0,1]
* **Hypothesis h:** Hypothesis h is a conjunction of constraints on the attributes. A constraint can be a specific value or no value at all.
* **Training example d:** An instance x(i) paired with the target function c.

## The step-wise working of the find-S algorithm is given as-
* The process starts with initializing ‘h’ with the most specific hypothesis, generally, it is the first example in the dataset.
* We check for each positive example. If the example is negative, we will move on to the next example but if it a positive example we will consider it for the next step.
* We will check if each attribute in the example is equal to the hypothesis value.
* If the value matches, then no changes are made.
* If the value does not match, the value is changed to “?”.
* We do this until we reach the last positive example in the dataset.

*Originally published at https://www.asquero.com/article/working-of-the-find-s-algorithm/*

##Also Read- 
**Classes of Problems in Machine Learning -** https://www.asquero.com/article/classes-of-problems-in-machine-learning/

**Concept and Concept Learning -** https://www.asquero.com/article/concept-and-concept-learning/
Lock at this beauty - BSD
Tags: showdev, motivation, node, linux
Published: 2020-08-18 16:00:52

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/5gnebtxj67wdq9fz07jm.jpg)

Look what I just got - sooner or later I will replace the CPU board with a custom board that runs my nodejs emulator (using a rpi). Scary!
The Cost of Bad Documentation: When Losing a Developer
Tags: documentation, productivity, writing
Published: 2020-08-18 15:55:56


I've been doing a lot of research on the cost of bad software documentation, and came across this [paper](https://www.researchgate.net/profile/Satish_C_J/publication/303954738_Software_Documentation_Management_Issues_and_Practices_A_Survey/links/5e312c2e299bf1cdb9f9595e/Software-Documentation-Management-Issues-and-Practices-A-Survey.pdf) by C. J. Satish and M. Anand. It's a survey of various published works to indentify recurring pain points caused by bad documentation. One highlight: _**what happens when a developer leaves?**_

### Losing Knowledge

Here's a quote from the paper:

> Documentation is not complete and people who have the knowledge about the system retire without adequate knowledge transition.

> The absence of original requirements documentation nullifies the option of rebuilding the system

You know that developer that has been in the team since day 1, for the last 8 years? The one that knows _everything_ about the system, because they wrote a good chunk of it, but haven't written anything down. 

Now, they are leaving the company, and are asked to write _handover documents_ that explain how...wait for it... _**everything they've worked on for the last 8 years works**_. Oh, and their last day is this Friday and they have zero motivation or incentive to actually do a good job documenting things.

### Don't Leave It To The Last Minute

_**The worst time to start worrying about documentation is when the knowledge is about to be lost forever.**_

There is a very real cost in not documenting our internal systems as software engineers. In the best case, developers lose a few hours a week tracking down how a system works, and in the worst case, huge amounts of knowledge are simply lost as people leave the company over time.

As I was about to write this, I came across this relevant [quote](http://codebetter.com/davelaribee/2009/11/17/the-high-cost-of-losing-a-developer/) about how long it takes for a developer to ramp up in a new team.

> A $60K/annum employee may very well take $120K before reaching the productivity level and contribution of the developer who left the team.

To decrease that number, invest in your documentation. Make it a **first class citizen** in your process. Ask for **doc updates in code reviews**, just like unit tests. Invest in your **tools**. Otherwise your developers will turn into 
archaeologists.

---

While you're here, If this resonated with you, you might be interested in what I'm working on. Head on over to [my personal site](www.begley.me/about) if you want to reach out or hear more.
Sponsorware is picking up
Tags: opensource
Published: 2020-08-18 15:38:47


A couple of months ago, I signed up for [Caleb Porzio](https://calebporzio.com/)'s [newsletter about VS Code](https://learn-vscode.com/). I then rediscovered Caleb through his post on [hitting $100k/y through Github Sponsors](https://calebporzio.com/i-just-hit-dollar-100000yr-on-github-sponsors-heres-how-i-did-it). This post made quite the round across the internet, after all, that's the dream, right?

In this post, he said that one of the spikes was due to the [Sponsorware](https://calebporzio.com/sponsorware). It's not an app or anything, it's just an idea. The idea is that you only let your supporters use your "open-source" work until you reach a certain number of sponsors. Once you reach this level, you make the repo public. That's pretty genius.

I'm very intrigued by this idea and have decided to give it a go. I have applied for the [Github Sponsors](https://github.com/sponsors/) program. The process is very straight forward. If you do any open-source work, I suggest you apply as well, there is no harm. If you get in, try this Sponsorware thing, I think the future of open-source is very bright if more people adopt this strategy. If I don't get in, no worries, I'll just keep working on my open-source projects until I can get in.

I don't have a huge following my work, but I hope this post will spread. I think that this way of working is very healthy for the developer and for the community alike. I really hope this picks up.

Thanks for reading, have a wonderful day!

You can reply on [Twitter](https://twitter.com/rasulkireev/status/1295740529012092929). Your reply will be displayed here, also, thanks to the [webentions](https://indieweb.org/webmention).
How powerful are the regular expressions for faster coding
Tags: codenewbie, vscode, showdev, tutorial
Published: 2020-08-18 15:38:44

Do you know about a technique that can speed up your coding experience for almost all the code editors in the world?

# Code Editors, the long debate 😁

Choosing a code editor is a long (and never-ending) debate though. The choice of code editor totally depends on your needs as well as your comfort. There is no *perfect for all* code editor. The one that you prefer, may not be a good option for someone else. So, explore multiple code editors to find your favorite one. (Remember, I'm talking about code editors, not IDEs 😑). Some of the top trending GUI code editors today are:

* [**Visual Studio Code**](https://code.visualstudio.com) by Microsoft
* [**Atom**](https://atom.io) by GitHub
* [**Sublime Text**](https://www.sublimetext.com) by John Skinner
* [**Brackets**](http://brackets.io) by Adobe

Also, there are some CLI code editors like *Vim* and *Nano*.

But all GUI editors have one common feature!

# Regular Expressions in Code Editors

Most of the time, especially when modifying a previously written code. We all use *Find* (*CTRL+F*) and *Replace* (*CTRL+H*) features to search a previously coded module, features, variable, or method. Although this feature is very good, **Regular Expressions** can increase their productivity up to a great extent.

## Usage of RE in Code Editors

I personally use the Visual Studio Code. So, I'll illustrate 3 very basic examples of using regular expressions to search for specific content in the codebase.
*Note that you must turn on RE feature as shown in the image below:
![RE Demo 0](https://dev-to-uploads.s3.amazonaws.com/i/oxodo6nkwg3nj58csxmi.png)

### 1. Match any single character (except a line break)
![RE Demo 1](https://dev-to-uploads.s3.amazonaws.com/i/3nujlvkjsuro1zjxkff6.png)
can match any sequence such as `cms`, `crm`, or `c3s` etc.


### 2. Match multiple characters
![RE Demo 2](https://dev-to-uploads.s3.amazonaws.com/i/1vj0q787j8pncug57sw8.png)
can match any sequence such as `cases`, `comes`, `c43s` etc.


### 3. Match at the beginning of a sentence
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/n6mf3ia0ovt8te3p8tjz.png)
can match all the lines starting with `user`.

There are many more ways to use Regular Expressions for searching the codebase.

You can find Regular Expression usage in [Visual Studio Code and Visual Studio IDE](https://docs.microsoft.com/en-us/visualstudio/ide/using-regular-expressions-in-visual-studio). If you are using some other editor, google its docs!

Hope you like this! 😉
Matt's Tidbits #78 - A new build view
Tags: mattstidbits, android, androidstudio, tidbittuesday
Published: 2020-08-18 15:35:46

[Last week I wrote about the benefits of starring issues filed against Android Studio.](https://medium.com/@matthew.b.groves/matts-tidbits-77-it-pays-to-star-issues-1a847a0907c7) This time, I have a quick update on a previous tidbit.

Back in July of last year, in [Tidbit #27](https://medium.com/@matthew.b.groves/matts-tidbits-27-how-to-toggle-build-output-views-b32aee64ddd8), I wrote about how to toggle the build output view in Android Studio. I received a question from a reader about how to find this functionality now.

I did a little research, and found that unfortunately, JetBrains removed the ability to toggle build views between the all-text and graphical tree representations. However, there's now a new combined view that includes both of them in one!

Here's the older view:
![](https://cdn-images-1.medium.com/max/1600/1*mfhmXPUva5upPu_4fRFj8A.png)

And here's the new combined view:
![](https://cdn-images-1.medium.com/max/2400/1*RHX1EvjDagOGdym5KSOa8w.png)


Thanks for reading, and tune in next week for an exciting Rx-related tidbit! And, please follow me on Medium if you're interested in being notified of future tidbits.

*This tidbit was discovered on July 2, 2020.*
Any mini web app ideas ?
Published: 2020-08-18 15:35:23

Long story short, I'm a Logistics and SCM student learning web development on free time. 
I still don't know much about web dev even though I've self-taught for over a year now. My skill is somewhere between
amateur level and junior dev level. 
For the past few months I felt like going nowhere in the web dev world, and until recently I started growing fond of aerospace engineering and physics. But at the same time I was afraid of letting go of web dev. I've already made this far and I can never imagine forgetting them all. I also have to deal with the possibility of spreading myself too thin.
So, before I give myself the green light to embark on a new journey, I need to have some bit-sized projects to remind myself web dev basics. 
Any answer is greatly appreciated ! Mad love to you guys.