teleren/devto huggingface dataset:
Mastering FizzBuzz
Tags: fizzbuzz, interview, codenewbie
Published: 2020-01-22 17:10:48

I had heard about "FizzBuzz", of course, but never encountered it in the wild. Recently in a technical interview, I was asked to complete this ubiquitous challenge. I did so in JavaScript, and followed the Red, Green, Refactor pattern to get to my final answer.

The basics of "FizzBuzz" are as follows:

-For a provided input, if divisible by 3, output "Fizz"
-For a provided input, if divisible by 5, output "Buzz"
-For a provided input, if divisible by 3 & 5, output "FizzBuzz"
-All else, output the provided input

The function provided to me in my technical challenge was:

`let FizzBuzz = (n) => { return n }`

This allowed for the final of the four tests to be passing from the beginning.

I started by writing psuedo-code to gather my thoughts about the best way to solve this.  I wrote a conditional statement that evaluated the input based on "divisibility". It's important to note that the conditional for "FizzBuzz" must go first, otherwise the return will end the execution of the function whenever a number is divisible by either 3 or 5 before being able to reach the conditional for both numbers. 

```
let FizzBuzz = (n) => {
 if (n%3 === 0 && n%5 === 0) {
    return "FizzBuzz"
 }
 else if (n%3) {
    return "Fizz"
 }
 else if (n%5) {
     return "Buzz"
 }
 else {
    return n
 } 
}
```

This alone is sufficient enough to pass the requirements of FizzBuzz, but the number of lines of code can be reduced. Because a return ends the execution of a function, we can remove the else if statements and have 3 if statements. Additionally, because of the simplicity of these conditional statements, we can place all of our code on one line and remove the brackets. This reduces our FizzBuzz function down to four lines of code! 

```
let FizzBuzz = (n) => {
 if (n%3 === 0 && n%5 === 0) return "FizzBuzz"
 if (n%3) return "Fizz"
 if (n%5) return "Buzz"
 else return n
}
```

While it might seem tempting to just print out the final answer in an interview, going through these steps shows your ability to think logically and how well you can communicate, by talking through the steps you are taking with your interviewer.
Fix Visual Studio Mono.AndroidTools.RequiresUninstallException
Tags: visualstudio, xamarin, dotnet, csharp
Published: 2020-01-22 18:53:17

---
title: Fix Visual Studio Mono.AndroidTools.RequiresUninstallException
published: true
date: 2020-01-22 17:00:00 UTC
tags: Visual Studio, Xamarin, dotnet, csharp
canonical_url: https://christophweigert.com/fix-visual-studio-mono-androidtools-requiresuninstallexception/
---

After upgrading to Visual Studio 16.4 I couldn't deploy an older Xamarin.Forms branch to a Samsung Galaxy Tab S5e. Visual Studio could not deploy the App to the device.

> ADB1000: Deployment failed Mono.AndroidTools.RequiresUninstallException: The installed package is incompatible. Please manually uninstall and try again. at Mono.AndroidTools.Internal.AdbOutputParsing.CheckInstallSuccess(String output, String packageName)

