teleren/devto huggingface dataset:
Misunderstood suggestions
Tags: machinelearning
Published: 2021-02-27 13:46:50

A couple of years ago I was working on a calendar application, on the machine learning team, to make it smarter. We had many great ideas, one of them being that once you indicated you wanted to meet with a group of people, the app would automatically suggest you a time slot for the meeting.

We worked on it for several months. We couldn't just use simple hand-coded rules, because we wanted to do things like learn every users working hours, which could vary based on many things. In the end, we implemented this feature using a combination of both hand coded rules (to avoid some bad edge cases) and machine learning. We did lots of testing, both automated and manually in our team.

Once the UI was ready, we did some user testing, where the new prototype was put in front of real users, unrelated to our team, who were recorded while they tried to use it and then were asked questions about the product. When the reports came in, the whole team banged their heads against the desk: most users thought we were suggesting times when the meeting couldn't take place!

What happened? If you included either many people or even only one very busy person, there will be no empty slot which is good for everyone. So our algorithm would make three suggestions, saying that for each there would be a different person who might not be able to make the meeting.

In our own testing, it was obvious to us what was happening, so we didn't consider it a big problem. But users who didn't know the system, found it confusing and kept going to the classic grid to manually find a slot for the meeting.

Lesson: machine learning algorithms are never perfect and every project needs to be prepared to deal with mistakes.

How will your machine learning project handle failures? How will you explain to the end users the decisions the algorithm made? If you need help answering these questions, let's talk.
TypeScript สำหรับผู้เริ่มต้น
Tags: typescript
Published: 2021-02-27 13:36:25

> บทความนี้เหมาะกับคนที่เคยเขียน JavaScript แต่ไม่เคยเขียน Static Types เช่น C, C#, Java เป็นต้น

TypeScript เป็นภาษา JavaScript ที่ใส่ types

> แล้วมันต่างกับ JavaScript ยังไง ?

ก็ syntax ส่วนใหญ่ใช้เหมือนกัน ต่างกันแค่ตอนประกาศตัวแปร ต้องกำหนด type ให้กับตัวแปรนั้นๆ

## วิธีประกาศตัวแปร

```ts
// var [identify]: [type-annotation] = value
let name: string = 'Hello World'

// var [identify]:[type-annotation]
let name: string

// var [identify] = value
let name = 'Hello World'

// var [identify]
let name
```

## Primitive Types
เรามาเริ่มจาก primitive types ก่อน มีดังนี้

- boolean
- number
- null
- string
- undefined

เวลาเราประกาศตัวแปรที่กำหนด type แล้วจะเปลี่ยนค่าได้เฉพาะ type เดิม เช่น

```ts
let myText = 'Hello World'
// Incorrect
myText = 100
// Correct
myText = 'Hello You'
```

แล้วเมื่อกำหนด type แล้วสามารถตรวจสอบคุณสมบัติของ type นั้นๆ ได้ เช่น

```ts
let myText = 'Hello World'
// Incorrect
console.log(myText.len)
// Correct
console.log(myText.length)
```

## Any
โดยปกติ ถ้าประกาศตัวแปรแบบไม่กำหนด type ตัวแปรนั้นจะมี type เป็น any

```ts
let myText

myText = 'Hello'
myText = 100
```

## Unknown

แต่ในบางครั้ง ถ้าตัวแปรนั้นมี type ที่ซับซ้อนมากๆ เราอาจจะใช้ unknown แทนได้

```ts
let notSure: unknown = 4;
notSure = "maybe a string instead";

// OK, definitely a boolean
notSure = false;
```

## Array
```ts
let genders: string[] = ['male', 'female']
let numbers: number[] = [1, 2, 3, 4, 5]
```

## Interface or Type

ใช้กับตัวแปร object (key-value)

