teleren/devto huggingface dataset:
Mongoose dynamic update hack
Tags: mongoose, node, express
Published: 2019-09-06 12:31:31

---
title: Mongoose dynamic update hack
published: true
description: 
tags: Mongoose,nodejs,expressjs
cover_image: https://raw.githubusercontent.com/daton89-topperblues/mongoose-transactions/master/docs/img/mongoose-transactions.png
---
Why do you use mongoose you say?
Let’s face it, writing MongoDB validation, casting and business logic boilerplate is a drag. Mongoose eases the whole mess.
While working with mongoose specially on the update operation , you will notice that you will have to provide the selector for the document you are modifying (normally _id or username ) along with the fields you wish to modify and their corresponding values that you would like to update.
Here is a simple snippet to summarize the whole thought above

```javascript
User.update({
"username": req.params.user} , {$set:
{age: req.body.age, location: req.body.location, name:req.body.name ....}
} ,
function (err , success) {
if (err) throw (err);
else {
res.send({
msg: 'update success'
})
}})
```
![](https://media.giphy.com/media/mCRJDo24UvJMA/giphy.gif)

The code is okay if you are to update two to handful of fields but its get kinda ugly as the field to be updated gets increased. Say 100 fields . Also if you do manage to write the update query for 100 fields , whats the chance that the properties names in the schema will remain the same forever. If the schema were to update, you will be writing 100+100 = 200 update assignments.
This is where my code comes to rescue. Not only it dynamically populates the update fields on the query , it also picks up the field name from the request.

```javascript
const entries = Object.keys(req.body)
const updates = {}

// constructing dynamic query

for (let i = 0; i < entries.length; i++) {
updates[entries[i]] = Object.values(req.body)[i]
}
User.update({
"username": req.params.user
} , {
$set: updates
} ,
function (err , success) {
if (err) throw (err);
else {
res.send({
msg: "update success"
})
}
}

```
![](https://media.giphy.com/media/RyXVu4ZW454IM/giphy.gif)


Happy Node'ing

[![Beerpay](https://beerpay.io/rubiin/nest-easyconfigs/badge.svg?style=beer)](https://beerpay.io/rubiin/nest-easyconfigs)
php artisan make:auth in laravel 6.0
Tags: php, laravel, tutorial, laravel6
Published: 2019-09-06 12:04:44

---
title: php artisan make:auth in laravel 6.0
published: true
description: As you may have known by now that laravel 6.0 has been out. Though it’s expected to have a lot of changes in the major release but in 6.0 there are not that many changes.
tags: php, laravel, tutorial, laravel6
canonical_url: https://codebysamgan.com/php-artisan-makeauth-in-laravel-6-0
cover_image: https://thepracticaldev.s3.amazonaws.com/i/a00tgtfk0sxc71xneaee.png
---

As you may have known by now that laravel 6.0 has been out. Though it’s expected to have a lot of changes in the major release but in 6.0 there are not that many changes.

It’s more like 5.9 in terms of changes.

But one major change introduced in laravel 6.0 is the removal of

<pre>php artisan make:auth</pre>

Command. As you may know, this was used to create the authentication scaffolding. Thought the concept is not removed but just the way to implement has been changed.

**The New Way**

Authentication support is now added with the help of a package now. you can read in detail about it in [here](https://laravel.com/docs/6.0/authentication)

*Command to implement the Auth are as follows.*

<pre>
composer require laravel/ui
php artisan ui vue --auth
</pre>

All the other stuff is the same as 5.8. Same Routes, Controller and all the stuff.

{% youtube Mqs0O0jDQTg %}

Hope this was helpful
feel free to share your thought in the comment section.

PS: the video also has some Hindi in it, but I am sure you will get the gist.
Top 20 Android interview questions for beginners in 2019
Tags: android
Published: 2019-09-06 11:50:35

 Question-related to Android for beginners in 2019
- Android development trends
- Importance of Android developers
- Q1. What are the seven lifecycle methods of Android activity and what is their purpose?
- Q2. Briefly list the components of the Android architecture.
- Q3. What is DDMS?
- Q4. How would you check for the presence of a Compass sensor on the system using the hasSystemFeature() method?
- Q5. What is ADB?
- Q6. Describe activities.
- Q7. What is the importance of XML-based layouts?
- Q8. What do you think are some disadvantages of Android?
- Q9. What’s the difference between a file, a class, and an activity in Android?
- Q10. What is the Dalvik Virtual Machine?
- Q11. What are the exemptions in Android?
- Q12. What is the Open Headset Alliance?
- Q13. If an application is crashing frequently, how will you troubleshoot it?
- Q14. What is the AndroidManifest.xml file and why do you need this?
- Q15. Explain different launch modes in Android.
- Q16. Name the different data storage options available on the Android platform?
- Q17. What is a ThreadPool? And is it more effective than using several separate threads?
- Q18. What is a BuildType in Gradle? And what can you use it for?
- Q19. What are the steps involved in creating a bound service through Android Interface Definition Language (AIDL)?
- Q20. When might you use a FrameLayout?
- So Want to hire a developer?
Let us have a look at some important Android interview questions for beginners.
Android is the world’s most popular mobile platform. Initially developed by Android Inc., which Google bought in 2005, Android was unveiled in 2007. Moreover, the first commercial Android device was launched in September 2008. The core Android source code is known as Android Source Open Project (AOSP), which is primarily licensed under the Apache License.

For answer of these question you can read this articles Click here:- https://codersera.com/blog/top-android-interview-questions-beginners-2019/
About integrating Firebase in your Elm project
Tags: elm, firebase, cloud
Published: 2021-12-29 23:11:23

---
title: About integrating Firebase in your Elm project
published: true
tags: elm,firebase,cloud
canonical_url: https://lengrand.fr/using-firebase-in-elm/
---

 ![About integrating Firebase in your Elm project](https://lengrand.fr/content/images/2019/09/Screen-Shot-2019-09-06-at-1.07.09-PM.png)

During [my last article](https://dev.to/jlengrand/a-short-introduction-to-ports-and-flags-in-elm-14em), I explained the basics about [**Elm**](https://elm-lang.org/) ports, having finally learnt how to use them myself.

The reason for me to finally get into ports is that I wanted to use Firebase in my new Elm project, and finally have a side-project with no backend to manage and maintain.

This article introduces the [elm-firebase](https://github.com/jlengrand/elm-firebase/tree/master) repository that I made, who can be used as a basis to support Firebase in your own application.[**You can try the demo here.**](https://elm-firebase.netlify.com/)

## Why another integration, you say?

- If you Google for elm and firebase, you'll find a few hits. For example [elmfire](https://package.elm-lang.org/packages/ThomasWeiser/elmfire/) comes first for me, followed by another [elm-firebase](https://github.com/pairshaped/elm-firebase). Except both those projects haven't been updated for years, and none support 0.19 (and the latest Firebase Cloud Firestore, to my knowledge).
- I wanted to learn more about ports myself, and build my own integration as a learning experience.
- I'm actively trying to create some more elm resources online to spread my love for the language :)
- I'm working on a side project with a friend that needed a database :D.

## So what is it doing?

[Using the demo app I built](https://elm-firebase.netlify.com), you can :

- Log in using Google OAuth2. Users are saved using [Firebase Authentication](https://firebase.google.com/docs/auth)
- The log in stays cached, so you don't have to log in all the time
- You can save text messages to the database, and see the list of messages you wrote. This part makes use of the new [Firebase Cloud Firestore](https://firebase.google.com/docs/firestore).
- Basic security is in place, meaning that you cannot see the messages of your fellow friends. 

Here is a short video of the capabilities :

<!--kg-card-begin: embed-->

<iframe width="459" height="344" src="https://www.youtube.com/embed/S4bPd0vz06c?feature=oembed" frameborder="0" allow="accelerometer; autoplay; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe><figcaption>Demo of elm-firebase's (limited) capabilities</figcaption>

<!--kg-card-end: embed-->
## So how do I get started? 

The easiest is probably to [head to the repository](https://github.com/jlengrand/elm-firebase), clone it and read the [README](https://github.com/jlengrand/elm-firebase/blob/master/README.md)!

Hope the repository, or even this article was useful to some of you :). If you have comments, improvements or simply wanna chat do hit me up on **[Twitter](https://twitter.com/jlengrand)** :).
Best way to validate content of the entire input data file is consistent!!
Tags: machinelearning, learning, tips, datacleaning
Published: 2019-09-06 09:53:07

---
title: Best way to validate content of the entire input data file is consistent!!
published: true
description: 
tags: ML, Learning, Tips, Data cleaning
---

In machine learning, preparing data is one of the key step. Below is the simple and best way to check input data file is formatted properly. Below command should always return one unique value other wise file is not formatted properly. 
<code>
cat file_name | awk -F',' '{print NF}' | sort -u
</code> 
Refer original [post](http://www.chanduthedev.com/2019/09/how-to-validate-data-file-is-formatted.html) for more details.
Question: Should every App in Android TV needs to have Video content inside it?
Tags: android, tv, discuss
Published: 2019-09-06 09:46:31

---
title: Question: Should every App in Android TV needs to have Video content inside it?
published: true

description: I know main purpose of TV is to watch videos but Can't we use it to show other streaming data like scores, weather information, and some financial data. It's just a discussion post. I would love to hear it from the community.

tags: Android, TV, discussion 
---
Conducting Effective Code Reviews
Tags: codereview, softwaredevelopment
Published: 2019-09-06 09:45:43

---
title: Conducting Effective Code Reviews
published: true
description: Learn about the things to pay attention to, and what to automate while reviewing code so that you can increase the speed and the quality of code reviews in your organization.
tags: #codereview #softwaredevelopment 
canonical_url: https://auth0.com/blog/conducting-effective-code-reviews/
---

Code review is a process that enables peers and automated tools to check proposed changes to a codebase. The main goal of a code review is to catch potential issues, security problems, and bugs before they are introduced to the codebase and prevent them from causing problems in production.

Code review can be fun. You try to hunt down well-disguised bugs before they hurt your production. You feel like a superhero defending your town every time you find a bug.

[Read on 🔍](https://auth0.com/blog/conducting-effective-code-reviews/?utm_source=dev&utm_medium=sc&utm_campaign=code_review)

![Conducting Effective Code Reviews](https://cdn.auth0.com/blog/illustrations/code-review.png)
first post
Tags: test
Published: 2019-09-06 09:34:41

---
title: first post
published: true
description: some description 
tags: test
---
![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/ycqwybhz4n2php0qis4z.png)
ha ha ha 

```js
const js = 1;
// look the theme
```
View All HTTP Status Codes Offline 😜
Tags: http, statuscodes
Published: 2019-09-06 09:28:42

---
title: View All HTTP Status Codes Offline 😜
published: true
description: View all HTTP status codes and methods in terminal #offline
tags: HTTP, StatusCodes
---

If you have NodeJS installed just type `node` in your command line/shell/terminal then type `http.STATUS_CODES`. All status codes will be returned, just like so:

```shell
$ node
> http.STATUS_CODES
{ '100': 'Continue',
  '101': 'Switching Protocols',
  '102': 'Processing',
  '200': 'OK',
  '201': 'Created',
  '202': 'Accepted',
  ... }
```

Also try `http.METHODS` just for more fun.
I wonder how GitHub's trending algorithm works. Any clue ?
Tags: discuss, opensource, github
Published: 2019-09-06 08:47:25

In the past the trending algorithm was simple. The number of trending repositories was limited and your repository had to earn more stars than the last one in list to get into it.

Since GitHub changed their algorithm I can't figure out how it works. Someone has an idea ?

<hr />

**Answered by** [Ankita Singhal](https://dev.to/ankitasinghal): She found [a post](https://github.community/t5/How-to-use-Git-and-GitHub/How-github-detect-trending-repositories/m-p/5925) on github.community with [an answer](https://github.community/t5/How-to-use-Git-and-GitHub/How-github-detect-trending-repositories/m-p/26464/highlight/true#M7517) from [Lee Dohm](https://twitter.com/leedohm?lang=fr) community manager at GitHub.
Just because you can build something doesn't mean you should
Tags: entrepreneurship, engineering, product, saas
Published: 2019-09-06 08:43:39

---
title: Just because you can build something doesn't mean you should
published: true
description: I could probably write a small book on the mistakes I've made in my first year as an entrepreneur
tags: #entrepreneurship #engineering #product #saas
---

I could probably write a small book on the mistakes I've made in my first year as an entrepreneur.


Most of them come from the fact that I am an engineer at core, and my obsession with exhaustiveness. It's excellent to have as an engineer, really bad to have as a founder.


I wanted to silo the product from other products. Because I thought most of their features could be bundled into one and made better this way.


I've learned the hard way that: **just because you can build something doesn't mean you should**.


It will be harder to maneuver & pivot in the long run. Harder to market and sell a bunch of things put together. Harder to pitch to pre-seed level investors. Harder to network. Just harder overall, and for no good reason.


I am starting to correct it though. Yesterday I released 21 integrations for Archbee.


GraphQL, Swagger, Github Gist, Numeracy, Codepen, Mode Analytics, Slack, Airtable, Trello, LucidChart, Typeform, Mindmaster, Prezi, Miro, Invision, Figma, Framer, Abstract, Marvel, Google Analytics, Intercom.


Check them out right here: [Archbee Integrations](https://archbee.io/integrations)


No product is an island, the power of the ecosystem is huge. Why not benefit from it and at the same time make it better? Win-win.


I am curious and willing to learn from other people's mistakes as well. What mistakes did you make and what steps did you take to correct it?


Let me know down below!
Terraform 0.12 "is empty tuple" error in module
Tags: terraform, discuss, aws
Published: 2019-09-06 08:14:42

---
title: Terraform 0.12 "is empty tuple" error in module
published: true
description: When creating module with optional resources the "is empty tuple" is thrown when optional resource is removed.
tags: terraform, discussion, aws
---

I'm struggling to create a module with optional resources steered with "count" attribute.

[Here](https://github.com/piczmar/terraform-sqs-module) is a project which demonstrates the problem.

There is an SQS module which has optional dead-letter queue attached with SQS redrive policy.

On first run when queue is created with DLQ everything is fine, but when I wanted to remove DLQ the issue appears when `terraform plan` is running: 


```
Error: Invalid index

  on modules/sqs/sqs.tf line 67, in resource "aws_sqs_queue" "regular_queue_with_dl":
  67:   redrive_policy             = var.attach_dead_letter_config ? data.template_file.regular_queue_redrive_policy[count.index].rendered : null
    |----------------
    | count.index is 0
    | data.template_file.regular_queue_redrive_policy is empty tuple

```


Does anyone know how to properly create such module with optional resource in Terraform 0.12 or fix the issue I am facing?

-----------

*EDIT*: I asked the same question on [stackoverflow](https://stackoverflow.com/questions/57908294/optional-resources-in-terraform-0-12-module) and got the answer which solved my problem.

The solution was to conditionally assign `redrive_policy` to `null` if Lamdba should not use it, e.g.: 

```
resource "aws_sqs_queue" "regular_queue" {
  redrive_policy = var.attach_dead_letter_config ? templatefile(
    "${path.module}/redrive_policy.tmpl", {
      # (...whatever you had in "vars" in the template_file data resource...)  
    },
  ) : null
...
}
```

In addition we can inline template file instead of creating a separate resource.

My updated example is [here](https://github.com/piczmar/terraform-sqs-module/commit/7ad3018b6ba945e0b1d3a459cdc5dcc645959d49)
Coaching, to the next level.
Tags: todayisearched, career, beginners
Published: 2019-09-06 07:59:07

<h2>School vs Coaching </h2>

With the fast pace modern technologies are developing, I can't help but wonder if University Computer Science classes are the way to go in the current Business environment. Whatever students learn today is probably no longer relevant by the time they leave school to start their careers.

I haven't completed any study myself but I was taught to code through some coaching from family members who are already very experienced in the field. I still have ways to go, but the coaching elevated me to a level high enough to start working in the industry.

<h2>Coach your colleagues</h2>

It is not just being coached, coaching someone else yourself levels you up. By helping other developers, forcing yourself to have to explain some technology helps you realize what your actual understanding of the topic is.

This lead me to searching for platforms that would link developers to mentors or coaches to men-tees that are looking to be coached. 
With how easy it is to set up live conference calls and even live coding sessions through Vs-code. This seems like the way to go to develop developers, with the help of its vast community.

One of the sources I found that got me interested is <a href="https://codingcoach.io/"><b>CodingCoach.io</b></a> An open source project that helps people looking for coaches to find them.

What do you know? Would you be interested to coach people that have less experience than you? Would you be open to be coached?
Magento 2 Reward Point Extension
Tags: magentorewardextension
Published: 2019-09-06 07:39:33

Reward Point Extension for Magento 2 is the key to build loyalty of shoppers to your website effectively. With the extension, your store can easily reward customers for orders, review submission, sign up for newsletter or other actions. Points rewarded to custommers will motivate them to place further orders. 
https://bsscommerce.com/magento-2-reward-points-extension.html
Besides Reward Point Extension, you might care about following extensions 
https://bsscommerce.com/magento-2-request-for-quote-extension.html
https://bsscommerce.com/magento-2-gift-card-extension.html
Switched From Opera to Vivaldi
Tags: privacy, security
Published: 2019-09-05 19:34:05

At the beginning of this year, I set out to replace some applications and online cloud services with other alternatives that are more privacy conscious and are less likely to use me as their product. Last year I switched to using Opera as my main browser after using Chrome for many years. My reasoning then was that moving away from Google would bring me closer to this goal. I've used Opera for many years in the past, especially during the early 2000s. 

That's until I've read [this article](https://nordvpn.com/blog/best-privacy-browser/) on the NordVPN blog. Apparently [Opera has been sold](https://www.engadget.com/2016/07/18/opera-browser-sold-to-a-chinese-consortium-for-600-million/) to a Chinese consortium back in 2016. So long privacy.

After I've learned about this, I switched to the [Vivaldi browser](https://vivaldi.com) as my main browser. I've been using it for almost a month now and I'm pretty happy with it. The *Quick Commands* feature is really nice if you're used to such a feature in other applications like development IDEs and file managers like [Marta](https://marta.yanex.org).

I'm looking forward to it further progress in the future.
Jack Ma vs Elon Musk Debate — Different perspectives of future of AI
Tags: machinelearning, ai, future, datascience
Published: 2019-09-06 05:49:01

So, guys here we are with Jack Ma, the founder of Alibaba sharing stage with Elon Musk, Tesla CEO for the first time at WAIC ’19 in Shanghai, China.

It was great to see both big names in AI discussing the disruptions that AI can cause to us in the future. Both differed in every point about AI, but the only thing to which both agreed was that a population collapse is more likely to happen in coming 20 years.

Read my complete article at Medium :

https://medium.com/@saeeddev/jack-ma-vs-elon-musk-debate-different-perspectives-of-future-of-ai-e3f980be235f?source=friends_link&sk=8baa35c2a878877ebf11b064080222a0

Let me know what do you think of future of AI?
Is JavaScript still worth learning?
Tags: javascript
Published: 2019-09-06 14:58:40

---
title: Is JavaScript still worth learning?
published: true
tags: javascript
canonical_url: https://flaviocopes.com/javascript-worth-learning/
---

I was searching for some JavaScript related questions on Google when I noticed Google suggesting me in the “People also ask” box some questions I thought pretty funny:

![JavaScript still worth learning](https://thepracticaldev.s3.amazonaws.com/i/v68vqydb5aj0q0v1kioz.png)

Those got my attention.

Clicking the answer of led me to a reassuring answer, as I expected without a doubt. But I also had my own thoughts on the topic, so I though “let me write them”!

Let’s get it straight: **JavaScript is more alive than ever**.

JavaScript has never been more popular than today. And it’s never been more powerful than today.

When I started learning about JS in the late 90’s, the vast majority of the developers used it to make snow rain on the website at Christmas, show alert and dialog boxes, and do all weird kinds of effects. It was kinda fun, but only the pros would use it to create things more complicated than a poll or something.

When I got into JS seriously in 2012-2013, JS was much more serious. Gmail, Google Maps and other thick client applications showed us all what was possible with JavaScript. Node.js was just starting to become popular but the number of people using it in production was thin.

Nowadays many people learn JavaScript as their first and only programming language. And they might never learn another one for years, because I’d say that thanks to being the only language that works inside Web browsers, JavaScript is **the most popular and powerful language in the entire world**.

If anyone tells you any different, maybe it’s because their favorite programming language is much less popular and they hope one day people stop using JS and use the one they invested so much into :)
Slides: .NET Unit Testing Libraries
Tags: dotnet, testing, techtalks
Published: 2019-09-06 03:50:27

Below are the slides I used for my talk several weeks ago at the [Central Ohio .NET Developers Group (CONDG)](https://www.meetup.com/Central-Ohio-NET-Developers-Group-CONDG/).

{% slideshare CNcrBnM8hV1YaK %}

In this talk I discuss various libraries and techniques for expanding .NET unit testing with a goal of exposing the audience to as many different types of testing libraries as possible.

For more details on Scientist .NET, I recommend you read my in-depth article on it:

{% link https://dev.to/integerman/victimless-canary-testing-with-scientist-9nn %}

I discuss more about snapshot testing and Snapper in this article:

{% link https://dev.to/integerman/snapshot-testing-in-javascript-net-7j6 %}

Code and slides are available in the following GitHub repo:

{% github integerman/softwarequalitytalk %}