teleren/devto huggingface dataset:
Java Multithreading & Concurrency Overview
Tags: java, tutorial, multithreading, concurrency
Published: 2020-01-28 18:36:02

Multithreading and Concurrency in Java-
 Java was one of the first languages to make multithreading easily available to developers. Java had multithreading capabilities from the very beginning. Therefore, Java developers often face the problems described above. That is the reason I am writing this trail on Java concurrency. As notes to myself, and any fellow Java developer whom may benefit from it.

The trail will primarily be concerned with multithreading in Java, but some of the problems occurring in multithreading are similar to problems occurring in multitasking and in distributed systems. References to multitasking and distributed systems may therefore occur in this trail too. Hence the word "concurrency" rather than "multithreading".

Concurrency Models-

The first Java concurrency model assumed that multiple threads executing within the same application would also share objects. This type of concurrency model is typically referred to as a "shared state concurrency model". A lot of the concurrency language constructs and utilities are designed to support this concurrency model.

However, a lot has happened in the world of concurrent architecture and design since the first Java concurrency books were written, and even since the Java 5 concurrency utilities were released

The shared state concurrency model causes a lot of concurrency problems which can be hard to solve elegantly. Therefore, an alternative concurrency model referred to as "shared nothing" or "separate state" has gained popularity. In the separate state concurrency model the threads do not share any objects or data. This avoids a lot of the concurrent access problems of the shared state concurrency model.

New, asynchronous "separate state" platforms and toolkits like Netty, Vert.x and Play / Akka and Qbit have emerged. New non-blocking concurrency algorithms have been published, and new non-blocking tools like the LMax Disrupter have been added to our toolkits. New functional programming parallelism has been introduced with the Fork and Join framework in Java 7, and the collection streams API in Java 8.
Terraform: use for_each instead of count
Tags: terraform, tf12
Published: 2020-01-28 18:17:27

---
title: Terraform: use for_each instead of count
published: true
description: use terraform's for_each instead of count
tags: #terraform #tf12
---

For a long time I've used the `count` meta-argument to create multiple instances of a resource. One of the problems with this is ordering. Since count is managing a `list`, if any objects in the list change position terraform wants to destroy/re-create that object. This can cause obvious problems; at the very least heart burn.

### Example using `count`:

```hcl
locals {
  user_list = [
  {
    email = "drew@nebulaworks.com",
    display_name = "Drew Mullen"
  },
  {
    email = "ldong@nebulaworks.com",
    display_name = "Lynn Dong"
  }
  ]
}

resource "azuread_user" "user_template" {
  count = length(local.user_list)
  user_principal_name = lower(local.user_list[count.index].email)
  display_name        = local.user_list[count.index].display_name
  password            = "SuperPassword123"
  force_password_change = true
}
```

### Example using `for_each`:

```hcl
variable "nwi_users" {
    description = "NWI users for Azure. Key is the displayed name, value is the login name (your email)."
    type = map
    default = {
        "Lynn Dong" = "ldong@nebulaworks.com",
        "Drew Mullen" = "drew@nebulaworks.com"
    }
}

resource "azuread_user" "user_template" {
  for_each = var.nwi_users

  user_principal_name = lower(each.value)
  display_name        = each.key
  password            = "SuperPassword123"
  force_password_change = true
}
```

**Note**: It is annoying that the Azure provider requires a static password, however, terraform is smart enough to **not** bork your password when its updated.

The above code builds the same resources but is cleaner to read and also is no longer effected by the order of the variable's values!

