teleren/devto huggingface dataset:
What’s your alternative solution? Challenge #22
Tags: challenge, javascript, codenewbie, learntocode
Published: 2020-04-15 03:11:53

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Rotate an array to the left 1 position

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge20

var ar = [1, 2, 3];
rotateLeft(ar);
println(ar);

function rotateLeft(ar)
{
    var first = ar.shift();
    ar.push(first);
}

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.
EVT: A new EventEmitter for Deno ( and every other JavaScript runtimes )
Tags: node, javascript, typescript, deno
Published: 2020-04-15 02:55:53

https://evt.land

Disclaimer: Although EVT is a marked improvement over ``EventEmitter`` it can't compete in teme of feature scope with RxJS yet.
There are important operators such as ``swichMap``, ``mergeMap``, ``debounceTime`` and others that do not have an equivalent in EVT.
However, EVT has two main things going for it already:
- It allows performing ``filter``, ``map``, and ``scan`` in a single operation which makes the code much less verbose and enables typescript to seamlessly infer what is going on.
- It is more accessible, the API is close to EventEmitter which allows getting started quickly and progressively leverage the more advanced features.
Any feedback much appreciated
Which language do you think has a better future: Java or Javascript?
Tags: career, java, javascript, discuss
Published: 2020-04-15 02:04:45

I remember a couple of years ago I was in class and a colleague asked to our professor: Which language do you think has a better future? The professor started explaining how diferrent they are, what can you do with them or which one you should use in your project. At the end, didn't answer his question.

Right now, that question came up in my mind in terms of carrers, I prefer Java since is a robust language and I had the opportunity to work with it rather than Javascript. But how do you think would be the Future of Java? What about Javascript?

I believe that Javascript has a better future since you can build almost everything with it and most important there is a huge community which can implement it: front-end apps, back-ends apps, desktop apps and mobile apps of course with their corresponding framework. I know with Java you can do it as well , that's why I'm trying to compare them (except a front-end app, as far as I know).

What do you think the future of a Java developer will look like? a Javascript one? Can Spring Boot beat NodeJs? Can JavaEE beat ElectronJs? Can Kotlin beat React Native?

I look forward your answers.
Quick Demo! Build a slack clone
Tags: showdev, javascript, react, postgres
Published: 2020-04-15 01:23:40

We just discovered that DEV has videos! So we thought we'd show you a 2 minute demo video which we made for Y Combinator to show off what we're building over at https://supabase.io