```ts
interface Location {
  lat: number
  lng: number
}

const myLocation: Location = {
  lat: 13,
  lng: 54
}
```
หรือ
```ts
type Location = {
  lat: number
  lng: number
}

const myLocation: Location = {
  lat: 13,
  lng: 54
}
```
โดยปกติเราสามารถใช้ได้ทั้ง interface และ type แต่ทั้งสองอย่างนี้มีข้อแตกต่างเวลาใช้ในระดับ advanced

เดี๋ยวมาดูความแตกต่างระหว่าง interface vs type กันในบทถัดๆ ไป

## Function
```ts
// ไม่มี parameter และ ไม่มีการ return ค่า
const logMessage = (): void => {
  console.log('Hello World')
}

// ไม่มี parameter และมีการ return ค่า
const getMessage = (): string => {
  return 'Hello World'
}

// มี parameter และ มีการ return ค่า
const getGreetingMessage: (name: string): string => {
  return `Hello ${name}`
}

// มี parameter ที่เป็น optional
const getFullname = (firstName: string, lastName?: string) => {
  if (lastName) {
    return `${firstName} ${lastName}`
  }
  return firstName
}

// มี parameter ที่ใส่ default value
const getFullName = (firstName: string, lastName?: string, title = 'Mr.') => {
  if (lastName) {
    return `${title} ${firstName} ${lastName}`
  }
  return return `${title} ${firstName}`
}
```

## Async Function

```ts
interface Location {
  lat: number
  lng: number
}

const fetchData = (country: string) => Promise<Location> = {
  return axios.get('/location', {
    params: {
      country
    }
  })
}
```

เพียงเท่านี้ น่าจะพอเขียน TypeScript แบบง่ายๆ กันได้แล้วนะครับ

---
## Reference
- https://www.tutorialspoint.com/typescript/index.htm
- https://www.typescriptlang.org/docs/handbook/basic-types.html
JavaScript Interview Question #25: Immediate Promise.resolve
Tags: beginners, javascript, codenewbie, webdev
Published: 2021-02-27 13:00:43

