teleren/devto huggingface dataset:
How to easily Dockerize your NestJs App
Tags: docker, javascript, showdev, webdev
Published: 2020-05-02 19:22:18

In this [previous article](https://dev.to/edgargonzalez525/how-to-schedule-a-cron-job-with-nestjs-in-less-than-5-mins-cmi) I talked about how to create cron jobs with a NestJs application, now I'm going to take that same app and create a Docker script that we can use to deploy it on a production environment like AWS.

You can find the source code for this guide [here](https://github.com/edgargonzalez525/nestjs-cron).

I will assume you have some basic knowledge of how Docker works for this guide.

To Dockerize our app we are going to be using the following Docker file:

You can also find a gist for this Docker script [here](https://gist.github.com/edgargonzalez525/1313af5d7e44a8437acc58184ba469c9).

```Docker
FROM node:12.15.0-alpine

# Create app directory
WORKDIR /usr/src/app

# Copy package files
COPY package*.json ./

# Install npm packages
RUN npm install

# Bundle app source
COPY . .

# Build our app for production
RUN npm run build

EXPOSE 3000
CMD [ "npm", "run", "start:prod" ]
```

I will go through each of the lines on the file and explain what they mean.

* `FROM node:12.15.0-alpine`

In this line we are telling Docker to use as a base image the node:12.15.0-alpine, this node version was enough for the purpose of our app, I recommend always using a fixed version for your Docker scripts and not the latest o stable one, because when those versions change something can break on your app. So manual version updated are preferred by me.

* `WORKDIR /usr/src/app`

This is the directory where we will copy and build our app.

* `COPY package*.json ./`

A wildcard is used to ensure both package.json AND package-lock.json are copied where available (npm@5+)

* `RUN npm install`

Here we will install all npm dependencies. It is recommended to use `npm ci` instead for prod environment, but I had some trouble to make that work properly with NestJs build command so I kept it simple with the usual `npm install`

* `COPY . .`

Copy the rest of the app files. To avoid copying unwanted files, like the local dist folder or node_modules folder use a `.gitignore` file.

* `RUN npm run build`

Execute the build command of our project, this will internally execute the NestJs build command and will generate the distribution files of our app.

* `EXPOSE 3000`

This line is to expose port 3000 on the Docker instance that will be created. This port will depend on the port your app runs.

* `CMD [ "npm", "run", "start:prod" ]`

Finally, execute our app and keep it running in the Docker instance.

To test the Docker script you can execute the following commands on the root of the project, remember to create the Docker and the `.dockerignore` files.

* Build docker image `docker build -t nestjs-cron .`
* Run docker instance on port 3010 of our local machine `docker run --name nestjs-cron -p 3010:3000 nestjs-cron`


As you saw it is very simple to dockerize our NestJs app. See you the next time.
PHP Laravel microservices + WEB APP development
Published: 2020-05-02 19:21:29

We have Legacy application (Learning Management System ) developed in Asp.Net and SQL Server.
We are thinking to develop new LMS with lot of features and integration with third party tool such as Mailchimp,Salesforce,Payment getaways etc.
We are looking for expert advice whether to use PHP Laravel or Lumen framework to build complete application.
Any suggestions are welcome.
The obvious mistakes you still make as a senior developer
Tags: programming, essay
Published: 2020-05-02 19:20:54

---
title: The obvious mistakes you still make as a senior developer
published: true
date: 2020-05-02 19:12:46 UTC
tags: programming,essay
canonical_url: https://siderite.dev/blog/obvious-mistakes-as-senior-developer/
---

  Original post at: https://siderite.dev/blog/obvious-mistakes-as-senior-developer

  I want to write this post to talk about the most common mistake I make as a software developer, even after almost 20 years of experience. And it's not code related. It's more human. But I would also like to hear what you think your biggest mistakes are that are not related to lack of experience. Don't be shy!

  My mistake: assumptions.

  I was assigned this bug recently and, wanting to do a fast job and impress people, I investigated the code, noticed a bug, fixed it, then immediately gave it in for review. I had reasons for doing that, because I was new and did not know the application well. The leads would tell me if they thought I did not find the problem. But, out of the goodness of my heart, you see, I've decided to test the fix as well. And I discovered that the feature was barely implemented. It was not a bug, it was a full fuck up.

  What happened here? I assumed a certain quality of the code and expected, without any reasonable evidence, to find a small typo or a logic bug that would be solved by writing a few lines of code. Instead, I had to reimplement the whole thing as a fix, I pissed off the lead devs because they had enough on their plate and made the entire team wonder what I was doing there. I mean, I haven't even tested the fix!

  Doing things fast means working on valid assumptions that allow you to cut corners. In a new environment, with a team you are not familiar with and a code base you don't understand, you do not have the luxury to make assumptions. Instead, do a good job first: investigate thoroughly, see what the reported problem is, find the actual problem (which may be different), come with an attack plan, implement it, then test that it had the desired result. Yes, it takes more time than to quickly compile the logic flow in your head and hope for the best, but in some places you don't get second chances at fixing things, teams are more formal, processes need to be followed. Optimism is also based on assumptions. Be a realist instead.

  In order to win a game you need to know its rules. That applies both to development process and to local politics, which sometimes are more important than the work. Once you are a good player, you can start experimenting. The title "senior developer" is not given in a vacuum, but is relevant (or not) depending on the environment. Yes, you have experience, but you don't have \*this\* experience yet. In my desire to be efficient and fast I didn't do anything right and I couldn't believe I have been that stupid.

  Now, how about you? What are your silly mistakes that you can't believe you are still making?
How Slack’s New Website Brilliantly Converts Visitors Into Users
Tags: slack, saas
Published: 2020-05-02 18:59:16

Fun fact: Historically, Slack re-builds its website every single year, sometimes even twice a year. That’s so crazy! I love the new 2019 Slack website, and I want to walk you through everything you need to steal from it for your own website.

What You Will Learn

Essentials of a great SaaS
website

• Effectively combines benefits 
and features, and explains it’s product. 

• Uses animation to give a sneak-peek inside the product.

• Shows up integrations 

• Include testimonials that converts visitors.
Fundaments of Dart programming lenguaje
Tags: dart, programming, google
Published: 2020-05-02 18:52:01

En este post te mostrare ejemplos de las características del lenguaje, para que nos familiarizaremos con ello y sus conceptos básicos propios del lenguaje de programación.

##Colecciones
Las colecciones son objetos de tipo estructuras de datos que almacenan diversos elementos, existen 2 tipos de colecciones, las listas y los sets.

En Dart los arreglos son Objetos ordenados de tipo List los cuales almacenan con un índice a cada uno de los elementos, mientras que los sets son colecciones que contiene valores únicos (no se pueden repetir) no ordenados (no se pueden recuperar mediante índices).

Una lista permitirá agregar los elementos que se deseen, mientras que un set no permitirá volver a agregar un valor ya existente, pero tampoco mandará un error.

### Declaración e inicialización
La forma de inicializar una coleccion se muestra en el siguiente ejemplo:
``` dart
main(List<String> arguments) {

    // COLECCIONES List
    List colors; // inicializar una lista en null
    colors= ['Black', 'Red']; // asignar elementos

    // COLECCIONES Set    
    Set cities; // Inicializar un set en null    
    cities= Set.from(['Guadalajara','Puebla','Monterrey']); // Asignar elementos
}
```

### Ejemplos de uso
Generalmente lo usaremos para almacenar los datos que obtengamos de una base de datos y posteriormente mostrarlos en tablas o en inputs de  tipo option list, al final el uso que le demos depende de nuestras necesidades que nos convenga usar más en su debido momento.

Se pueden usar para enviar una lista de elementos donde si nos interesa mantener el orden en que se van agregando podemos usar una colección List y si lo que nos interesa es que no se repitan podemos usar una colección Set.
``` dart
main(List<String> arguments) {

    // COLECCIONES List
    List colors; // inicializar una lista en null
    colors= ['Black', 'Red']; // asignar elementos
    colors.add('Pink'); // agregar un elemento
    print(colors);

    colors.removeLast(); // remover el último elemento
    print(colors);

    List<String> otherColors = ['Blue','Green']; // Inicializar una lista con tipo de dato String
    colors.addAll(otherColors ); // agrega todos los elementos de una lista
    print(colors);
    
    colors.removeAt(2); // Remueve un elemento indicándole el indice del elemento
    print(colors );

    // COLECCIONES Set    
    Set cities; // Inicializar un set en null    
    cities= Set.from(['Guadalajara','Puebla','Monterrey']); // Asignar elementos
    print(cities);

    cities.add('Yucatán'); // Agregar un elemento
    print(cities);
 
    cities.remove('Puebla'); // Remover un elemento indicando el nombre
    print(cities)
}
```

### Diferencias entre ellas
Entre las diferencias tenemos que en una colección Set jamás se van a repetir los elementos y al tratar de agregarlo no nos arroja ningún error, en cambio una lista si nos permite agregar elementos repetidos ya que la forma de diferenciarlos es mediante su índice que como sabemos en programación inicia en 0.
dev.to as a generic blog?
Tags: discuss, beginners
Published: 2020-05-02 18:41:25

---
title: dev.to as a generic blog?
published: true
description: Is it a good idea to use dev.to for other subjects than development?
tags: discuss, beginners
---

Do any of you use dev.to as a generic blog, besides development-related subjects (I'm thinking genealogy for example)?

What would be the pros and cons?
Why Should You Start a Blog?
Tags: blog, blogging, blogs, blogger
Published: 2020-05-02 18:39:50

Books and articles provide information, work gives experience, and a blog helps to comprehend all this. It will assist you to hold in your head not 1%, but 3% of useful information. Three times more, by the way! The numbers are conditional, but they demonstrate the main principle. Also, a specialist with a blog will become more known in his field than a specialist without a blog.

Other blogging rules and benefits:
==================================

1\. Blogging boosts your understanding of things. While you writing, you yourself will understand the topic better.

2\. If you have to explain something for the third time, write a post and give a link to it. This will save time in the future.

3\. Some posts will be useful to other people. These people will trust you more. Inside the company, this happens very quickly, changing attitudes and atmosphere. Especially important for distributed teams.

4\. A professional blog is more important than any resume.

"Hire great writers. When choosing between several applicants for the same position, give preference to someone who is better at writing. It does not matter if this person is a marketer, seller, designer, programmer, or anyone else, his writing skills will pay off."

5\. Being a good writer means more than being able to write. The ability to clearly state one's thoughts is a sign of a clear mind. Great writers can interact with other people. They make things more understandable. They can imagine themselves in the place of someone else. They know what can be neglected. And these are the qualities that you want to see in any candidate. "

6\. A blog is a personal project. Blogging trains self-discipline and the skill of managing long projects.

7\. A blog works as a thought book: it describes an idea --- it frees up space in the head for the next. You can not even publish. I have 97 drafts and I'm unlikely to publish most of them. This is normal.

The blog is well suited for exploring a new field of knowledge. Keep a blog as a diary, organize information. This will serve as proof that you are ready for real tasks in this area. "

If it made you curious, learn more about [how to start a WordPress blog](https://www.onlinetoolsexpert.com/how-to-start-a-blog/), which is the best blogging platform these days.
If you use Git and VS Code – Read This!
Tags: vscode, git, webdev, javascript
Published: 2020-05-02 18:36:23

{% youtube WotbsEIjqrs %}
I am, like many other developers nowadays, using Git and VS Code as my version control and code editor. Couple of weeks ago I wrote about the [Best extensions for VS Code in 2020](https://codepulse.blog/best-extensions-for-vs-code-in-2020/?utm_source=devto).

In that post I mentioned GitLens as one of my favourite plugins. This was mostly because I use Git and I need to see Git commit history and changes for a given file and VS Code itself doesn’t offer a good tool for that. Well not until March 2020 update.

## Introducing Timeline
In the [March 2020 update](https://code.visualstudio.com/updates/v1_44#_timeline-view) Timeline view was out of preview and enabled by default. Timeline view is a unified view for visualising time-series events (for example, Git commits, file saves, test runs, etc.) for a file.

So basically you can select different sources for the timeline and if you for example select Git as a source, you get nice view of Git commit history for a file. You can also view the commits and see a diff view for the file.

Here is a quote from the release notes: _In this release, the built-in Git extension contributes a timeline source that provides the Git commit history of the specified file. Selecting a commit will open a diff view of the changes introduced by that commit. A context menu provides commands to Copy Commit ID and Copy Commit Message. There is also a new Open Timeline command on the File Explorer’s context menu, to quickly show the timeline for the selected file._

![Timeline view](https://i1.wp.com/codepulse.blog/wp-content/uploads/2020/05/vscode-timeline.gif?w=640&ssl=1)

I have been using the timeline view quite a lot for the past few weeks and personally I think it’s a great and very needed addition to VS Code. What do you think?

-----------
_Originally published at [codepulse.blog](https://codepulse.blog/if-you-use-git-and-vs-code-read-this/?utm_source=devto) on May 2, 2020._

-----------
_Subscribe to my [Youtube channel](https://www.youtube.com/channel/UC34UXFLKqdW3cpk5CBu2Siw/?sub_confirmation=1) for videos about software development!_
LeetCode 1365. How Many Numbers Are Smaller Than the Current Number
Tags: csharp, algorithms, leetcode
Published: 2020-05-02 18:24:54

The problem can be found [here](https://leetcode.com/problems/how-many-numbers-are-smaller-than-the-current-number/). 
The obvious brute force solution to has a complexity of `O(n^2)`, so we should try to think of something better. I present my solution below.

#### Solution explanation
After we sort the array, the index of an element shows how many smaller elements there are, except when we encounter duplicate elements. To fix this, we scan the array, and if the current number is seen for the first time (meaning that all elements before it are smaller, and none are equal to it), we add the index to the dictionary, otherwise we skip it, because even though the index is incremented, the previous number is equal to the current one, not smaller.

Afterwards, we simply scan the original array (so that we can output the answers in the correct order), and retrieve the quantities for each of the elements.
#### Complexity
The `Array.Sort()` method has an average case complexity of `O(n*logn)`, copying the array and scanning the elements takes up `O(n)`.

#### Code
```C#
public class Solution {
    public int[] SmallerNumbersThanCurrent(int[] nums) {
        Dictionary<int, int> smallerNumbers = new Dictionary<int, int>();  
        int[] numsOriginal = new int[nums.Length];
        int[] ans = new int[nums.Length];
        
        // Copy original array
        for(int k = 0; k < nums.Length; k++)    
            numsOriginal[k] = nums[k];
        
        Array.Sort(nums);
        
        // First element has no smaller numbers anyway
        smallerNumbers.TryAdd(nums[0], 0);
        
        for(int i = 1; i < nums.Length; i++) 
            if(nums[i - 1] != nums[i])
                smallerNumbers.TryAdd(nums[i], i);
        
        for(int j = 0; j < numsOriginal.Length; j++)
            if(smallerNumbers.ContainsKey(numsOriginal[j]))
                ans[j] = smallerNumbers[numsOriginal[j]];
        
        return ans;
    }
}
```
IST 402: Web Components
Published: 2020-05-02 18:11:10

Web Components are a collection of web Platform API’s that can be used to create new custom, reusable and encapsulated HTML tags to be used in web pages and web apps. Web Components are based on existing web standards. Web Components play a major role in the website development process and developers can pull additional resources previously created and utilize these tasks. The driving idea behind web components is creating dynamic interface elements without using custom JavaScript code or building new libraries. This allows for developers to not be tied to one framework because new custom components will work in any other framework. Web components also allow for better brand consistency. Developers only need to write the custom web component one time and then can use it in other projects by simply calling the element. This allows for a standardization of content across multiple pages of a site. Businesses can also benefit from the use of web components because of the reusability of the components. Before web components, web developers would have to repeat the same process of creating custom headers and features of a web page.  With the reusability of web components web developers spend less time on writing custom code and businesses save money. Different libraries can be useful for finding web components to add to a new site. More web components will be used as more are created, so it will become essential for web developers to understand where they can find specialized web components. Web components allow for the creation of uniform websites simple to build and allows for scalability for a growing site. 

YouTube Video: https://www.youtube.com/watch?v=o2UUQzEtygQ&feature=youtu.be
Introducing Replay: a cross-platform JS game engine inspired by React
Tags: gamedev, javascript, react, showdev
Published: 2020-05-02 18:09:36

---
title: Introducing Replay: a cross-platform JS game engine inspired by React
published: true
description: Initial launch post for Replay
cover_image: https://user-images.githubusercontent.com/15923595/80872097-c3c33a00-8ca7-11ea-8043-8b47e4138042.png
tags: gamedev, javascript, react, showdev
---

Today I'm publishing a new open-source library for creating games: [Replay](https://replay.js.org/).

I've built many indie games over the years (such as [The Impossible Game](https://www.flukedude.com/theimpossiblegame/)). I've also built many web apps using [React](https://reactjs.org).

[Replay](https://replay.js.org/) takes the ideas and concepts that makes React such a great library for building user interfaces, and brings them to game development. Take a look at how Replay manages state and rendering through a declarative API:

```js
const Player = makeSprite({
  init() {
    // Initial state
    return {
      posX: 0,
      posY: 0,
    };
  },

  loop({ state }) {
    // Return new state at 60 fps
    return {
      posX: state.posX + 1,
      posY: state.posY + 1,
    };
  },

  render({ state }) {
    // Draw a circle based on current state
    return [
      t.circle({
        position: {
          x: state.posX,
          y: state.posY,
        },
        color: "#147aff",
        radius: 10,
      }),
    ];
  },
});
```

Check out [the docs](https://replay.js.org/docs/intro) on how to quickly get setup with a new JavaScript or TypeScript project, and then deploy to the web or iOS.

I hope you enjoy using it to build some new games!
How do you manage wellness and avoid distractions?
Tags: discuss, mentalhealth, productivity
Published: 2020-05-02 18:05:06

With so many new remote workers I'd love to hear how others are managing this new way of work.

My living room has now become an office/gym/living room. Separating work and life is more challenging for me now. The desk and laptop are always looming in the corner of the room.

Conversely, I tend to become more distracted without the structure of the office.

- How do you all separate work from life?
- How are you managing your mental health?
- How are you remaining focused during the workday?
Maratona digital gratuita vai capacitar pessoas para o mercado de tecnologia
Tags: career, trianing, shedotech
Published: 2020-05-02 17:55:26

---
title: Maratona digital gratuita vai capacitar pessoas para o mercado de tecnologia
published: true
description: Treinamento será oferecido de 18 de maio a 3 de julho pela organização WoMakersCode. 
tags: career, trianing, shedotech
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/nwwarmnvle69koh84a5g.png
---

Com foco em capacitar mais mulheres para atuar na tecnologia, apresentar as profissões e principais passos para começar uma carreira em TI, o Hacking de Carreira será realizado entre os dias 18 de maio e 3 de julho. A capacitação será gratuita e online, transmitida através da plataforma da WoMakersCode, com aulas semanais, organizadas em 9 módulos de conteúdo e planos de estudos. 

As participantes irão aprender sobre planejamento de carreira, preparação para processos seletivos. Nesta primeira edição online, também aprenderão sobre algumas das áreas que têm uma alta demanda de contratação, como Cloud Computing, Inteligência Artificial e Cyber Security. 

Com o Hacking de Carreira, a WoMakersCode pretende impactar mulheres e empresas em todo o Brasil, gerando mais oportunidades de empregabilidade na área da tecnologia e incentivando o fortalecimento da diversidade no mercado, que ainda é muito masculino. As aulas serão ministradas por mulheres profissionais na área de tecnologia e recrutamento.

As inscrições e a programação completa pode ser acessada no site [https://womakerscode.org/carreira](https://womakerscode.org/carreira)


> Treinamento será oferecido de 18 de maio a 3 de julho pela organização WoMakersCode. Planejamento de carreira, processo seletivo, storytelling profissional e atuação nas principais áreas da tecnologia serão alguns dos temas abordados nos workshops online