**Update:** Although we disagree on when to use `count` vs `for_each`, [Spacelift](https://spacelift.io/) has written up a good long-form blog on these meta arguments! Find their blog for added context and explanation [here](https://spacelift.io/blog/terraform-count-for-each).
JavaScript Filter Function Explained
Tags: javascript, tutorial, beginners
Published: 2020-01-28 18:15:03

The filter function can be used to find elements within an array that match certain criteria. The example below shows an array called 'myNumbers' that contains the numbers 1 through 5. The filter function takes one parameter which is a function that has one parameter. The filter function works by going through each element of the array and checks if a condition matches, if it matches it returns the element. The parameter in the inner function is each element in the array. Then the filter function is used to return all the numbers from that array that are above 2, so the numbers 3, 4, and 5. 

```javascript
var myNumbers = [1, 2, 3, 4, 5];
var result = myNumbers.filter(function(i){ return i > 2 });
```

Because you pass a function to the filter function you can declare the function elsewhere in the code and then pass that into the filter function. The code snippet below shows creating a function and putting it into the variable 'myFunc'. This allows you to pass the variable, the function, into the filter function. This also means that you could use the same filter function in different areas of the code or multiple times.

```javascript
var myNumbers = [1, 2, 3, 4, 5];
var myFunc = function(i){ return i > 2; }
var result = myNumbers.filter(myFunc);
```

You can also use the filter function on any array with any variable types. The below code snippet shows using the filter function on an array of objects. The below code will return a new array with only the first two objects from the original array. This means the variable 'result' will contain the first and second objects from the 'people' array. 

```javascript
var people = [
  {firstName: 'John', lastName: 'Smith', age: 32},
  {firstName: 'Jane', lastName: 'Doe', age: 27},
  {firstName: 'Peter', lastName: 'Hammond', age: 65},
 ];
var myFunc = function(i){ 
  return i.age < 65; 
}
var result = people.filter(myFunc);
```

All the examples so far are using numbers within the conditional filter function. The below code snippet shows using a string operation in the condition instead. This will return all the objects from the 'people' array whose 'firstName' field begins with the letter 'J'. 

```javascript
var people = [
  {firstName: 'John', lastName: 'Smith', age: 32},
  {firstName: 'Jane', lastName: 'Doe', age: 27},
  {firstName: 'Peter', lastName: 'Hammond', age: 65},
 ];
var myFunc = function(i){ 
  return i.firstName.startsWith('J'); 
}
var result = people.filter(myFunc);
```

The filter function can be used to get specific values from an array and put those values into a new array. It's important to remember that the original array will not be affected in any way, it will contain the same elements before the filter operation after the operation has been executed. If the filter function does not match any items within the array it will return an empty array, as no items matched the criteria so no items will be added to the filtered array.

This post was originally published on https://acroynon.com
Top 5 DEV Comments from the Past Week
Tags: bestofdev
Published: 2020-01-28 18:06:11

---
title: Top 5 DEV Comments from the Past Week
published: true
description: Highlighting some of the best DEV comments from the past week.
tags: bestofdev
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--7VrAA2ln--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://thepracticaldev.s3.amazonaws.com/i/qmb5wkoeywj06pd7p8ku.png
---

This is a weekly roundup of awesome DEV comments that you may have missed.  You are welcome and encouraged to boost posts and comments yourself using the **[#bestofdev](/t/bestofdev)** tag.

@msarit starts things off with their reply to **[What are some common falsehoods about working as a software developer?](https://dev.to/ben/what-are-some-common-falsehoods-about-working-as-a-software-developer-2840)**:
{% devcomment klnb %}

@bradtaniguchi talks about truly comprehensive documentation in response to **[What's the best documentation you have ever read?](https://dev.to/madarsbiss/what-s-the-best-documentation-you-have-ever-read-1d4p)**:
{% devcomment klbm %}

@missamarakay shares her answer and rationale in response to **[What software development tools (libraries/frameworks/apps/whatever) make you feel most anxious while you're working with them?](https://dev.to/ben/what-software-development-tools-libraries-frameworks-apps-whatever-make-you-feel-most-anxious-while-you-re-working-with-them-369l)**:
{% devcomment kkd8 %}

@molly_struve drops some serious knowledge to an anonymous poster, answering the question **[How would you handle a conversation with someone who thinks "respecting an opinion" means "agreeing with it"?](https://dev.to/sloan/how-would-you-handle-a-conversation-with-someone-who-thinks-respecting-an-opinion-means-agreeing-with-it-2bi2)**:
{% devcomment ki98 %}

Finally, @dwd shares their answers, and also links to two wonderful stories in answering **[What was the weirdest bug you ever encountered?](https://dev.to/devmount/what-was-the-weirdest-bug-you-ever-encountered-b3c)**:
{% devcomment khk8 %}

See you next week for more great comments ✌
It's Permissions, Dummy! - Building SaaS #25
Tags: python, django, saas
Published: 2020-01-28 18:02:48

{% youtube PRdEB9tKb20 %}

In this episode, we got into a static files problem that caused a template to fail to load from the Shiv app.

After some serious spelunking through the Django code and deep debugging, we found the file permission error that was the source of the problem.

Show notes for this stream are at [Episode 25 Show Notes](https://www.mattlayman.com/building-saas/its-permissions-dummy/).

To learn more about the stream, please check out [Building SaaS with Python and Django](https://www.mattlayman.com/building-saas/).
Remember <marquee> and <blink>?
Tags: html
Published: 2020-01-28 17:39:52

Do you remember the first website you wrote? Mine was a fanpage about Doom II. Yep. That was over 20 years ago.

I used an IDE called NVU when I started getting my hands dirty with HTML and CSS. I find it fascinating that this software is still around. I remember pondering about using a WYSIWYG editor or not, which is not even a question that web developers ask themselves anymore. Also, the standard for HTML tags was to write them in all caps, like `<BODY></BODY>`. It looked awful! Do you recall `<marquee>` and `<blink>`? My co-workers and I brought back memories of these silly tags the other day. Web development in the 90s was a completely different beast. How to transfer files via FTP was common knowledge. Another lost practice… probably for the best!


In the end, I feel like the only tag that truly survived the evolution of HTML and the intrusiveness of JavaScript in the DOM is `<div>`. Despite the effort to implement semantic tags, the blandness of div is what probably encourages its use everywhere. And it seems that accessibility is the primary victim of this trend. Also, nobody looks at the resulting code of rendered pages anymore (did anyone ever did? I remember obsessing about this), so who cares?

When I look at how CSS evolved, though, I see a language that remained very stable and up to date. Even better, I believe that stylesheets grew to be an even more awesome way to create beautiful, pure designs. I’ve always considered that using JPEGs instead of CSS to build the layout of a website was a huge mistake, especially before the time of high-speed internet. I remember looking at websites in the 2000s and cry a little bit inside because of the size of the assets. Of course, float and inline-block are not really a thing anymore, thank goodness. But the recent addition of flex and grid were big game changers that promoted better styling practices.

I believe that looking, even briefly, at the early decades of web development is a good reminder of how far we got in the way we create websites. JavaScript truly evolved into something that I would have not foreseen. And the disruption from jQuery to libraries such as React and Vue was huge!

Remembering these things through the lens of nostalgia is a fun exercise. However, there is no doubt that this evolution was most definitively for the better!
Is Express.js still relevant?
Tags: javascript, npm, node
Published: 2020-01-28 17:38:33

I remember recently reading an article mentioning that using Express as your app's web server is something of the past (of course I can't find it now, sadly).

Upon looking in on the [Express website](http://expressjs.com/), the footer indicates that the site was last updated in 2017.

Additionally, checking out their [GitHub page](https://github.com/expressjs/express/), the last commit was back in May 2019.

---

Does anyone use Express, or have any insight if this is a framework to pursue in 2020?

Are there other lightweight server frameworks that you use for your Node projects?

I'm definitely an advocate of the [lean web](https://leanweb.dev/), and am slowly learning my way to build a full stack website (Node and MongoDB for backend goodies). The less code and dependencies overall the better :)
Get these 1️⃣1️⃣ 🐿 FIREFOX extensions Nowwww ! & Be Superrrrr Productive !
Tags: webdev, productivity, techtalks
Published: 2020-01-28 17:21:00

As far as I know the extensions I'm going to tell you are quite less known 🤫 but extremely useful and will increase you productivity to next level.🤓

Today I decided to share my complete list of **11** Firefox extensions/addons with you guys, so that everyone can gain benefits.

Here it goes ... 

## 1. Dark Reader
This forces every website to be in dark mode. It also has 5+ color schemes and custom CSS editing facility for dark mode. 

You all will love it !

## 2. WhatFont

It is very handy for knowing the font used, the weight,line height etc etc about the page. Just click and hover and click and the popup with the info will show you everything you want.

## 3. ColorZilla 

Best color picker till date (*-*)

## 4. Download All Images

It is an extension and not a sentence :), that name is too long and the working is tooooo good.
It's a Swiss army knife for getting all the images on the webpage in one click.
It has filers like: REGEX,Zipping etc etc. List of features is endless.

A must have for everyone.

## 5. Measure-it

It is used to measure the elements on the page. Just click on it and then draw the overlay and it will tell width and height.

## 6. Tab Auto Refresh

As the name says, refreshes the page after given time intervals

## 7. Ruler

It seriously places a big  ruler on the web page for you.

## 8. Web Developer

Behold !!!!!! The father of Swiss army knife extensions is here. My blog post will go too long to explain it.

Download and explore, it has everything (I mean every thing)

## 9. Fireshot

Just a good extension to take images, print PDFs from web page. Extremely useful as it automatically scrolls the page.

## 10. Code Injector

I love it....... This extension injects custom HTML, CSS, JS to any webpage you want and it also saves that for the particular domain.

Just download it now! You will regret otherwise :)

## 11. Linkgopher

Extracts every single link from the webpage

---
🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️🙋🏻‍♂️
Thank you all and be productive!!!😎

# You can follow me on;
https://instagram.com/codingindian
https://twitter.com/iamsharadraj
Do you believe more successful devs around you make you a better dev?
Tags: webdev, career, discuss
Published: 2020-01-28 17:20:08

---
title: Do you believe more successful devs around you make you a better dev?
published: true
description: 
tags: webdev, career, discuss
---
I've always thought, that one of the most effective ways of personal growth is to surround yourself with more experienced and successful people. 

You begin to attract the winning mindset and formulas to make things work and become inspired by their insights and their sense of confidence.

Do you agree with this in coding career? 
If you do, what's something you learned from them?
How to use moment.js with React
Tags: react, momentjs, typescript
Published: 2020-01-28 17:18:54

---
title: How to use moment.js with React
published: true
description: 
tags: react, momentjs, typescript
series: React and Material UI
---

# Introduction

After some refactoring and some adjustments, my football almanac application looks like this

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

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

There is a last thing to work on: the date and time of each match.

# Installing `moment.js`

I install `moment.js`

```bash
npm install --save moment react-moment
```

and I import it in the `Match.tsx` component

```typescript
import Moment from 'react-moment';
...
<div className={classes.cardHeader}>
  <Typography variant="overline" display="block" gutterBottom>
    <Moment>{utcDate}</Moment>
  </Typography>
</div>
...
```

In this way, I obtain the date and time formatted

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

# Advanced formatting

`moment.js` allows different date formats. If you want to learn more about it, visit the [official documentation](https://momentjs.com/docs/#/parsing/string-format/).

I prefer a more readable format. Something like `1st January 2020 - 19.00` should work.

```typescript
...
<Moment format="Do MMMM YYYY - HH:mm">{utcDate}</Moment>
...
```

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/bocrdk7m5d813zbnpwu1.png)
Destructure an object to remove a property
Tags: javascript, snippet, beginners
Published: 2020-01-28 16:59:54

---
title: Destructure an object to remove a property
published: true
tags: javascript, snippet, beginners
main_image: https://timdeschryver.dev/snippets/images/destructure-an-object-to-remove-a-property.png
canonical_url: https://timdeschryver.dev/snippets/destructure-an-object-to-remove-a-property
---

Follow me on Twitter at [@tim_deschryver](https://twitter.com/tim_deschryver) | Originally published on [timdeschryver.dev](https://timdeschryver.dev/snippets/destructure-an-object-to-remove-a-property).

---------


## Destructure an object to remove a property

### Use case

I want to delete a property from an object in a pure (immutable) way.

### Solution

Use a destructuring assignment to assign the to be removed property to a variable, while cloning the "rest" properties to a new variable.
The `_` is used to prevent a linter giving the `variable is declared but its value is never read` warning.

```ts
const { password: _, ...user } = {
  id: 47,
  username: 'tim',
  password: 'iliketrains',
}

console.log(user)
// |> { id: 47, username: 'tim' }
```

For more examples see [Destructuring assignment on MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment)

-------

Follow me on Twitter at [@tim_deschryver](https://twitter.com/tim_deschryver) | Originally published on [timdeschryver.dev](https://timdeschryver.dev/snippets/destructure-an-object-to-remove-a-property).
Redux Visualized
Tags: javascript, redux, beginners
Published: 2020-01-28 16:53:08

---
title: Redux Visualized
published: true
description: Redux Visualized
tags: javascript, redux, beginners
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2z1nsviqijg2xoockice.png
---

While revamping my slides for a Redux workshop I came up with this animation:

![Redux Visualized](https://dev-to-uploads.s3.amazonaws.com/i/ofveedx2ix7c9xk7xhv2.gif)

If you think about it, Redux is not so hard to grasp :-)

For the occasion I updated this [React Redux tutorial](https://dev.to/valentinogagliardi/react-redux-tutorial-for-beginners-learning-redux-in-2018-13hj) as well.

Happy coding!
PWAで動いてる？isPWA();
Tags: javascript, css
Published: 2020-01-28 16:41:25

# JavaScript

ChromeとFirefox、iOS Safari 13以降であれば次の方法が可能です。詳しい利用可能状況はcaniuseで。

https://caniuse.com/#search=display-mode

```js
(window.matchMedia('(display-mode: standalone)').matches
// true: working on PWA
// false: not working on PWA
```

iOS Safari 12以前ではdisplay-modeを利用できないので、次の方法を利用します。

```js
window.navigator.standalone
// true: working on PWA
// undefined: not working on PWA
```

# CSS

CSSではdisplay-mode media queryを利用すればPWAで動いているかどうかでスタイルを変更できます。

```css
@media all and (display-mode: standalone) {
    // styles for PWA
}
```
What is your opinion on "advertising" in library logs?
Tags: discuss, opensource
Published: 2020-01-28 16:32:44

{% github https://github.com/zloirock/core-js/issues/548 %}

What kind of messaging would be "okay", what is totally inappropriate, where do you stand on the issue?

Is it appropriate to ask for support at all in this context? Let's discuss the nuance here.
PPL MVR
Tags: codepen
Published: 2020-01-28 16:25:34

<p>Animated Recreation of Band Poster found here <a href="https://i.pinimg.com/originals/33/4c/a8/334ca89bd0c7b6f04a38318ae71f33c7.jpg" target="_blank">https://i.pinimg.com/originals/33/4c/a8/334ca89bd0c7b6f04a38318ae71f33c7.jpg</a>. Original artwork by artist Martín Ontiveros created for PPL MVR.</p>

<p>PPL MVR - <a href="https://www.pplmvr.co/" target="_blank">https://www.pplmvr.co/</a></p>

<p>Martín Ontiveros  - <a href="https://martinheadrocks.bigcartel.com/" target="_blank">https://martinheadrocks.bigcartel.com/</a></p>

{% codepen https://codepen.io/KristopherVanSant/pen/VwYgvwE %}
Beta Version of New Devart ODBC Driver Provides Access to NexusDB Data 
Tags: delphi, database, nexusdb
Published: 2020-01-28 16:07:20

---
title: Beta Version of New Devart ODBC Driver Provides Access to NexusDB Data 
published: true
description: Devart released the public beta of ODBC driver for NexusDB, client/server and embedded database system for Delphi applications.
tags: Delphi, database, NexusDB
---

*Devart released the public beta of ODBC driver for NexusDB, client/server and embedded database system for Delphi applications.*

Devart, a recognized vendor of connectivity solutions for various databases and cloud services, released the public beta of [ODBC driver for NexusDB](https://www.devart.com/odbc/nexusdb/). The driver can be used to access data in NexusDB databases from various analytics, database management and reporting tools, IDEs and programming languages on Windows (32/64 bit): Excel, Power BI, Tableau, RAD Studio, Lazarus, dbForge Studio, RStudio, and many others.

The vendor also notes that Devart ODBC driver for NexusDB provides full support for the standard ODBC API functions and data types and can connect to the NexusDB server directly via TCP/IP. It also supports multilingual NexusDB databases, be it Latin, Cyrillic, or Chinese.

As an extra benefit comes cost-effective deployment: the driver is a standalone installation file that does not require the user to install or update any dependencies, while large organizations with hundreds of machines can use the silent install method with an OEM license.

Users can download the new driver on the vendor’s website to test it for 30 days for free with the third-party tools. The driver is also available for pre-order. To learn more about the recent release, visit https://blog.devart.com/odbc-driver-for-nexusdb-beta.html

**About Devart**

Devart is one of the leading developers of database tools and administration software, ALM solutions, data providers for various database servers, data integration and backup solutions. The company also implements Web and Mobile development projects.
For additional information about Devart, visit https://www.devart.com/.