![js-test-25](https://learn.coderslang.com/js-test-25.png)

How fast is `Promise.resolve()` in JavaScript? Which of the messages will be logged first?

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

.

The logic is almost the same as in this [setTimeout example](https://learn.coderslang.com/js-test-5).

If you're new to the JS Promises, I suggest starting here:
- [What is a JavaScript Promise and how it works](https://learn.coderslang.com/0027-javascript-asynchronous-programming-and-promises/)
- [How to create Promises in JS and handle Promise chains](https://learn.coderslang.com/0029-javascript-promise-chains/)

Even though `Promise.resolve()` doesn’t have any explicit delay, the code inside of  `.then()` is executed asynchronously and has a lower priority than the synchronous code.

So, the `console.log('resolved')` will be executed after the `console.log('end')`.

---

**ANSWER**: the string `end` will be logged first, followed up by `resolved`.

[Learn Full Stack JavaScript](https://js.coderslang.com)
What's on your book shelf? 📚
Tags: books, programming
Published: 2021-02-27 12:45:10

I've read maybe only about 40%.
My favourite is probably the Illustrated Guide To Python 3.
I like that Effective JavaScript and Effective Python have syntax highlighting. It makes it easier to read.
Both JavaScript & JQuery, and HTML & CSS are beautiful books.

- Bash Pocket Reference
- The C Programming Language
- C Programming In Easy Steps
- Clean Code
- Code Complete
- C the Pocket Reference
- CSS Pocket Reference
- Delphi 6
- Delphi In A Nutshell
- Effective JavaScript
- Effective Python
- Flask Web Development
- HTML & CSS
- Illustrated Guide To Python 3
- JavaScript & JQuery
- JavaScript Pocket Reference
- Linux Pocket Guide
- MSP430 Microcontroller Basics
- Python Pocket Reference
- Regular Expressions
- Tiny Python 3.6 Notebook
- Web Design In Easy Steps
How to use @yarnpkg/core?
Tags: help, yarn
Published: 2021-02-27 12:35:51

I see that on [yarn repository](https://github.com/yarnpkg/berry#generic-packages) mentions about `@yarnpkg/core`:

> allows any application to manipulate a project programmatically.

Okay, that's what I need! But how to use it? I also found the [API documentation](https://yarnpkg.com/api/modules/yarnpkg_core.html), but I don't understand how to programmatically install a package from npmjs.com, for example.

Pseudocode of what I want:

```ts
import { someUtil } from '@yarnpkg/core';

async function myTest(packageName: string) {
  await someUtil.add(packageName); // Installing from npmjs.com
  const package = await import(packageName); // Load the newly installed package from node_modules.
  package.doSomething(); // Work with the package
}

myTest('somePackage'); // Imagine that I run this function from an HTTP request
```
DBeaver Community install Linux
Tags: linux, snap, database
Published: 2021-02-27 12:31:36

DBeaver é um aplicativo de software cliente SQL e uma ferramenta de administração de banco de dados. Para bancos de dados relacionais, ele usa a interface de programação de aplicativo JDBC para interagir com os bancos de dados por meio de um driver JDBC. Para outros bancos de dados, ele usa drivers de banco de dados proprietários.

Se você utiliza Ubuntu e derivados, a sua instalação ficará muito mais simples utilizando os pacotes snaps, criado e mantido pela Canonical. 

Caso você não conheça os pacotes snaps, segue o link abaixo para você conhecer com mais detalhes.👇

👉 https://bit.ly/3r4sGcG

Instale usando a linha de comando:

sudo snap install dbeaver-ce

Aguarde o snap concluir a instalação, caso tenha dúvidas você poderá acessar a Central de Aplicativos da sua distribuição e pesquisar pelo DBeaver e instalar. Caso o seu sistema seja Windows apenas faça o download do .exe e faça a conexão com seu banco de dados localhost ou remotamente.

Além disso, o dbeaver é compatível com mais de 80 banco de dados diferentes, além de ter uma interface simples para facilitar a vida dos novatos!

Você encontrará duas versões para download, recomendamos a Community por ser uma versão Open Source da comunidade.
vim + space = ️
Tags: vim, productivity, health
Published: 2021-02-27 12:18:21

---
title: vim + space = ❤️
published: true
description: How to improve your vim experience with a only one small change
tags: vim, productivity, health
//cover_image: https://direct_url_to_image.jpg
---

About one year ago I started using `vim` as primary text editor in my job. Sometimes I think about `emacs` and its distributions with mnemonic keybindings focused on space-key usage. It's very elegant and easy to remember `<space>-f-g` to global find, or `<space>-g-s` to reveal `git` status. As `leader` key it allows to use some plugins with pleasure.

For example [vim-surround](https://github.com/tpope/vim-surround). Instead default `\S` you can easily press `<space>S`.

In that way `space` is better for your health, because the thumb is the strongest finger on our hand. When you're using pinky finger to press `capslock` or `\` as `leader` key it not so comfortable and your hand getting tired much faster.

---

About one month ago I've discovered, that it's possible to similarly use `space` in `vim`.

> I know about [spacevim](https://spacevim.org/), but it's so complicated and I like to build my editor by myself, keeping only features what I really need.

Let's try it!

### Add `vim-which-key`

[`vim-which-key`](https://github.com/liuchengxu/vim-which-key) allows to see all your keybindings at any time. It looks absolutely like the same feature in `emacs` (and in `spacevim` too).

### Initial configuration

Add a few lines to `init.vim`:

```vim
let g:which_key_map =  {}
" needs to call `whichkey` on `whitespace` press
call which_key#register('<Space>', "g:which_key_map")
" reassign default space behaviour in normal mode
nmap <SPACE> <Nop>
" map fuzzy search on double space
noremap <Leader><SPACE> :ProjectFiles<CR>
let g:which_key_map['SPACE'] = 'project-files'
" open `whichkey` after single space press and small wait
nnoremap <silent> <leader>      :<c-u>WhichKey '<Space>'<CR>
```

### Example bindings for `git`

Add some useful bindings for [vim-fugitive](https://github.com/tpope/vim-fugitive):

```vim
let g:which_key_map.g = { 'name': '+git' }
noremap <Leader>gs :G<CR>
let g:which_key_map.g.s = 'git-status'
noremap <Leader>gc :Gcommit<CR>
let g:which_key_map.g.c = 'git-commit'
noremap <Leader>gd :Gdiffsplit!<CR>
```

These bindings can be easily remembered as `git - status` or `git - commit`.

---

That's all! If you know other useful hacks for `vim` let's discuss it! ✨
5 Redis Use Cases - Redis Lab
Tags: redis, architecture, design
Published: 2021-02-27 12:02:56

So I was seeing a video in youtube about redis use case for a specific scenarios or a system design. So I am writing down my understanding of those use-cases

### Learning: 
The key redis use-cases are being used in the video
- Caching
- Queuing
- Locking
- Throttling 
- pubsub’ing

### Summary: 
They were explaining how they integrated redis in their system in multiple layer as explaining their's system workflow.

- They `cached` the db queries in redis. 
- Then when a user requests a query it `queues` in redis and a consumer consumed the request and start processing for the query. 
- Before starting the query they `locked` the user request so that his further requests are not being processed by other consumers. If another consumer fails to `lock` a query(means it is already being locked) they `re-queue` the query again with fibonacci series seconds. 
- After they get a response from the db they generate the `cache` for the query and send back the request to redis by publishing(`pubsub`) it and on the other side the web server was listening(`pubsub`) for the response in the redis(it started listening right after it made the request to that service). When it gets back the result it responds back to the client.





The original Link can be found here, [5 Redis Use Cases with Gur Dotan](https://www.youtube.com/watch?v=znjGckK8abw)
How SOLID is your code? - Introduction
Tags: java, oop, codequality
Published: 2021-02-27 11:36:41

"I don't understand this method. I should ask the person who wrote this." 
"Hey! Your change broke the functionality I implemented few days ago."
"It may take some time, we have a merge conflict."
"It was working before. I don't know what happened now."
"I spent the whole day understanding the code."

Sounds familiar? - Sounds like a normal work day?

These are some of the discussions we have had more frequently than we would like to. Not only does it require extra time and efforts to resolve these situations, it even makes it more likely that we won't mind adding to the mess in the future.

The SOLID principles of object-oriented programming were formulated by **Robert C. Martin** with a purpose
> To create understandable, readable, and testable code that many developers can collaboratively work on. 

The five SOLID principles are:
1. *Single Responsibility Principle*
2. *Open-Closed Principle*
3. *Liskov's Substitution Principle*
4. *Interface Segregation Principle*
5. *Dependency Inversion Principle*

Let's look at each principle and understand how they become important in writing well-designed and maintainable applications.

I will divide it into a series of articles so that I can give enough time to each principle and it doesn't become too much to absorb at a time.
On the way to becoming a Developer Advocate
Tags: developer, advocate, career
Published: 2021-02-27 11:33:17

I really like to become a Developer Advocate. I'm enthusiastic, eager to learn, love to code and to like to share my knowledge.

Started already to write articles, to organise workshop and to promote some technologies. Mostly related to Ionic, Capacitor. But lately I also started to learn Machine Learning.

Next to these activities, I also read some articles about Developer Advocay.

Any suggestions how to proceed? I really would appreciate some advice.
Science made simple
Tags: science, sciencemadesimple, documentary, codepen
Published: 2021-02-27 10:36:28

Here is a small *pen* containing [links](https://en.wikipedia.org/wiki/Hyperlink) to the [Science made simple](https://youtube.com/playlist?list=PLmmQrVVEIcP68I_yCN2Vt1Tr-vsqXnIkS) documentaries.
Originally the documentary was on a **[DVD](https://en.wikipedia.org/wiki/DVD)** that they stopped selling.
I thus, because I the documentary was so interesting, decided to upload it's chapters to my **YouTube channel** so that everybody can now learn from them.
 
I do not intend to steal their work. This is the Twitter page of the company [@yorkfilms](https://twitter.com/yorkfilms) and here is their website [YorkFilms of england](http://www.yorkfilms.com/).

These documentaries are a great source of knowledge. Unfortunately, they decided to stop selling the DVD, so that is why I decided to upload the chapters. more info is in the webpage of my pen.
{% codepen https://codepen.io/henry-letellier/pen/RwoQMbp %}
Trying out lite editor
Tags: editor, lua, lite
Published: 2021-02-27 10:20:18

My main editor is VS Code. But lately, I found it a little bit too much and kind of slow for my liking, so I tried to find something else more simple and lightweight. And I found **[lite](https://github.com/rxi/lite)** and below is its main UI.

![lite UI](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/i61ijzv7s4m7s53l269r.png)

I was so surprised, because the whole package is just around 1MB and it looks pretty too. **lite** may still lacks a lot of feature comparing to VS Code but I think I like it that way and willing to give it a try.
Need advice regarding web development
Tags: webdev, career, help, discuss
Published: 2021-02-27 10:17:05

I have been learning web development for the past year. I have good knowledge of fundamentals i.e. HTML, CSS & JavaScript. I also know React and Redux. Then I learned about backend development using NodeJS i.e API, authentication, database (MongoDB), etc.

I have done few projects such as an e-commerce app, google forms clone, COVID-19 tracker, an event registration website, and an admin panel.

My question is what should I do next? Are there any projects I can do? Any technology to learn? I want to get a job as a full-stack web developer. Any advice would be helpful.
Do you know what is CSS Prefixes 😮
Tags: css, todayilearned, tutorial, codenewbie
Published: 2021-02-27 10:15:07

Hi, coding people,

Hope you all doing amazing growth in your journey.

This post is part of our "20 days CSS animation"

{% link https://dev.to/atulcodex/20-days-of-css-animation-post-3g8d %}

In this post we are going to learn about CSS prefixes 😅 actually it's not an animation syntax. Its name of a solution, I mean there are some old browsers like internet edge, opera, etc these browsers can't load some CSS animations properly that's why in CSS there some prefixes like 
* -webkit- (for old ios browsers)
* -ms- (for old Microsoft edge browsers)
* -moz- (for firefox old versions)
* -o- (for opera old browsers)

For latest browsers
* animation: sunrise 2s linear 0s infinite normal none;

Prefix for old edge browser
* -webkit-animation: sunrise 2s linear 0s infinite normal none;
* -ms-animation: sunrise 2s linear 0s infinite normal none;
* -moz-animation: sunrise 2s linear 0s infinite normal none;
* -o-animation: sunrise 2s linear 0s infinite normal none;

Now see this codepen project for real-life examples of CSS prefixes.

{% codepen https://codepen.io/atulcodex/pen/mdOXoKX %}

And if you guys interested in my free website templates please download them here 👉[AtulCodex Marketplace 🏪](https://www.instamojo.com/atulcodex/).
Premium Gift Supplier Malaysia - Seven Gifts 
Tags: corporategift, premiumgift
Published: 2021-02-27 10:12:20

As being one of the largest <a href="https://www.sevengifts.com.my/"> Gift Supplier in Malaysia</a>   , Sevengift has more than 1,000 products which range from their most popular annual dinner door gifts, exhibition door gifts, Fitness gifts, conference giveaway, employee gift, team building gifts, and sport day gifts. 

Our range of <a href="https://www.sevengifts.com.my/"> Corporate Gift</a> is always able to meet customer requirements and most of the time exceeds customer expectations for the price paid. We are able to satisfy your requirement and provide different promotional products to meet your demand. 

▶Visit Us : https://www.sevengifts.com.my/
▶Call Us : +6010 8777 078
#Premiumgift #JuteBagSupplier #Sevengifts  #Corporategiftsupplier #Corporategifts #Nonwovenbag
My Sinatra Base Web Application..."Hello Efitness!"
Published: 2021-02-27 10:00:53

# Getting Started: Woohoo

I must admit, This time around I wasn't as nervous and confused as I was when building my very first project here at Flatiron. I was very well prepared. I had a clear idea as to what I wanted to build and how I wanted my app to look. I decided to build a Fitness tracker Web App, in which a user/users are able to signup/login and begin tracking their workouts. 

# Project Structure:

  `Gem install Corneal`

Corneal is a super convenient gem which is used for creating Sinatra base templates. The gem magically creates the file structure as well as providing useful gems in a Gemfile in other to manage the dependencies in the App. 

After getting my file structure up and running, I went ahead an created my project folders and subfolders. I decided on four models: A User, Workout, Exercise and Exercise_workout. Their relationships are as follows:
```
class User < ActiveRecord::Base
    has_secure_password
    has_many :workouts

class Workout < ActiveRecord::Base
    belongs_to :user 
    has_many :exercise_workouts
    has_many :exercises, through: :exercise_workouts

class Exercise < ActiveRecord::Base
    has_many :exercise_workouts
    has_many :workouts, through: :exercise_workouts

class ExerciseWorkout < ActiveRecord::Base
    belongs_to :exercise
    belongs_to :workout
```
# Routes and Controllers

I was able to utilize RESTful routes in my App through the following: 

`ApplicationController` is the parent controller of my App. It requires the necessary files and configures views and sessions. This controller only has one route, A Get request which renders to the homepage, along with helper methods, to check whether or not a user is logged in.  

`UserController` has Get request which renders the user index page, signup form, as well as a Post request to create a user. 

`SessionsController` has Get request which renders the login form, as well as a Post request to login/authenticate a user. 

`WorkoutController` has Get requests to render the workouts index page, the form to create a new workout, as well as a Post request for that new workout created. This controller also renders the form to either update and or delete a workout.  

# Conclusion

This project was very rewarding and fun to work on. My biggest challenge was styling, which I ultimately decided to leave very basic. I learned how important it is to organize/have a rough idea prior to coding. I hope that the information provided will be helpful as other students like myself embark on this portion of their journey here at Flatiron. Happy coding!😁
Cloud Community Days - Learn Serverless & DevOps
Tags: devops, serverless, azure, kubernetes
Published: 2021-02-27 09:58:03

**Cloud Community Days is back** 📢

**Cloud Community Days** is a two day (24 & 25 March 2021), **free**, virtual, developer-focused, community driven conference themed on the various use cases of **Serverless & DevOps** on Azure, meant for professional developers!

**What to expect?**

Demo heavy talks by expert speakers on the theme "Serverless & DevOps on Azure" starting from best & latest practices bringing you a one-stop learning platform for your Cloud journey!

**Register at**: [Cloud Community Days](https://ccdays.konfhub.com/?utm_source=0b116720&utm_medium=email&utm_campaign=referral)

![image](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3ot7urcy9o83c3oje784.png)
Add loop for with condition
Published: 2021-02-27 09:57:49

var accueilsite = "Bonjour à toi Aventurier, es-tu prêt à te lancer dans une lutte sans merci contre Le Maître du Hasard"; 
        alert(accueilsite);


var tapname = prompt("Afin de personnaliser votre avatar peux-tu m'indiquer ton nom ?");
    for
    if (tapname != null) {
        alert("Merci " + tapname + "\nNous allons pouvoir commencer maintenant, bon courage...");
    
    }

// I would like a loop that allows me that:
1) if the user enters his name then he can continue
2) if he does not enter his name (that he does not enter anything) then we ask him again to enter his name in order to continue.

I am working on a JavaScript program I am a beginner.