After digging around google I found this [useful Entry in the Visual Studio Developer Community](https://developercommunity.visualstudio.com/content/problem/854497/xamarinandroid-deployment-failed-monoandroidtoolsr.html).

A workaround is available to fix this critical issue:

1. Open Tools -\> Android -\> Android ADB Command Prompt
2. Run the uninstall command via adb and pass your APK package name.  
adb uninstall com.yourcompanyname.yourappname
3. Deploy the app through Visual Studio again. This time it should work.
Bad habits
Tags: discuss
Published: 2020-01-22 16:59:44

Hello everyone,

today I was thinking about bad habits while writing code for a project. After a while I realized that my functions are way to long with to much different actions inside. That made me thinking about my schooltime. I remember, when I was at school, there was one thing, beside being lazy, where I earned critic for very often. It was, that I write to long sentences with to much information. My teachers and also my parents told me that pretty often. Even when I left school and applied for my first job as a programmer, my parents and my friends read the application and told me: "Make shorter sentences! You can write everything what you want, but not everything in one sentence."

I realised that there seems to be a connection between writing too long sentences and too long functions. It's the bad habit to try to put all my information into one context which is logical to me. But this is often exhausting for others.

It's interesting to find a connection between behaviors through a habit.
What about you? Do you have any habits in some areas which you can reflect on the way you write code?

Cheers, Tim
An interactive tutorial of the Capital One data breach
Tags: security, aws, webdev, tutorial
Published: 2020-01-22 16:55:47

Paige Thompson was accused of breaking into a Capital One server and gaining access to 140,000 Social Security numbers, 1 million Canadian Social Insurance numbers and 80,000 bank account numbers. 

Paige had exploited a Server Side Request Forgery vulnerability (SSRF) to invoke the AWS meta-data endpoint and subsequently steal authentication tokens to gain access to Capital One's internal network. 

The following interactive tutorial is a reconstruction of this data breach incident that exposed the records of almost 106 million customers, how Paige exploited this vulnerability and steps developers can take to mitigate against SSRF vulnerabilities.

DEMO - https://application.security/free-application-security-training/server-side-request-forgery-in-capital-one
Update all values in a MongoDB collection to a random range
Tags: mongodb, snippet
Published: 2020-01-22 16:49:44

The following query allows you to easily update all values in a collection of documents to a random number range, in this case, between 50 and 100.

```
db.collection.find({}).forEach(function(doc) {
  db.collection.update({ _id: doc._id }, { 
    $set: { value: Math.floor(Math.random() * (100 - 50 + 1)) + 50 }
  })
})
```

Note: I haven't tested this on a large data set. This is more of a snippet for future me.
Automate Repetitive Task In Node.js Using Cron jobs
Tags: node, cronjobs, expressjs
Published: 2020-02-05 07:41:52

---
title: Automate Repetitive Task In Node.js Using Cron jobs
published: true
date: 2020-01-22 16:44:56 UTC
tags: Node.js,cron-jobs,express.js,node.js
canonical_url: https://codesquery.com/node-js-cron-jobs/
---

After building an awesome web application using the node.js, there is a time when we have to do specific things in the application server at a certain time repetitively. There are lots of things we have to do after building applications like system maintenance, server monitoring, database backup, sending reminder emails/SMS, administrative tasks and other [...]

The post [Automate Repetitive Task In Node.js Using Cron jobs](https://codesquery.com/node-js-cron-jobs/) appeared first on [CodesQuery](https://codesquery.com).
ASP.NET tutorials
Tags: vueaspnetcore
Published: 2020-01-22 16:16:59

---
title: ASP.NET tutorials
published: true
description: Tutorial
tags: Vue ASP.NET Core 
cover_image: https://hackernoon.com/hn-images/1*Ko-vkqS8ZJSwVrq2tIf1ig.png
---
Can anyone suggest good Vue and ASP.NET Core 3.1 integration tutorials?
Integrating Qna Maker Into The Power Virtual Agent
Tags: qnamaker, powerplatform, ai, azure
Published: 2020-01-22 15:48:53

In another post I introduced the Power Virtual Agent. Which is a nice tool for business users to build simple chat bots. One big feature that it is missing is standard integration with Qna Maker.But since we can call Power Automate Flows, there is a work around. Let’s have a look how.

{% youtube 1PyIjzuP9dM%}

Initially posted on [datafish.eu](https://www.datafish.eu/media/integrating-qna-maker-into-the-power-virtual-agent)
Fed up with theoretical Docker tutorials? 🙄 🐳
Tags: docker, beginners, tutorial, devops
Published: 2020-01-22 15:44:28

Once you've learnt the basic concepts, it's important to see how Docker is actually used in practice or in real world development so to say.

So, if you are already fed up with theoretical Docker 🐳 tutorials about basic concepts and commands, I have created a more hands-on, practical guide of how to actually apply these concepts.

![Docker Workflow](https://static.wixstatic.com/media/e7182f_6f906822495e4f5f8ed4af2164b2b87f~mv2.png "Docker Workflow")

The ***"Docker in Practice" video series*** covers the whole workflow with Docker:
 - Development 
 - Continuous delivery (Build the App and create the Docker image)
 - Deployment



So in each of these videos one part of the workflow is shown:
1. [***Develop an application with Docker***](https://youtu.be/6YisG2GcXaw): Building a simple Javascript application with Node.js and MongoDB using Docker.
2. [***Docker Compose***](https://youtu.be/MVIcrmeV_6c): Learn what Docker Compose is, why it's useful and how to use it.
3. [***Build an image out of the Dockerfile***](https://youtu.be/WmcdMiyqfZs)
4. [***Create Private AWS Repo and push to it***](https://youtu.be/vWSRWpOPHws): You will learn about private docker registry. How to create a private repository on AWS ECR, how to push your built image to it and about the image naming concepts in registries in general.
5. [***Deploy your containerized application with Docker Compose***](https://youtu.be/ZowjOhpAcIc)

--------------------------

In the first video you can get already an overview of how to work with Docker from ***development to deployment***. 

{% youtube YdKUkDe22RA %}
My Data Structures and Algorithms Resources

Tags: resources, career
Published: 2020-01-22 15:39:21


## My Collection of resources for Data Structures and Algorithms

A set of resources that I stumbled upon on the internet and felt to be keepers for future references.

- [visualgo.net - A tool to help his students better understand data structures and algorithms](https://visualgo.net/en)
- [Data Structures and Algorithms (https://www.lavivienpost.com)](https://www.lavivienpost.com/data-structures-and-algorithms/#ds)
- [Summaries of Data Structures (https://stepik.org)](https://stepik.org/lesson/31445/step/7?unit=11743)
- [The top data structures you should know for your next coding interview (https://www.freecodecamp.org)](https://www.freecodecamp.org/news/the-top-data-structures-you-should-know-for-your-next-coding-interview-36af0831f5e3/)
- [Big O Cheatsheet - Data structures and Algorithms with their complexities (https://www.hackerearth.com)](https://www.hackerearth.com/practice/notes/big-o-cheatsheet-series-data-structures-and-algorithms-with-thier-complexities-1/)
- [Big O notation: Time complexity of an algorithm by Vikas Kumar](https://www.linkedin.com/pulse/big-o-notation-time-complexity-algorithm-vikas-kumar/)
- [Code Repo for Data Structures in python](https://github.com/vprusso/youtube_tutorials/tree/master/data_structures)
- [Code Repo for Algorithm in python](https://github.com/vprusso/youtube_tutorials/tree/master/algorithms)

Do share your resource links if you have any for the topic. Thanks!
Protect your contributions!
Tags: github, git, career
Published: 2020-01-22 15:38:32

# My contribution graph looks empty!

I recently left a company and subsequently the private GitHub organization. Additionally, I used my work email for commits. The result is that my contribution graph was reduced to my OS contributions.

Now, while on one hand I despise the fact that our society treats likes, karma, and alike as currency, GitHub activity can be relevant for the career.

So needless to say, this is a bummer.

## How to protect yourself

As a result, I want to remind everyone that

**you should always commit using your personal (main) email**

Even after leaving (or getting kicked out) of an organization, you will at least keep your contribution count.

## What if it's too late?

GitHub will count your contributions even for unverified emails as long as nobody else verifies that email. I have heard of cases where intranet emails like "mylocalmail@localhost" where used in order to enable switching corporations without any hastle (be aware that you need to make sure it's unique enough).

## Why did this happen to me?

I am afraid that all of this should have been obvious to me. But I assume that I am not the only one not thinking about such things. So I figured the least I can do is share this information as a reminder and would ask you to help me doing so.
Memoization in javascript
Tags: javascript, memoization
Published: 2020-01-22 15:36:26

Hey everyone ! I was recently reminded of the great technique of memoization by one of my friends and thought more developers should either know / be reminded of it so I've written this article on memoization.

It is a technique that can significantly improve the performance of your functions. Please take a look :)

https://easyontheweb.com/memoization-in-javascript-for-beginners/
Free React Native Calendar Picker
Tags: reactnative, calendar, calendarpicker, react
Published: 2020-01-24 08:17:30

---
title: Free React Native Calendar Picker
published: true
date: 2020-01-22 15:30:20 UTC
tags: react native, calendar, calendarpicker, react
canonical_url: https://www.mobileframeworks.dev/free-react-native-calendar-picker/?ref=devto
---

 ![Free React Native Calendar Picker](https://www.mobileframeworks.dev/content/images/2020/01/basic-react-native-calendar-picker.gif)

To use the Calendar Picker Component for React Native you just need to:


`npm install --save react-native-calendar-picker`

### Example Code:
```
import React, { Component } from 'react';
import {
  StyleSheet,
  Text,
  View
} from 'react-native';
import CalendarPicker from 'react-native-calendar-picker';

export default class App extends Component {
  constructor(props) {
    super(props);
    this.state = {
      selectedStartDate: null,
    };
    this.onDateChange = this.onDateChange.bind(this);
  }

  onDateChange(date) {
    this.setState({
      selectedStartDate: date,
    });
  }
  render() {
    const { selectedStartDate } = this.state;
    const startDate = selectedStartDate ? selectedStartDate.toString() : '';
    return (
      <View style={styles.container}>
        <CalendarPicker
          onDateChange={this.onDateChange}
        />

        <View>
          <Text>SELECTED DATE:{ startDate }</Text>
        </View>
      </View>
    );
  }
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#FFFFFF',
    marginTop: 100,
  },
});

```[See Post](https://www.mobileframeworks.dev/free-react-native-calendar-picker/?ref=devto)
An interactive demo of the TikTok XSS vulnerability
Tags: security, java, tutorial, webdev
Published: 2020-01-22 15:27:26

The recent investigation conducted by Checkpoint Research against TikTok highlights trivially-exploitable security issues, that could have allowed motivated threat actors to gain an understanding and/or manipulate their political adversaries Ad campaigns.



To demonstrate the significance of this vulnerability, we at Kontra have developed an interactive tutorial detailing the Cross-Site Scripting flaw reported within TikTok's Ad platform and the exploitation of this issue by hypothetical cyber adversaries.

The tutorial is designed to teach developers about how cross-site scripting attacks manifest in code, how malicious actors exploit these vulnerabilities and steps developers can take write secure code. 

DEMO https://application.security/free-application-security-training/cross-site-scripting-vulnerability-in-tiktok
Numerical Palindrome in JavaScript
Tags: javascript, challenge, showdev
Published: 2020-01-22 15:19:15

A palindrome is a word, number, or sequence of characters which reads the same backward as forward. In this coding challenge we need a solution that tells if a given number is a palindrome. Only numbers allowed. For example: 2442 or 100001.

```javascript
function isPalindrome(num) {
    if (typeof num !== 'number' || num < 0) {
        return false;
    }

    return +num.toString().split('').reverse().join('') === num;
}

console.log(isPalindrome(2442)); // true
console.log(isPalindrome(1234)); // false
console.log(isPalindrome(100001)); // true
```

Video going through this example:

{% youtube BvpvvnsYCbE %}
Scan securityheaders on local projects 
Tags: security, laravel
Published: 2020-01-22 15:16:49

I like this site a lot 

https://securityheaders.com/

I want to use it to scan my local projects

I can't seem to do that.

![](https://i.imgur.com/BRVzLv5.png)

Is there a way to check security headers on local project that not live yet ?
Daily Challenge #168 - [Code golf] f (f (f b)) = f b
Tags: challenge
Published: 2020-01-22 15:10:13

---
title: Daily Challenge #168 - [Code golf] f (f (f b)) = f b
published: true
series: Daily Challenge
description: It is easy to prove that `f(f(f b)) = f b` for all functions `f : bool -> bool`. But can you do it in less than 92 characters?
tags: challenge
---
The kata is inspired by a Stack Overflow question.

It is easy to prove that `f(f(f b)) = f b` for all functions `f : bool -> bool`. But can you do it in less than 92 characters?

More specifically, your task is to prove the following lemma:

`Lemma lemma : forall (f : bool -> bool) (b : bool), f (f (f b)) = f b`.

And the size of your solution (including all declarations) should be 91 characters or less.


***
_This [challenge](https://www.codewars.com/kata/5d2428590fb98b0018b7dc47) comes from monadius on CodeWars. Thank you to [CodeWars](<https://codewars.com/>), who has licensed redistribution of this challenge under the [2-Clause BSD License](<https://opensource.org/licenses/BSD-2-Clause>)!_

_Want to propose a challenge idea for a future post?  Email **yo+challenge@dev.to** with your suggestions!_
Refactoring For jQuery
Tags: webdev, testing, refactoring, jquery
Published: 2020-01-22 15:09:42

---
title: Refactoring For jQuery
published: true
description: I found a lot of jQuery usage. While working with them to build a better test suite, I started with some simple refactoring to make these functions more testable.
tags: WebDev, Testing, Refactoring, jQuery
series: Front-End Testing Patterns
cover_image: https://thepracticaldev.s3.amazonaws.com/i/idt71ryhxpbhe0ygbvge.png
---

## Set Up

Recently, in some client code, I found a lot of jQuery usage. While working with them to build a better test suite, I started with some simple refactoring to make these functions more testable.

The initial code looked like this ...

```javascript
const testableCode1 = {
  test: function() {
    return testableCode.runTest();
  },
  runTest: function() {
    var elements = $('.elements');
    return elements.length;
  }
};
```

## Initial Test Coverage

There were no initial tests. Since we wanted to do some refactoring, we wound up with a simple pattern to allow for refactoring ...

```javascript
describe('pre-refactor', function() {
  it('test before refactor', function() {
    var itemToReturn = $('<div></div>');
    spyOn(window, '$').and.callFake(function(item) {
      if (item === '.elements') {
        return itemToReturn;
      }
    });

    var result = testableCode1.test();

    expect(result).toEqual(1);
  });
});
```

## Refactor

Now, with these tests in place, we can refactor the code with a level of confidence that the functionality will remain the same.

Here's the refactored ***testableCode*** code ...

```javascript
const testableCode2 = {
  test: function() {
    var elements = $('.elements');
    return testableCode2.runTest(elements);
  },
  runTest: function(items) {
    return items.length;
  }
};
```

## Rework Tests

Given this refactor, the old test put into place should still pass and we can now write tests without the ***spyOn*** being used ...

```javascript
describe('post-refactor', function() {
  it('test before refactor', function() {
    var itemToReturn = $('<div></div>');
    spyOn(window, '$').and.callFake(function(item) {
      if (item === '.elements') {
        return itemToReturn;
      }
    });

    var result = testableCode2.test();

    expect(result).toEqual(1);
  });

  it('test after refactor', function() {
    var itemToReturn = $('<div>');
    var result = testableCode2.runTest(itemToReturn);
    expect(result).toEqual(1);    
  });
});
```

## Conclusion

Now that the code has been refactored, the initial test could easily be removed, making the tests much cleaner and simpler to work with.
The CodeNewbie Journey Continues
Tags: meta, codenewbie
Published: 2020-01-22 14:41:01

---
title: The CodeNewbie Journey Continues
published: true
description: CodeNewbie is officially joining the DEV family!
tags: meta, codenewbie
---

I’m incredibly excited to announce that CodeNewbie is officially joining the DEV family! We at CodeNewbie spend all of our time thinking about how we can better serve our community, and there’s no one better to go on that mission with than DEV.

When CodeNewbie was started almost seven years ago, it was built as a simple weekly Twitter chat made to provide much needed support, love, and resources to people who are just getting started on their coding journey. Now, we’ve grown to include two podcasts, our annual conference, Codeland, added a Sunday Twitter chat, and done over 300 Twitter chats. Our podcasts have been downloaded over 4M times and we’ve helped countless people feel a little less alone as they work their way through their careers. But there’s still so much important work to be done to create a more inclusive and supportive tech community, and, now, we get to continue working on that mission with DEV.

The DEV community is the embodiment of everything we believe a community should be: empowering, inclusive, and, most of all, kind. I’m so excited to continue working towards an even stronger tech community under the incredible DEV organization. 

I’ll continue to host the podcasts and serve as an editorial consultant for DEV. I could not have asked for a better home for CodeNewbie. We’re going to continue on our mission of building the most supportive community of programmers and people learning to code, and I can’t wait for you to see what we do next. Happy coding!
I'm Levi, Your Resident Podcast Producer, And I Just Joined The Dev Team
Tags: podcast, career, codenewbie, basecs
Published: 2020-01-22 14:40:37

Hello DEV community! 

My name is Levi Sharpe, and I am one of DEV's newest hires. I am a podcast producer and sound designer. I currently work on the [CodeNewbie](https://podcasts.apple.com/us/podcast/codenewbie/id919219256) and [Base.cs](https://podcasts.apple.com/us/podcast/base-cs-podcast/id1304168963) podcasts, hosted by [Saron Yitbarek](https://twitter.com/saronyitbarek?ref_src=twsrc%5Egoogle%7Ctwcamp%5Eserp%7Ctwgr%5Eauthor). [CodeNewbie](https://www.codenewbie.org/) is an organization which fosters a supportive, international community of people learning to code, which has now been acquired by DEV!

Previous to working at CodeNewbie, I was lead podcast producer at Gizmodo Media Group, where I helped create and produced Lifehacker’s Webby-nominated podcast, The Upgrade, as well as Jezebel's pop culture podcast DirtCast and their politics show Big Time Dicks.

I received my master's from the CUNY Graduate School of Journalism, and my work has been featured on Marketplace Tech, Marketplace Weekend, Codebreaker, Actuality, The Takeaway, Word of Mouth, and Popular Science. You can take a look at some of my work at [levisharpe.com](http://www.levisharpe.com/).

As a passion project, I sound design and mix the narrative fiction podcast [Roommate From Hell](https://podcasts.apple.com/us/podcast/roommate-from-hell/id1432313971), which is an independent show I make with some friends about a girl named Claire who moves in with a literal demon from hell named Bea, they become friends, and antics ensue.

Some of my other passions outside of podcasting include banjo picking, sculpting, cocktail-making, cycling, and nerd stuff like Magic: The Gathering, D&D, and comics. I've also been dabbling in Python.

I am really excited about being a part of the DEV team and exploring and expanding our podcast and audio endeavors!

Please rate and subscribe :)