teleren/devto huggingface dataset:
Inside the Gpt-3-Powered Chatbot That Someone Used to Talk to Their Fiancé Who Passed — on DevNews
Tags: news, podcast
Published: 2021-08-12 18:56:37

---
title: Inside the Gpt-3-Powered Chatbot That Someone Used to Talk to Their Fiancé Who Passed — on DevNews
published: true
description: Listen to S5E4 of the DevNews pod!
tags: news, podcast
series: DevNews Season 5
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/zoxvbu0494gq3sxtjp4v.png
---

Listen to S5E4 of the DevNews podcast today!

{% podcast https://dev.to/devnews/s5-e4-inside-the-gpt-3-powered-chatbot-that-someone-used-to-talk-to-their-fiance-who-passed %}

**Hosts:** @saronyitbarek & @joshpuetz 

**Guest:** 
- [Jason Rohrer](https://twitter.com/technollama), Designer and Creator of Project December, whose GPT-3-powered chatbot has been used by people to talk to historical figures and personalities, and was even used by one person to talk to his late fiancé for closure.


---

_You can [follow DevNews](dev.to/devnews) to get episode notifications and listen right in your feed_ _— or subscribe on your platform of choice! Plus, if you leave us a review, we'll send you a free pack of thank-you stickers. Details [here](https://airtable.com/shr8oKAIMZgdYnBxx)._ 

## **Quick Listening Links**
- [Apple Podcasts](https://podcasts.apple.com/us/podcast/s5-e4-inside-the-gpt-3-powered-chatbot-that-someone/id1525581923?i=1000531798349)
- [Spotify](https://open.spotify.com/episode/2bP3DMe7ix5yyRbDL5Uh8d)
- [Google](https://podcasts.google.com/feed/aHR0cDovL2ZlZWRzLmNvZGVuZXdiaWUub3JnL2Rldm5ld3NfcG9kY2FzdC54bWw/episode/aHR0cHM6Ly9kZXZwb2RzLmRldi9wb2RjYXN0cy9kZXZuZXdzLzM2?sa=X&ved=0CAQQkfYCahcKEwig1urVk6zyAhUAAAAAHQAAAAAQCA)
- [Stitcher](https://www.stitcher.com/show/devnews/episode/s5-e4-inside-the-gpt-3-powered-chatbot-that-someone-used-to-talk-to-their-fiance-who-passed-86055371)
- [Listen Notes](https://www.listennotes.com/podcasts/devnews/s5e4-inside-the-gpt-3-q7jKnkDQxc_/)
- [TuneIn](https://tunein.com/podcasts/Technology-Podcasts/DevNews-p1352512/?topicId=165079324)
- [RSS Feed](http://feeds.codenewbie.org/devnews_podcast.xml)
- [DEV Pods website](https://devpods.herokuapp.com/podcasts/devnews/episodes/178)

#### _Acknowledgements_ 
- _@levisharpe for producing & mixing the show_
- Our season five sponsor, [Scout APM](https://scoutapm.com/devnews) ❤️ 


We hope you enjoy this episode of DevNews!
How to configure esbuild with a build script
Tags: esbuild, javascript
Published: 2021-08-12 18:48:47

In this article, I will show how to use build scripts in esbuild. So far in this series, we've been using command-line (CLI) arguments to configure our builds. As our configuration is growing, it can become cumbersome. And what's even more important, some esbuild features - such as plugins - are not available from CLI.

# Goal
I want to keep the npm scripts set up in the [dev sever part](https://how-to.dev/how-to-set-up-a-dev-server-with-esbuild). Plus, I still want to avoid code duplication.

# Executable script

First, let's start by adding an executable file. The easiest way will be:
```sh
$ touch build.js
(no output)
$ chmod +x build.js
(no output)
```

To make the file executable with node, we have to start the file with:
```js
#!/usr/bin/env node
```

We can add a simple console.log to see if it works as expected:
```js
console.log('test');
```

With all this in place, we can call it directly from the terminal:
```sh
$ ./build.js 
test
```

(thanks to [@BenVida](https://hashnode.com/@lacikawiz) for pointing it our in a [comment](https://how-to.dev/how-to-build-solidjs-application-with-esbuild#cks8laqbt07u222s19ja01dlr) to other article).

# Basic build script

Now, we can make the build script work for our basic case `npm run build`. Let's set the `build.js` set:
```js
#!/usr/bin/env node

require("esbuild")
  .build({
    logLevel: "info",
    entryPoints: ["src/index.js"],
    bundle: true,
    outfile: "www/main.js",
  })
  .catch(() => process.exit(1));
```

A longer discussion of the basic build is my [older post](https://how-to.dev/how-to-manage-complex-configuration-of-esbuild).

# npm scripts update
We can already use this script via `npm run build`, and we can update `package.json`:
```json
{
  ...
  "scripts": {
    ...
    "build": "./build.js",
...
```

With this, our build works:
```sh
$ npm run build

> esbuild-tutorial@1.0.0 build /home/marcin/workspace/github/esbuild-tutorial
> ./build.js


  www/main.js   151b 
  www/main.css   44b 

⚡ Done in 2ms
tuxy [npm run build] ~/workspace/github/esbuild-tutorial                                                                                                                  8:09
tuxy% npm run watch

> esbuild-tutorial@1.0.0 watch /home/marcin/workspace/github/esbuild-tutorial
```

But unfortunately, the parameters we add for *watch* or *start* are ignored:

```sh
$ npm run build -- --watch


> esbuild-tutorial@1.0.0 build /home/marcin/workspace/github/esbuild-tutorial
> ./build.js "--watch"


  www/main.js   151b 
  www/main.css   44b 

⚡ Done in 2ms
```

# Links

[Repo](https://github.com/marcin-wosinek/esbuild-tutorial), [branch](https://github.com/marcin-wosinek/esbuild-tutorial/tree/step-4).

You can check out my [video course about esbuild](https://bit.ly/esbuild-course).

# Summary
In this article, we have started refactoring towards build script with esbuild. The current script works fine for our build script, and I will address the other two in next article in this series. [Sign up here for info about new posts](https://landing.mailerlite.com/webforms/landing/b8k4x6)
Get Android's screen width and height
Tags: android, tip
Published: 2021-08-12 18:42:02

Inside your Activity:

```kotlin
override fun onStart() {
    val size = Point()
    if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
        requireContext().display!!.getRealSize(size)
    } else {
        val windowManager = requireContext().getSystemService(Context.WINDOW_SERVICE) as WindowManager
        windowManager.defaultDisplay.getRealSize(size)
    }
    size.x // Width
    size.y // Height
}
```
Nginx configuration pitfalls
Tags: nginx, pitfalls, tips
Published: 2021-08-12 18:36:04

Non-obvious Nginx configuration mistakes that take tons of time to debug when things go south.

## nginx add_header not working (part 1)

Having separate `add_header` directives for different HTTP headers in `server` and `location` blocks causes the headers defined in the `server` block to be dropped from the request response.

> Source: _There could be several `add_header` directives. These directives are inherited from the previous level if and only if there are no `add_header` directives defined on the current level. ([http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header](http://nginx.org/en/docs/http/ngx_http_headers_module.html#add_header))_

Make sure you copy your `add_header` directives to your `location` blocks.

## nginx add_header not working (part 2)

By default, HTTP headers with underscores are dropped by Nginx. To fix this, set: `underscores_in_headers off;`

## Unwanted request rebalancing

The `ip_hash` algorithm rebalances your requests if you remove servers or reorder servers in the `upstream` server list and reload your Nginx config.

> Source: _If one of the servers needs to be temporarily removed, it should be marked with the down parameter in order to preserve the current hashing of client IP addresses. ([http://nginx.org/en/docs/http/ngx_http_upstream_module.html#ip_hash](http://nginx.org/en/docs/http/ngx_http_upstream_module.html#ip_hash))_

## Don’t use hostnames in your Nginx upstream blocks

Hostnames in your `upstream` block are resolved only once on Nginx start/reload, they are not dynamically resolved.

- If the hostnames can’t be resolved, Nginx will fail to start/reload.
- If their IPs change, Nginx won’t notice the change until you reload.

For these reasons, always use IPs instead of hostnames in your `upstream` blocks.

## server level return directives take precedence over location blocks

```
server {
    root /my/path;
    location /file.txt {
        try_files $uri =404;    
    }

    # ...1000 lines of Nginx config below...

    return 301 https://www.example.com$request_uri;
}
```

Code language: PHP (php)

If you request `/file.txt` you’ll get an HTTP 301. Instead, you should do:

```
server {
    root /my/path;
    location /file.txt {
        try_files $uri =404;
    }
    location / {
        return 301 https://www.example.com$request_uri;
    }
}
```

Code language: PHP (php)

## Failed POSTs are retried on old versions of Nginx

If you use an old Nginx (<1.9.13), please upgrade it ASAP. Below this Nginx version, non-idempotent HTTP requests such as POSTs are retried when they fail. This is dangerous as it could lead to sensitive requests such as payment requests being sent more than once.

(If you liked this, you might enjoy [A few tips about Nginx caching](https://dev.to/braindumpk/a-few-tips-about-nginx-caching-16o8))
What is an APIView?
Tags: django, python, rest, apiview
Published: 2021-08-12 18:12:19

The Django REST framework offers a couple of helper classes we can use to create our API endpoints.

1. `APIView`
2. `ViewSet`

The `APIView` and The `ViewSet` both classes are slightly different and offer their own benefits in this post we will be diving in `APIView`.

The `APIView` is the most basic type of view we can use to build our `API`. It enables us to describe the logic which makes our `API` endpoint.

An `APIView` allows us to define functions that match the standard `HTTP` methods:

**`GET`, `POST`, `PUT`, `PATCH`, `DELETE`**

### When to use APIViews?

1. Need full control over logic.
2. Processing files and rendering a synchronous response.
3. Calling other APIs and Services.
4. Accessing local files or data.

Now let's create our first `APIView`. First we are going to import some classes in our `views.py`.

```
from rest_framework.views import APIView
from rest_framework.response import Response
```

#### Creating `FirstAPIView` Class.

Underneath the imports let's create a new class called `FirstAPIView` and inherit from the `APIView` which we imported from `rest_framework`.

```
class FirstAPIView(APIView):
    """ Test API View """

    def get(self, request, format=None):
        """ Returns some random values """
        py_list = [
            "apples","bananas",2,5
            ]

        return Response({'message': 'Hello!', 'list': py_list})
```

We created a `get` function which will return `message` and `list` as response if we receive `GET` request on this path.

#### Wiring it to URl.

```
from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('APP_NAME.urls')),
]
```

In above code we have made changes over boilerplate code such as:
* Importing `include` function which helps us to include Urls from other apps.
* Created new path `api/` and wire it up with urls file of app.

Create new file in app folder as `urls.py` and paste below lines of code in it.

```
from django.urls import path
from APP_NAME import views

urlpatterns = [
    path('first-view', views.FirstAPIView.as_view()),
    ]
```
By adding above code we:

* Imported `path` from `django.urls` and `views` from our custom app. 
* Created `urlpatterns` which linked `first-view` path to our `FirstAPIView` class.

#### Testing our APIView.

In terminal:
```
python manage.py runserver 0.0.0.0:8080
```

Visit below link using any browser:
```
127.0.0.1:8080/api/first-view/
```

#### Demo

![Screenshot 2021-08-12 at 11.38.12 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lj4pl34ryjosx6hhd0xe.png)
#100daysofcode [Day - 02]
Tags: 100daysofcode, javascript, programming, webdev
Published: 2021-08-12 17:52:34

#100daysofcode [Day - 02]
Today I've solved some small problems.
01 Getting Leap-year,
02 Find the Biggest Number from an Array,
03 Remove the Duplicate Name or Numbers,
04 Getting the Factorial numbers
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fipnpdbx9hw17bf8k7qg.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bn0b9bkx4hmmys6immgf.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jhhgcobzrrnqzfnbvn7g.png)![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/npsamynhsq1caczyqxye.png)
#coding #javascript #webdevelopment
Uma análise sobre a Engenharia do Conhecimento
Tags: engenhariadesoftware, software
Published: 2021-08-12 17:44:08

Implementar projetos de forma eficiente e produtiva não é uma tarefa fácil. O relacionamento entre membros da equipe pode ser bastante complexo e podem surgir disputas, pressão para realização de tarefas, falta de entrosamento entre membros da equipe, pensamentos diferentes sobre a forma de desenvolver, ou mesmo a escolha da tecnologia, entre vários outros. Afinal, o ser humano é complexo por ele só.

A Gestão do Conhecimento tem a finalidade facilitar o acesso e manter um gerenciamento sobre as informações em seus diversos meios. O conhecimento é a informação interpretada, ou seja, transformar o conhecimento implícito dentro das cabeças dos funcionários em um conhecimento explícito, podendo ser compartilhado por toda a organização.

Para podermos gerenciar este conhecimento é necessário o uso de ferramentas que vão além da administração de dados e de informações, possibilitando uma melhor e mais rápida geração, codificação e transferência do conhecimento. Como qualquer ferramenta, elas foram criadas para facilitar o trabalho, assim aumentando sua produtividade.

Sabendo como o meio reage às informações, podemos prever as mudanças e nos posicionar de forma para obter vantagens e ser bem sucedido nos objetivos e projetos da empresa.

Em uma definição resumida, pode-se dizer que Gestão do Conhecimento é um processo de disseminação e apropriação de conhecimentos por todos envolvidos, com o propósito de atingir a excelência dentro da organização.

A principal preocupação na área está na busca da melhoria de desempenho, na melhora dos processos e na criação de conhecimento.

Assim, através das ferramentas e tecnologias de informação e até mesmo uma boa comunicação, de forma geral, uma boa prática de gestão influencia direta e indiretamente o bom desempenho tecnológico, organizacional e financeiro de uma empresa.

Precisamos admitir que os conhecimentos da equipe são valiosos ativos, ativos intangíveis e confinados apenas na “cabeça” de quem os possui. Uma boa gestão desse conhecimento pode ser transferido a todos e assim elevando o nível da equipe.

Quando esse conhecimento não é gerido e o membro abandona a equipe, esse conhecimento é simplesmente perdido.
WordPress vs Django
Tags: webdev, django, wordpress, programming
Published: 2021-08-12 17:31:25

After a great deal of thought, I have decided to migrate my blog from Wordpress and create a custom blog using Django.

You can check out my new blog here:

[Blog](https://www.baltlogs.com) 

Any feedback?

I posted the entire Django Takeoff!! book/course on the website for free in a series of blog posts. Enjoy !!

These are some of the reasons why I decided to build a custom blog instead of using Wordpress.

###WordPress 

####Pros

* Cheaper costs since you don't have to worry about databases, serving static files, etc.
* Allows you to focus on your writing.
* Well-known platform to start blogging.
* No programming knowledge needed.
* Little maintenance required. 

####Cons

* There are thousands of plugins but somehow I never got what I wanted from them. 
* Design of the website felt artificial.
* Limited control over how to do things.
* Great plugins = Paid plugins

###Django Custom Blog

####Pros

* Unlimited control over the website.
* Custom styling and design.
* Easy to modify(No more annoying blocks).

####Cons

* More maintenance required. 
* Higher cost (database, static files hosting, etc).
* Requires programming knowledge.

The above pros and cons are personal, in the end, it really depends what you want to focus on. If you want to focus on writing blog posts consistently, I'd say go for Wordpress. 

If you are trying to become a developer or you blog about programming, I'd say create your own custom blog.

My goal in the beginning was to write blog posts so I went for WordPress, however, as I was learning how to program, I started creating my own custom blog.

Also I was writing blogs posts about programming, yet my blog was built using Wordpress.(Nothing wrong with doing this)

Nevertheless, to me it looked as if I was preaching something and then doing something complete opposite. In other words, I wanted to lead by example. 

[Twitter](https://twitter.com/balt1794) 

[Django Takeoff!! Book](https://www.amazon.com/dp/B08H4W2WLD)
Best software development tools to use in 2021.
Tags: github, development, programming
Published: 2021-08-12 16:59:55

<b>Linx:</b> It is used for APIs, automation, and, application development. It is a low code development platform used to build and automate backend applications as well as web services.

It allows you to simply and swiftly build processes that allow you to control and rewrite data across multiple systems.

It is part of the mainstream when it comes to agile software development tools for <a href="https://codersera.com/blog/what-does-a-software-engineer-do/">Software Engineers</a>.

<b>Cloud9:</b> It is a software development environment to integrate online. Supporting multiple programming languages such as Python, JavaScript, PHP, and other Cloud9 is a great diverse option for developing software.

As of 2016, Cloud9 was acquired by Amazon Web Service and has undergone major improvements and offers more opportunities than its starting in 2010.

Cloud9 is one of the best tools for <b>software developers</b>.

<b>NetBeans:</b> It is an open-source IDE that allows you to develop desktop, mobile, and web applications.

The tool is written in Java and allows you to quickly and easily create and <b>develop applications</b>.

NetBeans is our top choice in the drag and drop software development tools category and web developers love it.

<b>GitHub:</b> It is a development and collaboration platform devoted to code. GitHub allows for both code review and code management.

The software provides the rights tools needed for development jobs and allows users to <b>build applications and software</b> as well as host code, review code, and manage projects. It definitely warrants it’s ranking in our commercial software development tools category.

<b>Codenvy:</b> It is used to code and debug applications. The software is on a cloud development environment that allows for project sharing and collaboration in real-time.

Liked these <b>software development tools?</b> Learn about the <a href="https://codersera.com/blog/software-development-tools/">top 20 software development tools in 2021</a>.
Java 17 features 
Tags: java, java17
Published: 2021-08-12 16:55:56

Java 17 features are finalized and sealed. As of this writing , it is going to be released next month (September 2021).

Though there are around 14 new features introduced in this release , only two of them directly help developers and they should be aware of these.

Those two are :

Pattern Matching for Switch
Sealed Classess
Pattern Matching for Switch is introduced as a preview feature and it is one among the ongoing features released by the Java team in the pattern matching series.

This is explained in detail here with examples :

[Pattern Matching for Switch](https://fullstackdeveloper.guru/2021/08/11/pattern-matching-for-switch-java-17/)

Sealed classes were introduced in Java 15 as a preview feature and have now become a permanent feature in Java 17.

Here is a detailed explanation on this :

[Sealed Classes](https://fullstackdeveloper.guru/2020/06/19/sealed-classes-and-interfaces-in-java/)

Most of the remaining features are related to the JVM .

Here is the full list :

[https://openjdk.java.net/projects/jdk/17/](https://openjdk.java.net/projects/jdk/17/)
Merge Sort
Tags: algorithms, sorting, typescript, mergesort
Published: 2021-08-12 16:55:45

---
title: Merge Sort
published: true
description: Merge sort is a sorting algorithm that uses a divide-and-conquer technique to sort a given list
tags: algorithm,sorting,typeScript,mergeSort
series: Sorting Algorithms
//cover_image: https://direct_url_to_image.jpg
canonical_url: https://ricardoborges.dev/merge-sort
---

Merge sort is a sorting algorithm that uses a divide-and-conquer technique to sort a given list, which means it breaks down a problem into smaller parts in order to be simpler to solve.

Merge Sort starts by splitting the list into halves, and continues to split those sublists until only sublists with a single element are left. Then merge those sublists into sorted sublists, and continue doing so until end up with a single sorted list.

```
                [4, 3, 2, 1];
                |           |
               |             |
Divide      [4,3]           [2,1]
            |   |           |   |
           |     |         |     |
         [4]     [2]     [2]     [1]
           |     |         |     |
            |   |           |   |
Conquer     [2,4]           [1,2]
                |           |
                 |         |
                 [1, 2, 3, 4]
```

## Implementation

This algorithm can be implemented with two functions, one to **divide** and another to **merge** :

```typescript
/**
 * Function to merge
 **/
function merge(left: number[], right: number[]): number[] {
  const sorted = [];

  // until one of the sublists has a element, insert them into the sorted list
  while (left.length && right.length) {
    if (left[0] < right[0]) {
      sorted.push(left.shift());
    } else {
      sorted.push(right.shift());
    }
  }

  // one of the sublists can still have leftover elements, so we need to merge them
  return [...sorted, ...left, ...right];
}

/**
 * Function to divide
 **/
function mergeSort(list: number[]): number[] {
  // base case
  if (list.length <= 1) return list;

  // split the list into two halves
  let left = list.slice(0, list.length / 2);
  let right = list.slice(list.length / 2, list.length);

  left = mergeSort(left);
  right = mergeSort(right);

  // merge the sublists
  return merge(left, right);
}

const unsorted = [5, 4, 3, 2, 1];
const sorted = mergeSort(unsorted);
console.log(sorted); // [1, 2, 3, 4, 5]
```

Merge Sort performs in O(n log n) in terms of time complexity, its space complexity is O(n) since it uses auxiliary arrays to store the sublists.
Also, we can leverage multi-threading to implement Merge Sort, sorting each half in separated threads, for example. Moreover, we can combine Merge Sort with other [sorting algorithms](https://ricardoborges.dev/starting-with-sorting-algorithms), for example, instead of splitting the list into single element sublists, we could split into small sublists with a few elements, and apply [Insertion Sort](https://ricardoborges.dev/starting-with-sorting-algorithms) to sort them.
Become Python Developer With These 5 Books
Tags: python, programming, books, devops
Published: 2021-08-12 16:14:59

1. Python Crash Course, 2Nd Edition: A Hands-On, Project-Based Introduction To Programming
2. Learning Python, 5th Edition Fifth Edition
3. A Practical Introduction to Python 3
4. Intro to Python
5. Python All-in-One For Dummies

Link to the complete Article about these 5 books as follows.
https://www.alixaprodev.com/2021/08/become-python-developer-with-these-5-books.html

#python #programming #developer #learning #machinelearning #deeplearning #project #datascience #coding #java