teleren/devto huggingface dataset:
Python Zero to Hero - Ep.10 - More Pytest and Mock
Tags: python, beginners, tutorial, testing
Published: 2020-06-09 00:10:47

---
title: Python Zero to Hero - Ep.10 - More Pytest and Mock
published: true
description: Today we go deeper into pytest, try using fixture, mark xfail, skip and parametrize. We also look into how to monkey patch an object with mock.patch decorators.
tags: python, beginner, tutorial, testing
---
Today we go deeper into pytest, try using fixture, mark xfail, skip and parametrize. We also look into how to monkey patch an object with mock.patch decorators. If you have any questions or any suggestions about which Python topics to cover, please leave your comment at my [Twitch channel](https://www.twitch.tv/cheukting_ho)

You can get the slide deck [here](https://slides.com/cheukting_ho/python-decorators/) and the example code and homework form [GitHub here](https://github.com/Cheukting/python02hero). Ask questions at my [Twitch channel](https://www.twitch.tv/cheukting_ho)
Close All Buffers Except the Current in Vim
Tags: vim
Published: 2020-10-19 13:15:32

---
title: Close All Buffers Except the Current in Vim
published: true
date: 2020-06-09 00:00:00 UTC
tags: vim
canonical_url: https://tech.serhatteker.com/post/2020-06/close-all-buffers-but-current-in-vim/
---

__Vim__ has default `:tabonly` for `tabs` and `:only` for windows to close them all except curren one, but there is no `:bufferonly` command.

You can use [BufOnly] _plugin_; just put it to your `.vim/plugin` then execute `:BufOnly`.

However this can be achieved with a script:

```vim
" close all buffers except current one
command! BufCurOnly execute '%bdelete|edit#|bdelete#'
```

The `%bdelete` command deletes all buffers.

The `#` means the alternate filename. From `:h _#`:

```
# Is replaced with the alternate file name.	  *:_#* *c_#*
  This is remembered for every window.
```

Put this script in you `.vimrc/$MYVIMRC`, and then execute `:BufCurOnly`.

You can map this `command` to any keys as always:

```vim
" Close all buffers but current
nnoremap <C-B>c :BufCurOnly<CR>
```

All done!

[BufOnly]: https://github.com/vim-scripts/BufOnly.vim/blob/master/plugin/BufOnly.vim
How to add event listeners to HTML elements using JavaScript?
Tags: javascript
Published: 2020-06-09 00:00:00

---
  title: How to add event listeners to HTML elements using JavaScript?
  published: true
  tags: JavaScript
  date: Tue Jun 09 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/event-listeners-in-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-a08726a3133e8acfc877af8652e859db.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/event-listeners-in-javascript)
  
Event listeners listen for specific events happening on HTML DOM elements.

---

Consider a login button like this.

```html
<button id="loginButton">Login</button>
```

We need to trigger some action when user clicks on this button.

To achieve that we need to add a `click` event listener to it.

First, let's get a reference to the login button in javascript using the `getElementById()` function.

```javascript
// Get a reference to the login button using the id attribute.
const loginButton = document.getElementById("loginButton");
```

Now let's attach the `click` event listener to the login button using the `addEventListener()` function.

```javascript
// Get a reference to the login button using the id attribute.
const loginButton = document.getElementById("loginButton");

// Adding the click event listener.
loginButton.addEventListener("click", function () {
  // You can add you own logic here
  // Eg: We can send our user details to server
  alert("Logging in..");
  sendUserDetailsToServer();
});
```

The `addEventListener()` function takes 2 arguments:

- the event name as the first argument
- function to invoke as the second argument

In our case `click` is the event name (first argument) and a function that sends user details to the server as the second argument, this function will be triggered when the user clicks on the button.

There are many types of event you can add to HTML DOM elements such as:

- `click`
- `keydown`
- `keypress`
- `load`
- `focus`
- `blur`

[and many more.](https://www.w3schools.com/jsref/dom_obj_event.asp)

### Feel free to share if you found this useful 😃.

---
Read and Write in a local file with Deno
Tags: deno
Published: 2020-09-10 05:47:10

---
title: Read and Write in a local file with Deno
published: true
date: 2020-06-09 00:00:00 UTC
tags: Deno
canonical_url: https://www.loginradius.com/engineering/blog/read-and-write-in-a-local-file-with-deno/
---

In this blog, we will see how we can read and write into a local file with the help of Deno First, we will create a program which will read multiple quotes from a text file and then print a random quote on our screen Then we will take input from the user in the command line and…

   
[Read On](https://www.loginradius.com/engineering/blog/read-and-write-in-a-local-file-with-deno/)
Keeping yourself motivated
Published: 2020-06-08 23:46:21

Keeping myself motivated is one of the most difficult things, when I look at my surrounding and my friends how they’ve done well for themselves, and I’m here still struggling to find my first permanent job...I really don’t know what keeps me motivated, to learn, and to keep looking for the job I want.In a country with such a high unemployment rate, I love coding and analyzing, I like seeing a problem and thinking of ways to solve it. Even though I don’t always find the solution I want,But I don’t give up.
Every time I write a code and encounter a problem that I don’t know how to solve I go on google, w3schools stack overflow, geeks and sometimes I don’t know how to implement what I found on my projects because I’m still learning somethings, Then I loose interest...and those negative words comes to mind “programming is not for women” “maybe you should just do something else” ...when I apply for jobs and don’t even get a response...thinking maybe I’m not good enough... I should find something else. 

But subconsciously even my mind and heart knows how bad I want this, even though I see only reason for me to give up on this journey, somehow I still find a myself opening my machine and trying again.
Code and code, learn and keep learning, code more and code more. I can see the growth in my code, I clap for myself. When my code can do what I want it to do I smile and say “you did it gal, now on to the next one”. 
Maybe hope is what’s keeping me motivated. And hearing all the stories of all of you self taught developers! Knowing I'm part of something big and great! And I always tell myself there will always be someone who knows more than you..learn from them! 
Keep learning and keep coding till you get what you want!
Deploy a Flask REST API - The Docker way and the Serverless way
Tags: docker, python, aws, serverless
Published: 2020-06-08 23:45:47

Python has become a very famous programming language in recent times. Part of the reason for its popularity is that Python also has a Web framework which enables us to develop WEB API's and Web Apps. Flask is a very lightweight web framework and very easy to deploy via multiple ways.  

One of the useful functionality which can be implemented using Flask is build and host a REST API. Using Flask and a backend database, an API interface can be easily materialized and the data from the database can be accessed over the API endpoints. The API endpoints can be invoked by a client web application to operate on the data from the database. It provides a secure interface for the client web app to access backend data. Using API endpoints for different services is also a very useful design pattern for applications which use microservice architecture.  

In this post I will be going through process to deploy a simple REST API implemented in Flask. There are various ways by which we can deploy and make the API available over the web. Here I will be discussing two ways yo deploy a Flask API:  
  - Deploy using Docker: Deploy the API as a Docker container.  
  - Deploy using Lambda: Deploy in a Serverless way on AWS. Using Lambda and API Gateway.

Find the whole post here: https://amlanscloud.com/deployflask/
Day 149 : Rush
Tags: hiphop, code, coding, lifelongdev
Published: 2020-06-08 23:31:26

_liner notes_:
- Saturday : Had the radio show. Didn't get as much as I wanted to get done during the week, so I had to rush a little to get everything ready before starting the show. Had a really good time and had some new listeners. The recording is at https://kNOwBETTERHIPHOP.com

![Radio show episode image of a graph stating that 99% of killings by police from 2013-2019 have not resulted in officers being charged with a crime with the words June 6th 2020, Defund the Police](https://dev-to-uploads.s3.amazonaws.com/i/0p7ezhh8nwcgk31lv2qv.jpg)

- Sunday : Did some post work for the radio show like set up the email blasts and posted to the different social media accounts. Got in some light coding. Watched a bunch of YouTube coding videos and the second episode of "Quiz" on AMC/BBC. Pretty cool show so far.

- Professional : Today was pretty much answering questions and helping out some coworkers. I like doing both cause I get to help people and it really forces me to understand the material. I still need to finish up some prework for my workshop coming up so I can just focus on recording the videos tomorrow.

- Personal : Been using my side project's pomodoro function. Been working pretty well.

![Coast line of Fraser Island, Australia with some shrubs in the foreground and the beach and water with waves on a pretty sunny day](https://dev-to-uploads.s3.amazonaws.com/i/0oj1hvt0kftets7d64ut.png)

Probably just relax and put together the material needed to do my workshop this week. It's been raining ALOT and it's making me sleepy. haha.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube FIuGqmEFM-g %}
Hosting a Discord.py Bot with Repl.it
Tags: replit, python
Published: 2020-06-08 23:29:11

I know that hosting a discord bot with <a href="https://repl.it">Repl.it</a> isn't very conventional. I've gotten multiple remarks about hosting it there. But I didn't really have any alternative ways of hosting a bot there.

However, hosting a python discord bot with repl.it was quite hard. I had scraped the internet for quite some time before finding a solution.

I just had to make a keep alive script and use <a href="https://uptimerobot.com">Uptime Robot</a>.

The keep alive script is very simple and isn't very long. You just need to include flask in requirements.txt and use threads.
`keep_alive.py`
```py
from flask import Flask
from threading import Thread

app = Flask('')

@app.route('/')
def home():
    return "Bot is online"

def run():
  app.run(host='0.0.0.0',port=8080)

def keep_alive():  
    t = Thread(target=run)
    t.start()
```
Then on your main python file, import the `keep_alive()` function. Then, right before you run your bot, include `keep_alive()`.

This code, in summary, makes a website that just says "Bot is online"

However, repl.it doesn't keep this code on 24/7. You need to make a GET request to this site every so often for it to run constantly. This is where Uptime Robot comes in.

Go to <a href="https://uptimerobot.com">https://uptimerobot.com</a> and sign up with a free plan. Then create a monitor by clicking the button.

You should see a screen like this: 
![](https://i.ibb.co/Hgyrd4q/image.png)

For `monitor type`, put Http(s). Put whatever unique name you want in `Friendly Name`. For `URL (or IP)` you want to put the URL that the flask shows up on. Once you run the discord bot on repl, a box appears on the top-right of the interface with the URL.
![](https://dev-to-uploads.s3.amazonaws.com/i/h8g2vvbfw4a9ifkkgrcm.png)

That's it! It's done. Just click run on repl.it and you can close the tab. It works!

If you have any questions, let me know :D
92/100 100daysofcode Flutter
Tags: 100daysofcode
Published: 2020-06-08 23:09:25

day 92/100 of #100daysofcode #Flutter
Learning Flutter , courses Udemy from
@maxedapps

Today learn firebase storage,put file, and use image quality on image picker
https://github.com/triyono777/100-days-of-code/blob/master/log.md
Plots with Plotly
Tags: python
Published: 2020-06-08 22:43:47

Python programmers often use matplotlib to create plots, you can make all kinds of charts with it like <a href="https://pythonbasics.org/matplotlib-bar-chart/">bar charts</a> or <a href="https://pythonspot.com/matplotlib-line-chart/">line charts</a>. But this is not the only way to visualize your data. 

A popular alternative the plotly module. This service lets you create plots and put them online. You should <a href="https://pythonprogramminglanguage.com/">learn Python</a> before trying <a href="https://plotly.com">plotly</a>.

## Create a bar plot

Creating a bar plot is done with a few lines of code.
To get started install plotly and chart-studio

    pip install plotly==4.8.1 --user           
    pip install chart-studio==1.0.0 --user

A simple bar plot can be created like this:

    import plotly.graph_objects as go
    fig = go.Figure(data=go.Bar(y=[2, 3, 1]))
    fig.show()

So the data in this case is a list with integers, but the list can contains different <a href="https://python-commandments.org/python-data-types/">data types</a>.

That opens up a server on localhost showing the bar plot. You can also save them to a file or host them online.

![plotly plot](https://dev-to-uploads.s3.amazonaws.com/i/i43u1cjdyzkv4mk6973h.png)

To share them online, import chart_studio and set your api keys.

    import chart_studio
    chart_studio.tools.set_credentials_file(username='DemoAccount', api_key='lr1c37zw81')

That gives you this code:

    import plotly.graph_objects as go
    import chart_studio
    import chart_studio.plotly as py

    chart_studio.tools.set_credentials_file(username='DemoAccount', api_key='lr1c37zw81')

    data = [go.Bar(y=[1,2,3,4,5,6])]
    py.plot(data, filename='bar-plot')

After setting up, you will get a <a href="https://chart-studio.plotly.com/~toebest/4/#/">bar chart like this</a>.

## Line chart

If you want a line chart, you can change it. It's very important to change the filename, or it will overwrite your previous chart.

    g1 = go.Scatter(x=[1, 2, 3, 4], y=[2, 4, 6, 8])
    g2 = go.Scatter(x=[1, 2, 3, 4], y=[5, 10, 15, 20])

    data = [g1,g2]
    py.plot(data, filename='line-plot')


That results in this <a href="https://chart-studio.plotly.com/~toebest/6/#/">line chart demo</a>

![plotly line chart](https://dev-to-uploads.s3.amazonaws.com/i/6m5e9tehtroyma6h04o8.png)
The impostor inside
Tags: womenintech, career
Published: 2020-06-08 22:31:54

There is no news here: most women suffer from impostor syndrome. If you have never heard of the term before, it refers to that weird gutsy feeling you get once you get a job, a promotion, or stands out in any way. You can recognize it in that little voice that tells you you are not enough and that sooner or later someone will discover you are a fraud. It is a crippling feeling that makes a lot of things in our career harder than they should be. 

I believe that impostor syndrome plays a big role in the gender gap that undoubtedly exists in tech nowadays. As a woman and a programmer, I have identified on myself and my colleagues how this feeling damages our mental health and career progression. It makes us afraid of trying and unsure of our potential. Because programming is an art of practice much more than a skill you can acquire just by reading about it, insecurity and the fear of being discovered as a fraud hinders many women from daring and taking risks, which ultimately affects women's presence on the tech market. 

I understand that feeling insecure is not a women's prerogative, there are many men out there that can relate to that. However,  the impostor syndrome thing goes deeper than insecurity and it plays a structural role in gender inequality in the market place, especially in the programming sector because of its particular characteristics.

As I said in the beginning, this is no news. Actually, it is a very old discussion, so why write about it again? Because I believe that only when we address this dark brain pattern, call it by its name and recognize who it is affecting the most, then we can start making real change in tech. As someone that is in the job market and lives it on a daily basis, I know that the change we need isn't here yet. And, I believe that it is women's prerogative to talk about their own experience in the area, so we can push for change. 

Besides boosting the discussion around it, I believe that we also need to unite. I have been quite the nomad for the last few years and I lived in different countries. However, one thing that has grounded me during all these changes is finding women in tech groups. It is a powerful and revolutionary thing when we help one another. By talking and recognizing the common struggles we can be each other's counterpart to impostor syndrome. When we help another woman overcome its fear of failure, her success becomes a flash of hope that someday reality can be different for ourselves and others like us.
Kure small video chat service
Tags: kurento, videochat
Published: 2020-06-08 22:25:04

**About Kure application**

Application based on kurento project & openvidu project
You can find origin source code and licence on: Licence page Kurento project page Openvidu project Openvidu tutorials project

Main reason for KMS:
- WEBRTC VIDEOCONFERENCES
One-to-One, One-to-Many, Many-to-Many. Any combination you can think of is possible with OpenVidu.
- OPEN SOURCE
OpenVidu is an OpenSource project licensed under Apache License v2. Use it for free.
- MULTIPLATFORM
Chrome, Firefox, Safari, Opera, Edge, Android, iOS, desktop apps. All compatible with each other
I recommended everyone to use docker.
This project is commercial and i use it to run my own services.
Middleware server base on node.js.

Improvements:

- Protocol http2 for node middleware server.

- Implementation of session websocket based account system.

(used from visual-ts game engine project)

Kure Video Chat is commercial project but you can find code for `session account system` from:

 https://github.com/zlatnaspirala/visual-ts-game-engine/blob/master/server/rtc/connector.js

https://github.com/zlatnaspirala/visual-ts-game-engine/blob/master/server/common/shared.js

KMS vs openvidu docker variant with nodejs middleware.
Public web server for Kure service:

https://maximumroulette.com:2020

Websocket port: 3232
Estude menos, estude inteligente.
Published: 2020-06-08 22:20:11

Olá, nesse artigo gostaria de compartilhar um resumo super interessante sobre o vídeo "Study Less Study Smart" do professor Martin Lodbell que fala sobre estudar de forma mais efetiva.

[Marty Lobdell - Study Less Study Smart](https://www.youtube.com/watch?v=IlU-zDU6aQ0&list=WL&index=4&t=193s)

Martin explica que estudar por muitas horas consecutivas pode diminuir a nossa capacidade de assimilação, então uma melhor forma de estudar seria estudar em torno de 30 minutos e tirar 5 minutos de descanso para fazer algo divertido como escutar uma música, conversar com amigos ou  conversar com parentes.

Uma universidade do Hawai fez uma pesquisa com estudantes onde perguntou aos alunos qual é o maior dificuldade em estudar e a maioria respondeu que a maior dificuldade era começar a estudar então Martin Lodbell aconselha aos alunos terem um lugar onde o objetivo primário seja estudar.

Se você não gostou da forma que estudou troque o jeito de estudar, o processo de estudar varia de pessoa para pessoa, mas conforme vamos nos exercitando esse processo fica mais fácil a cada dia.

Dormir é essencial para quem precisa estudar, porque nosso cérebro precisa consolidar as coisas que aprendemos durante o dia.

Para fixar o aprendizado precisamos entender o conceito porque ele é o que liga o conteúdo novo que estamos aprendendo com as informações que já possuímos. 

Dê sentido as coisas e você só vai conseguir fazer isso quando explicar isso pode explicar para um amigo, parente, companheiro, filho ou para uma cadeira, a ideia é se ouvir para entender o conceito das coisas. Existe uma historia do livro programador pragmático que o desenvolvedor explica seu problema para um pato de borracha, assim conseguem ter clareza do que estão estudando.
Practical JS Interview Questions
Published: 2020-06-08 20:34:03

Let's face it, algorithms are a useless test of a candidate's experience as a frontend developer. Someone who can construct a binary tree from preorder and inorder traversal doesn't mean they can create an amazing UI with an awesome user experience. It means they got lucky you asked them a question they've seen before.

What I like to give are mini-projects the candidate can solve in a 30–45 minute timeframe. They can use any framework they like such as React, Angular, or even vanilla JavaScript! Since my firm focuses more on functionality than UI, I tend not to not be so picky about CSS. But adjust as needed.


## 1. Create a stopwatch
Ask them to create a simple stopwatch. It should have buttons to start, pause, and stop the timer. I created a simple example.
Gotchas:
Click the 'Start' button multiple times and see if multiple intervals are created. Most candidates make this mistake.
Ensure 'Pause' button is hidden when the stopwatch hasn't started.

Bonus questions:
style the stopwatch
show milliseconds, minutes and hours

## 2. Create a todo list
Enough said, so many tutorials out there about this. Tweak the problem however you like.
Bonus questions:
add pagination
make a todo editable

## 3. Create a simple upvote tool
This is a simple polling tool, similar to Slido, that let's users ask questions and upvote the questions so the most popular ones are shown on top. See example.
Gotchas:
Questions should be sorted by upvotes
When a question is upvoted past another question, the one with the highest upvotes should move to the top
Handle duplicate questions

Bonus questions:
Make questions editable
Add delete button next to each question
Style the app

If the user finishes ahead of time, I will usually ask them some JavaScript related questions. You can find a good list of them here.
Hope this helped!
Viewing history of cell changes using SQL
Tags: sql, git, database
Published: 2020-06-08 22:05:47

[Dolt](https://github.com/liquidata-inc/dolt) and [DoltHub](https://dolthub.com) are Git and GitHub for data. Having a versioned database makes collaborating on data more fluid and reliable in the same way that Git improves source code collaboration for software engineers.

I wrote a blog discussing DoltHub’s newest feature, cell history inspection. You can inspect the changes between versions of every cell in every table with just a click, making debugging between versions easy to trace.

Check it out here: https://www.dolthub.com/blog/2020-06-05-introducing-cell-history/
The Story And Creation of HTML DB
Published: 2020-06-08 21:56:30

So, this is an extremely awesome little article i decided to make, not only to celebrate html-db being 1 year old since its creation.... but, to celebrate its rewrite!


so, the story starts off here... I had just learned to code, and I was curious as heck ( as any teenager is/was ), so i decided.... **why not try to make my own database package for nodejs!** and out came the idea of html-db, a very crappy, bulky, and broken package, that stayed that way for over 10 months since 0.0.2... during that time, html-db had many issues I was not willing to fix, so, html-db was shut down. not having any updates for 4 whole months, I decided it was time for a full rewrite, this time, a version that actually works, version 3.0.2, a fully functioning, database comprised of map classes, and "Tables". the true idea of html-db was to be usable on the client side of web pages, and now that the dream is achieved, html db can finally enter the stage as a high scale database package.