If you want to make your own Slack clone check out our previous post:
[Creating a basic Slack clone with Postgres and React Hooks](https://dev.to/supabase/creating-a-basic-slack-clone-with-postgres-and-react-hooks-4iep)


## Follow for updates

At Supabase, we're helping developers to build products faster. We'll continue releasing some amazing tools that make Postgres as easy to use as Firebase. Some of the things we're about to launch:

- ⚡ Realtime listeners! Subscribe to your database just like you would with Firebase.
- 🤖 Instant RESTful APIs that update when you update your schema. Supabase introspects your schema and updates your API and documentation.
- 🔗 Connectors. Send realtime database changes to other systems, like queues or webhooks (Slack notifications!).
- 📓 Auto-documentation for your APIs and Postgres schema. What's better than documentation? Documentation that you don't have to manually keep up to date.

We'll announce all our future features with more freebies here on DEV first. Follow us so that you don't miss out.

![Follow](https://dev-to-uploads.s3.amazonaws.com/i/jf7adc5e3kbdu4luxvt4.gif)

And make sure to star us on github! 
[https://github.com/supabase/supabase](https://github.com/supabase/supabase)
Another YouTube series from yours truly
Tags: sass, css
Published: 2020-04-15 01:38:53

Hello everyone.

I hope you are doing well, or that you are at least hanging in there. 

I want to share another playlist I am working on. You might be familiar with the one where we build [Heartbeat](https://www.youtube.com/playlist?list=PLmJs3lfUmCdT9MyG60Oo6HM7xAn79vwZ0), but this time the videos are focused on Sass. 

Goal is to keep it short and sweet by making every video as focused as I can.

Thanks in advance for watching and any feedback will be very welcomed.

Stay safe and catch you later!

[You can see the playlist here](https://www.youtube.com/playlist?list=PLmJs3lfUmCdTvQfcaFgdJUP-J5wdm5Owq)

Here's the first video in hopes to pique your interest: 

{% youtube -6SLgZTMLpU %}
Node Package Managers
Tags: devops, node, npm, javascript
Published: 2020-04-15 01:38:44

When it comes to Node Package Managers, you will certainly cross paths with both NPM and Yarn. If you’re a newer developer, you may not fully understand the differences between the two. Let’s take a dive into these package managers for Node.js and touch on why to use them. 

#### NPM
NPM, or Node Package Manager, is the most fundamental package manager for Node.js. NPM is installed along with Node.js and consists of two things - First, it acts as an online repository for publishing open source Node.js projects. Second, it functions within the command line to interact with the project repository, helping to manage the project’s dependencies and package installation. In short, NPM is intended to manage the project dependencies defined within the package.json file, enabling packages to be installed with a single terminal command. 

#### Yarn
Yarn is a newer package manager. The primary motivations for migrating to Yarn are its offline download feature and speed. Though sometimes a condemned practice, packages installed using Yarn are installed to the user disk. This way, when offline, Yarn retains the ability to install packages. Alternatively, because NPM requires the internet to install packages, it won’t clutter the local disk with packages that may only be used once. While both NPM and Yarn download packages from the NPM repository, Yarn caches all installed packages and installs them simultaneously, making it faster than NPM. 

#### When to Migrate
Overall, using Yarn is very similar to using NPM. The added features and speed may certainly be advantageous, however there are two important asides to note. If you’ve already initiated a project utilizing NPM, transferring said project over to Yarn may create issues with installing native modules. Additionally, Yarn is not compatible with Node.js 5 or older. Outside of these conditions, migrating to Yarn should be considered if frequent offline use or an abundance of project dependencies are a factor. 

#### Conclusion
While the use of both NPM and Yarn are quite similar and relatively interchangeable, Yarn does provide certain benefits in the way of added features and installation speed. On the other hand, NPM is straightforward and battle-tested. In the end, both package managers are highly popular, stable tools for managing Node.js packages.
What is a good documentation for you and what tools do you use?
Tags: discuss, documentation
Published: 2020-04-15 01:37:52

---
title: What is a good documentation for you and what tools do you use?
published: true
description: Getting the knowledge of the community about docs.
tags: discuss, docs
---

It seems documentation never gets the love its deserve for our own good and there are many tools for that, although I'm still looking for the right one. 

What are the ones that make part of you guys pipelines?
DotVVM : Add shortcuts to your buttons and links
Tags: dotvvm, dotnet, csharp, html
Published: 2020-04-15 01:27:23

As developers we used to use shortcuts during writing code. The most famous shortcut for developer and non-developer is  _CTRL+S_  for save command,  _CTRL+C_  for copy command and  _CTRL+V_  for paste command.

If you would like to add command shortcuts to your web application you need to write a massive JavaScript code but with  [DotVVM](https://www.dotvvm.com/)  it is just a matter of one line in your markup file.

One of available controls in DotVVM  **Business Pack**  is  _CommandShortcut_  control which is allowing you to assign shortcut keys to commands in your web application. Lets see how we can achieve it.

## CommandShortcut Control

it is an invisible DotVVM control lives in  **_DotVVM.BusinessPack.Controls_**  namespace and allows to triggers a command a viewmodel for a key shortcut.

You can create different combinations of shortcut using  _CTRL_,  _Shift_,  _Alt_, and  _Key_  properties of  _CommandShortcut_  control.

1.  Open your Visual Studio and create new DotVVM Web Application.
2.  In Custom Your DotVVM Project, check DotVVM Business Pack and Sample CRUD Page checkboxes.

    ![](https://miro.medium.com/max/3675/1*HvMkJ0dV1fcVd4HEYrd_3w.png)

    > Note : You must have a valid license to be able to check DotVVM Business Pack checkbox otherwise it will be disabled.

3. Open _DotVVMStartup.cs_ and add the below line to _ConfigureServices()_  method if doesn’t exist.

    ```
options.AddBusinessPack();
```

4. Build and run your application. In the Home page you will New Item button that we want to create a shortcut key for it.

    ![](https://miro.medium.com/max/4363/1*mo3bbdxlFSvqcAprtcTcag.png)

5. Open  _Default.dothtml_  file you and add the below lines where we add  _CommandShortcut_  control and create a new shortcut using  **_CTRL+ALT+N_**  combination.
     ```
<bp:CommandShortcut Ctrl="true"   
                    Shift="false"  
                    Alt="true"  
                    Key="N"  
                    Command="{command: NewItem()}" />
```
6. Open  _ViewModels/DefaultViewModel.cs_  file and add  _NewItem()_  method that just do nothing but redirects to the  _CRUD_Create_  route
    ```
public void NewItem()  
{  
    Context.RedirectToRoute("CRUD_Create");  
}
```
    > _Note: Here we added a new method just for redirecting to_ CRUD_Create _route because_ RouteLink _doesn’t have command property. another work around is replace_ RouteLink _control with_ Button _control._

7. Build and run your solution

8. press  **CTRL+ALT+N**  to redirect to create view.



## Summary

In this article we knew how to create a shortcut key to command using  _CommandShortcut_  control which is part of  **DotVVM Business Pack**.

You can find the full code on  [Github](https://github.com/miroprocessor/dotvvm-shortcuts).
Scheduling Algorithm
Tags: scheduling, dynamic, programming, algorithms
Published: 2020-04-15 01:22:05

---
title: Scheduling Algorithm
published: true
description: This demo
tags: scheduling, dynamic, programming, algorithms
---
This Python Notebook (https://github.com/rishiraj824/scheduling/blob/master/scheduling.ipynb) demonstrates the scheduling algorithm for a list of activities provided through a CSV. It uses the dynamic programming approach to solve for the most compatible activities.

The above solution works for any given activity board as it takes into account the maximum earnings from those activities.

Step 1.
We first sort all our activities based on their finish times and compare the activities one by one to find the next compatible activity because activities cannot overlap each other.

Step 2.
We use a binary search to find the most compatible activity. This takes us O(lg n) time.

Step 3.
We do this n times and while we do this we save the activity names to output all the possible activities in the end.

Step 4.
Keep adding the reward of all the compatible, highest rewards and display the sum in the end.
Developer Professional: Be Kind
Tags: professional, developer, softskills, culture
Published: 2020-04-15 00:15:41

---
title: Developer Professional: Be Kind
published: true
description: The way to be an excellent developer 
tags: professional, developer, soft skills, culture
---

The majority of the time, I've seen how it works the professional developers when working on our environment. I have seen they have some times focus just on technical skills (coding, architecture, databases, technical issues) and tend to gone losing some soft skills, like that have good care with your team or your product.

Nowadays, It's easy to get jobs, to some developers. The HR Manager looks at your CV and: Wow, I want to reach this guy. When the developer has been interviewed, seen like it's how to comport with a casual conversation, see kindness, see empathy, and see much more about your CV describes. And sometimes, the "good" developer isn't just about technical skills.

But ok, we can't change our mind about making the best technical test, with good principles and best practices, but don't forget soft skills.

I look at five primary soft skills are essential and crucial to all developers:

* Empathy - Understand the other side. Be kind. Put yourself on the problem.
* Communication - Be educated, interested, confident.
* Open-minded - With the above comportments, be open-minded. Understand the problem and transform your big problem in simple.
* Teamwork - Don't show you the first developer of the world. It's good you get ideas, discussions, share acknowledgment, joining with the above behaviors as well.
* Patience - You will work with the best or worst developers like you technically.  Tolerance could be your guide to growth as a professional. Try to teach, explain, understand the time of learns of each one.

When you get a new job or looking for a new job, you grow up on your career, enjoy these tips to be an excellent professional, and bring this on your entire work.

Look some articles or videos related:

https://hackernoon.com/10-soft-skills-every-developer-needs-66f0cdcfd3f7

https://www.youtube.com/watch?v=crD6Qy75tyo

https://careerbuzz.prosky.co/articles/thursday-trend-getting-soft-skill-inspiration-from-ted-talks

That's all!
Encapsulation in Dart: Part 5
Tags: oop, dart, webdev, beginners
Published: 2020-04-15 00:14:50

We made it! Part 5 of the object oriented programming series. we will be discussing what is the purpose, use cases, and what does encapsulation even mean. Encapsulation is use to hide a specific property or method  only making those properties accessible within the scope of the function.

A real world example would be if you are with some friends. And you have a piece of cake in a public environment, those friends have also have access to your piece of cake but if you take your piece of cake to another area which is private or protected then the piece of cake is no longer accessible to your friends. This is a real world example of encapsulation.

``` File: cake.dart ```

```dart
library cake;

class MainCake{
//non-private property
//list of strings
 List<String> randomPieceOfCakes = ['cake3', 'cake4', 'cake5', 'cake6'];

 //private properties
 String _pieceOfCake1 = "cake1";
 String pieceOfCake2 = "cake2";
}
``` 

``` File: main.dart ```

```dart
import 'cake.dart';

void main(){
  MainCake newCake = new MainCake();
  //non-private property -  randomPieceOfCakes
  print(newCake.randomPieceOfCakes);

  //private property - piece of cake
  print(newCake._pieceOfCake1); // private property error

  // non-private private - piece of cake
  print(newCake.pieceOfCake2);
}
```

**NOTE:** Encapsulation in Dart happens at library level instead of class level unlike other object oriented programming languages.

In Dart, (_) underscores in Dart are private. This wraps up the series on object oriented programming. Hope you enjoyed it!
Update⚠️: WhatsApp Covid Auto-response bot
Tags: twiliohackathon, laravel, corona
Published: 2020-04-15 00:07:28

[Comment]: # (All of this is placeholder text. Use this format or any other format of your choosing to best describe your project.)

[Reminder]: # (Make sure you've submitted the Twilio CodeExchange agreement: https://ahoy.twilio.com/code-exchange-community)

[Important]: # (By making a submission, you agree to the competition's terms: https://www.twilio.com/legal/twilio-dev-hackathon-terms)


## What I build:
If you’ve been following with series you know what am up to. The app is now up and running, be sure to check it out [here](https://wa.me/14155238886/?text=join%20chicken%2Dmix).

Here are some screen shot of the responses.


## Demo Link
 
This is the [WhatsApp link](https://wa.me/14155238886/?text=join%20chicken%2Dmix) to the bot.
Send the prefilled message and you’re all set.

## Link to Code

https://github.com/SaidiAli/covid-19-autoresponse-whatsapp-bot

## How I built it (what's the stack? did I run into issues or discover something new along the way?)
I did run into some issues for sure, I needed a way to get all contacts from my sandbox in twilio. At first I thought there is an endpoint that twilio provides to give such info but no. So I manually do it.
I also wanted a way to be notified when someone joins my sandbox and I trigger a welcoming message but that is also not supported by twilio. If am wrong about this please help and correct me. 

## Additional Resources/Info
The app is deployed on Heroku.
The bot is majorly centralized to Uganda as a country but the updates and information is general. 
Am open for any suggestions and feedback. 
Please try it and technical criticism is welcomed.
windbg a .net core 3.1 app memory leak
Tags: dotnet
Published: 2020-05-06 07:07:30

---
title: windbg a .net core 3.1 app memory leak
published: true
date: 2020-04-14 23:00:00 UTC
tags: dotnet
canonical_url: https://gsferreira.com/archive/2020/04/windbg-a-net-core-31-app-memory-leak/
---

I've spent the past few days trying to fix a memory leak. I was having problems to figure out what was leaking, so I used windbg wishing that it would help me.

I confess that I'm not an experienced user of windbg, so I google how to catch memory issues using windbg. There's a ton of information out there. The problem is that I didn't found a guide on how to do it with a .net core application.

So, I'm sharing here how I've done it:

 1. Install windbg ([see here](https://docs.microsoft.com/en-us/windows-hardware/drivers/debugger/debugger-download-tools)).
 2. Add windbg.exe (x64 version) to your environment path.
 3. Install SOS ([see here](https://github.com/dotnet/diagnostics#installing-sos)): `dotnet tool install -g dotnet-sos`.
 4. Set breakpoint(s) using `System.Diagnostics.Debugger.Break()` in your source code.
 5. Update your project (*.csproj file) to Load Symbols: `<DebugSymbols>true</DebugSymbols><DebugType>pdbonly</DebugType>`.
 6. Build your project using Release configuration: `dotnet build -c Release`.
 7. Launch with WinDbg attached to your project: `windbg dotnet [YOUR DLL PATH].dll`.
 8. [Load SOS](https://bret.codes/net-core-and-windbg/#loadsos) using `.load C:\Users\[USERNAME]\.dotnet\sos\sos.dll .`.

  ![windbg - load sos](https://gsferreira.com/images/windbg-a-net-core-31-app-memory-leak-load-sos.png)

 9.  Enter `g` to go to the first breakpoint.
 10. Enter `!gchandles` to see garbage collector handles.
 11. `!DumpHeap /d -mt [MT]` using the memory type id from the result list of the previous command. Example: `!DumpHeap /d -mt 00007ffb4c85ca98`
 12. `!gcroot -all [ADDRESS]` using the memory address form the result list of the previous command. Example: `!gcroot -all 0x0000023cd2e71510`

Following this guide, you should have a clue of what is still in memory and where the object is in use.

Hope this helps.
What’s your alternative solution? Challenge #21
Tags: challenge, javascript, codenewbie, learntocode
Published: 2020-04-14 22:43:09

# About this series

This is series of daily JavaScript coding challenges... for both beginners and advanced users.

Each day I’m gone present you a very simple coding challenge, together with the solution. The solution is intentionally written in a didactic way using classic JavaScript syntax in order to be accessible to coders of all levels.

Solutions are designed with increase level of complexity.

## Today’s coding challenge

```
Create a function that will return in an array the first "nPrimes" prime numbers greater than a particular number "startAt"

```

(scroll down for solution)

## Code newbies

If you are a code newbie, try to work on the solution on your own. After you finish it, or if you need help, please consult the provided solution.

## Advanced developers

Please provide alternative solutions in the comments below. 

You can solve it using functional concepts or solve it using a different algorithm... or just solve it using the latest ES innovations.

By providing a new solution you can show code newbies different ways to solve the same problem.

## Solution

```javascript
// Solution for challenge19

println(getPrimes(10, 100));

function getPrimes(nPrimes, startAt)
{
    var ar = [];
    
    var i = startAt;
    
    while(ar.length < nPrimes)
    {
        if (isPrime(i))
        {
            ar.push(i);
        }
        
        i++;
    }
    
    return ar;
}

// Returns true if a number is prime
function isPrime(n)
{
    if (n < 2)
        return false;
        
    if (n == 2)
        return true;
    
    var maxDiv = Math.sqrt(n);
    
    for(var i = 2; i <= maxDiv; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
    }
    
    return true;
}

```


To quickly verify this solution, copy the code above in this coding [editor](https://codeguppy.com/code.html) and press "Run".

> Note: The solution was originally designed for [codeguppy.com](https://codeguppy.com) environment, and therefore is making use of `println`. This is the almost equivalent of `console.log` in other environments. Please feel free to use your preferred coding playground / environment when implementing your solution.