teleren/devto huggingface dataset:
Run blocking processes in async IO server
Tags: python
Published: 2021-03-04 20:02:54

In Python, although we can run some CPU-blocking tasks in a separate process, there could be question on how to integrate with other async IO tasks.

# Problem

As I am working with my company about AI products, we usually wrap our microservices using async IO web framework (e.g. Sanic), to control the execution of AI model training / inferencing.

- The IO-related tasks (e.g. database writes) are already implemented as async functions.
- AI model training / inferencing tasks are usually thread blocking. Calling them as normal function and execute them in event loop could be disastrous: other tasks in event loops (i.e. other incoming requests) would be blocked.
- Putting these AI related tasks to run in separate processes is a way out, but these tasks still need some kind of interaction with the async IO server, e.g. db updates about current task's progress.

# Solution

- While we execute a thread-blocking task, we run it in a separate process (using `multiprocessing` module), and use a pair of request/response queues (`multiprocessing.Queue`) for communications.
- We want the task to be "wrapped" within an async function, so that the user of the function can just call it, and expect it to be non-blocking.

![Solution](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7l0ymloe6xmsrqha4egr.png) 

- The async function wrapper can invoke `asyncio.sleep()` when waiting for message from response queue, to allow the event loop to take care of other async IO tasks (i.e. non-blocking).
- When the process task needs to invoke some asyncio function, it can send the message through the queue for that.

# Coding Example

(In the coding example, the names of the queues become `send_queue` and `receive_queue`, relative to the usage of the each function itself.)

[Coding Example](https://gist.github.com/kuimono/dde9aa0844b96a38b10d030f0ae82450)
What are the Best Teaching Platforms as an Instructor?
Tags: productivity, discuss, watercooler, beginners
Published: 2021-03-04 19:56:54

---
title: What are the Best Teaching Platforms as an Instructor?
published: true
description: Tell me about your online course journey.
tags: #productivity, #discuss, #watercooler, #beginners
//cover_image: https://www.todayifoundout.com/wp-content/uploads/2015/05/chalk.jpg
---
Greetings All,

I know quite a few of you have your own **courses** *and* 
**educational platforms** whether you have designed them all by yourselves or not. 
- What do you use and why? 
- What do you like about these platforms? AND, What do not like... 
- What is important to your courses/work? 

Some have claimed that if they were starting over they would "*get you up and running more quickly*" with:

- [LearnWorlds](https://www.learnworlds.com/)
- [Thinkific](https://www.thinkific.com/)
- [Leanpub](https://leanpub.com/bookstore?type=course)
- [ClickFunnels](https://www.clickfunnels.com/)
- [Teachable](https://teachable.com/)
- [Kajabi](https://kajabi.com/)
- [Podia](https://www.podia.com/)
- ad nauseam

Tell me about your online-course-instructor journey.
I'm Annika and I'm glad that nevertheless, they all coded.
Tags: wecoded
Published: 2021-03-04 19:44:15

It all started one year ago, when I joined the Talent Acquisition team at SinnerSchrader. I was fresh out of university and I always tried and did a lot of things and kept saying that I was open for everything. That's why I agreed to start a job that would mainly be about attracting devs and also working together with them every day. 

In the beginning, I thought I'd have to start learning everything about developing in order to be able to connect to the community and to be honest I was (and still am sometimes) scared that everyone would see me as another annoying recruiter who wants to hire resources and talks a lot. 

Then, I met [Feli](https://dev.to/kotzendekrabbe). She was the one who showed me a whole new world and one sentence I'll never forget is "Developers are people". Of course you are people! Admirable people with a lot of power and influence if you ask me. And even though I'm aware that the world in general, but the tech world in particular, is still not as inclusive as we want it to be, I learned so much about accepting, supporting and empowering each other from the tech community. 

I know it's kind of cheesy but **I am glad that despite all the challenges you have to face on a daily basis, you all coded and still do**. I'm really not glad that I had to learn about all the injustice and discrimination you had and have to go through, but I'm so glad that you never give up and inspire people and show how amazing you are. 

I can relate to your problems and I face similar challenges as a woman in my life, but the field I work in is not male-dominated. That's why I want to be there as an ally for all underrepresented groups in the tech community (and in general of course).

Thank you to all the women devs I get to work with. Thank you for welcoming me in your world, helping me and others grow. I hope (and the optimist in me is sure) that one day the hard work pays off and in the meantime, I'll be by your side and fight the battle with you.
Put your Macbook to sleep with this command
Tags: beginners, bash, tutorial, productivity
Published: 2021-03-04 19:33:58

Do you hate to use the Macbook’s touchbar like me? And do you spend most of the time in your terminal? 

Use the command below to put your Macbook to sleep:

```bash
pmset displaysleepnow
```

Follow me on twitter for more [@hossein761](https://twitter.com/hossein761)
Encode::Simple - Encode and decode text, simply
Tags: perl
Published: 2021-03-04 19:16:44

Encode is a well known core module in Perl with support for encoding and decoding text from almost any character encoding you can think of. But it's also an old module with a large amount of historical cruft.

With inspiration from #perl on freenode IRC, [Encode::Simple](https://metacpan.org/pod/Encode::Simple) is an attempt to at least improve on its interface and usability issues. Rather than an awkward and unintuitive bitmask and the option of clobbering the input data, Encode::Simple exports straightforward encode and decode functions that simply return the encoded or decoded result or throw an exception. For the cases where you want to allow invalid characters or byte sequences, encode_lax and decode_lax are provided.

Encode itself supports many more operations such as partial, mixed, and in-place encoding or decoding, where its options may make more sense, but these uncommon use cases are not supported by Encode::Simple.

As a final note, if you are working strictly with UTF-8, I suggest avoiding Encode entirely and using the excellent [Unicode::UTF8](https://metacpan.org/pod/Unicode::UTF8), or the related filehandle layer [:utf8_strict](https://metacpan.org/pod/PerlIO::utf8_strict), for fast and correct encoding and decoding.

*Since the original publication of this post, Encode::Simple has added `encode_utf8` and `decode_utf8` functions that directly use `Unicode::UTF8` if installed.*
Coding Grace's March Newsletter is out
Tags: diversity, newsletter, diversityintech, irishtechcommunity
Published: 2021-03-04 19:13:05

It's March, and it's International Women's Day where the month is jam-packed of events, initiatives. Even here on DEV, if you haven't seen it already, you can submit your experience to their annual [#SheCoded](https://dev.to/shecoded). [I submitted mine](https://dev.to/whykay/nevertheless-whykay-she-her-coded-in-2021-fap) so it's your turn if you haven't, plus this year's IWD theme is [#ChooseToChallenge](https://www.internationalwomensday.com/Theme). 

The newsletter this month is slightly changed, I am focussing more on Diversity in Tech events and other announcements. The general tech listings will now be linked to https://irish-diversity-in-tech.netlify.app/events/ (as the curated listings will be up-to-date)

Of course, we welcome general Irish tech announcements, opportunities, etc., and I will still have a section to do a shoutout in the newsletter.

📰 Here's the newsletter: https://mailchi.mp/3cb35a73a875/cg21-mar-iwd

# Some announcements of interest since the newsletter was published
If you have anything else to contribute, add them in the comments below, thanks in advance.

## 📢 Dogpatch Labs Launch of NDRC Accelerator
It is now open for applications.

###### DEADLINE: May 2nd, 2021 @ 23:59 GMT
Details: https://www.ndrc.ie/accelerator

## 📢 Smart Dublin Competition: Dublin Region Open Data Active Travel Challenge 2021
> The Dublin Region Open Data Active Travel Challenge seeks innovative ideas and applications that use open data to encourage and support active travel.

* First Prize is €1,200
* Second Prize is €600 
* Third Prize is €300

###### DEADLINE: March 30th, 2021 @ 12 Noon (Irish Time)
Details: https://smartdublin.ie/the-dublin-region-open-data-active-travel-challenge-2021/

---
I also want to shout out again about the DCU's Hack4Change call for judges, mentors, volunteers.

{% link https://dev.to/whykay/dcuhack4change-2021-call-to-action-20o %}

---

# Reminder
Again, if you have anything to share with us for our upcoming newsletter, collab on something, or even if you want to share a post with us, drop us a note down the comments below, or email us at contact@codinggrace.com.

![](https://media.giphy.com/media/dNgK7Ws7y176U/giphy.gif)
Tips for Learning to Code!
Tags: programming
Published: 2021-03-04 19:00:04

In my time coding, I've found a few things that others might find helpful. These are purely just things that I found that helped me, and they may not help you like they helped me. With no further adieu, here they are

**1) If you know it, go and learn it again**
I found that it is helpful to go back to the basics, learn what you already know. For me, it helped me understand how that specific thing works. This also works with advanced topics.

**2) If you watched the tutorial,watch it again, and again**
This one is similar to number 1, but it can also be dangerous. I found that if I watched a tutorial, and then a little while later after watching it again, and again, after a while, I was able to understand what the tutorial was trying to tell me.

**3) Practice**
I know its been said time and time again, but practicing and making things without a tutorial or walk-through or anything else like that is one of the best things you can do to improve your skills.

**4) Make something you'll enjoy**
While its great to make things that are super helpful for your job, or school, or just in your daily life, that's not all there is to do. If you like doing things that will help you or others, great, keep doing that. But if you don't enjoy making things like that, then try to make something else, something you'll like. It will help keep you interested in coding, and you will still get all the benefits of practicing.

**5) Take breaks**
Coding is fun. I think most people enjoy coding and everything that comes with it. But, sometimes it's good to just stop, and not worry about that bug that's been on line 237 for the past hour.

I hope these helped you, and I hope you're having a good day. If you have any other piece of advice I missed, comment it in, I'm 100% sure that it will be just as, if not more helpful than what I have written here.
Looking to deploy your Django App?
Tags: django, aws, tutorial
Published: 2021-03-04 18:53:01

AWS Elastic Beanstalk Console makes deployment simple. 

1) Create an AWS account.
2) Create a *requirements.txt* file in the project directory.
```
pip freeze > requirements.txt
```
3) Create a *.ebextensions* folder in the project directory.
```
mkdir .ebextensions
```
4) Create a *django.config* file in the *.ebextensions* folder.
```
option_settings:
  aws:elasticbeanstalk:container:python:
    WSGIPath: mysite.wsgi:application
```
5) Zip all the files in your Django project directory.
6) Upload the zipped folder to AWS EB console.
7) Wait for AWS EB to launch your project.
8) Click the custom EB URL to see your deployed project!

[Deploying Django from AWS Elastic Beanstalk Console](https://https://www.ordinarycoders.com/blog/article/deploying-from-aws-eb-console)
Punctuation in programming languages
Tags: javascript, programming, debugging, sleeplessness
Published: 2021-03-04 18:51:45

Yesterday a ten day long agony came to an end, three days of which were due to a right brace in the wrong place. I had spent hours trying to figure out what was wrong with program *statements* only to discover that it was the *punctuation* that was wrong.

Is this why some languages have keywords like `OD` and `FI`? Do languages like Python avoid this situation through indentation or does Python swap this for something else? 

Boss is happy. Clients are happy. I'm not so happy.
4 types of engineers
Tags: programming, devops
Published: 2021-03-04 18:27:15

There are 4 types of engineers: Starters, Maintainers, Optimizers, and Operators. I've found this to be a super helpful model for understanding different my work life. **Which is your dominant trait**?

**The Starter** loves to start new projects. They can rapidly build an MVP. They are great with ambiguity and design. They are customer obsessed.

**The Maintainer** is reliable, loves structure, and is a work horse. Every day they are carving the stones that build the multi-generational cathedral that will last for centuries.

**The Optimizer** loves puzzles, algorithms, and are often competitive. They know how to load test the software, profile the code, and get satisfaction out of shipping highly performant code.

**The Operator** loves to learn the ins and outs of an existing system. They know how to deploy it. They love operational readiness. They are experts on the infrastructure. They gleefully find bugs and know everything about the software.

If you put a Maintainer on a greenfield project to build a prototype, they will be miserable. The Starter thrives on a blank canvas and evaluating cutting edge technologies. The maintainer will be frustrated with the lack of focus and craves incremental progress as a SME.

**What do you think of this idea?**
Empty States - Building SaaS #83
Tags: python, django, templates
Published: 2021-03-04 18:13:58

{% youtube _k3ayh6J_hc %}

In this episode, I returned to the onboarding flow and start to polish some of the extra pages. We filled the pages with special copy and a call to action to each page to help customers be successful.

I started with the pages that displays the school years. We added a chunk of template from the onboarding process that asks the user to create a school year. I modified the template chunk to make it fit in the context of the page.

Next, I moved onto the index page that lists all the students in a user's account. I took another chunk from my main app view, refactored it into a partial template and then used it in two places. I did some testing to make sure that the old view continued to work.

After completing that empty state, I tackled another logical state when the user wants to view their weekly schedule, but they have no enrolled students. This is another state that can't show the full schedule, so I added more help and another call to action to help users along in the process.

To finish off the stream, I tried to add pytest-xdist to make the test suite run in parallel and run faster. I found that the extra process overhead negated the speed boost for my small test suite.
How to create project with Visual Studio 2019 – New Project Dialog
Tags: visualstudio, visualstudiocode, vscode, webdev
Published: 2021-03-04 18:05:03

---
title: How to create project with Visual Studio 2019 – New Project Dialog
published: true
description: How to create project with Visual Studio 2019 – New Project Dialog
tags: visualstudio, visualstudiocode, vscode, webdev
---

With Visual Studio 2019, A new project dialog has been introduced and there are lots of improvement done from the new project dialog. In this video, I have explained all the features of New project dialog for visual studio 2019 


Following is video for the same.

{% youtube PCeJhfvgQ_A%}

If you like this video and wanted to see a similar kind of video then, please subscribe to my you tube channel at - https://bit.ly/codewithjv.

Also, Please comment about what content you want to see in my you tube channel.
Are you sure how to upload files and manage it into the cloud?
Tags: joke
Published: 2021-03-04 18:03:44

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ufaztmmgaovq1b3onmrl.jpg)

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jtxab4kg5d7r6bvdsrwy.jpeg)
Fix CORS Error (JavaScript)
Tags: javascript, cors, fetch
Published: 2021-03-04 18:01:42

#What is CORS?
![cors](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kz3x3zf6oa75ow4gyyr8.png)
 

Cross-Origin Resource Sharing (CORS) is an HTTP-header based mechanism that allows a server to indicate any other origins (domain, scheme, or port) than its own from which a browser should permit loading of resources - [MDN](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)

This definition might seem confusing so let me try to explain it in simpler terms.
> **CORS** is a browser policy that allows you to make requests from one website to another which by default is not allowed by another browser policy called Same Origin Policy.

This is an error that is mostly addressed from the backend of an API.
The problem here is when you are trying to call a public API without the CORS error being fixed and you can't reach the developers that developed the API.

In this tutorial, I'll be showing you how to by-pass CORS errors using Vanilla Javascript when you are in such a situation.

The API we are going to be using is a `Quote Generator` API.

`http://api.forismatic.com/api/1.0/`

In other to get list of Quotes, we need to append this to the base URL

`?method=getQuote&lang=en&format=json`.

So the full URL becomes;

#####`http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json`

In other to make the API call, we need to create a Javascript file and call the endpoint.We would be using the `fetch` API.

This would look like this;

```javascript
// Get quote from API
async function getQuote() {
  const apiUrl = 'http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json';
  try {
     const response = await fetch(apiUrl);
     const data = await response.json();
     console.log({data});
  } catch (error) {
     console.log(error);
      }
  }
// On load
getQuote();
```


If you run this code in your browser and open up your console, you should see the error below;


![Screen Shot 2021-03-04 at 6.39.46 PM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m4y2oq9tqyhwedkmpequ.png)
 


In other to fix this error, add the following lines of code;

```javascript
// Get quote from API
async function getQuote() {
  const proxyUrl = 'https://cors-anywhere.herokuapp.com/' -> this line;
  const apiUrl = 'http://api.forismatic.com/api/1.0/?method=getQuote&lang=en&format=json';
try {
    
     const response = await fetch(proxyUrl + apiUrl) -> this line;
     const data = await response.json();
     console.log({data});
  } catch (error) {
     console.log(error);
      }
  }
// On load
getQuote();
```

This URL `https://cors-anywhere.herokuapp.com/` is also a public API that was created by someone to fix the CORS error.

**N.B**: You might still get some errors on your console even after following the steps I just showed.If this happens, go to this URL 

       `https://cors-anywhere.herokuapp.com/corsdemo`

and follow the instructions there.

Thanks for taking your time to read this Article. Your feedback and comment is highly welcomed.
Tip for React Developers 
Tags: react, redux, reactnative, javascript
Published: 2021-03-04 17:56:52

# Be more professional as a React developer

I am sharing with y'all my experience, always separate your Business logic from your UI implementation, don't mix them, this will make your application look decent and scalability easy as well as in future whenever you want to update your UI design you don't have to mess with your Business logic.

To achieve this , use custom hooks which will be responsible for managing your business logic and return the data or function  your UI need from this hook.
Want to earn more in dev? Learn Data Pipelines.
Tags: rudderstack, data, career
Published: 2021-03-04 17:49:10

---
title: Want to earn more in dev? Learn Data Pipelines.
published: true
description: 
tags: Rudderstack, data, career
cover_image: https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hmm33lldieli3xg3avqo.jpg
---

*cover photo by [CEphoto](https://commons.wikimedia.org/w/index.php?curid=39341369)*

Several concepts are key parts of the developer experience. In general we learn that that real world developers do not build abstract 'programs' or conceptual 'networks' but rather real services with with actual connections between layers. In coding boot camps and practical academic programs we often build with concepts like CI/CD, test-driven-development and (practically always) change management. 

I'd like to suggest that to this list of key concepts we should add [data pipelines](https://rudderstack.com/blog/rudderstack-cloud-extract-makes-cloud-to-warehouse-pipelines-easy). A quick definition:

---

Data pipelines are the arteries of any modern data infrastructure. Their purpose is pretty simple: they are implemented and deployed to copy or move data from “System A” to “System B.”

To be a bit more formal (and abstract enough to justify our titles as engineers), a data pipeline is  a process responsible for replicating the state from “System A” to “System B.”

---

Am I biased because [these pipelines are what rudderstack is built to help with?](https://rudderstack.com/)? Okay, very possibly! But the fact is that the question of 'how does this event/record/information get from our data warehouse over here to our sales/marketing/analytics system' is one that I've dealt with at every single dev role, contract job, startup, and enterprise team I've worked.

You can see questions of data pipelines in so many job listings: those request for a SQL pro who understands regex and the Stripe API are actually requesting someone who understands data pipelines.

If you want to read more about pipelines in general, [check out this post by Kostas on the subject.](https://thenewstack.io/part-1-the-evolution-of-data-pipeline-architecture/)
JavaScript function which confirms the ending of a word
Tags: javascript, algorithms
Published: 2021-03-04 17:47:00

Here is the problem :

We want to create a function that takes two arguments, both strings, and tell us if the second argument is the end of the string or not.

For example, the first argument could be 'Cesare' and the second 'e' the function should give us back the boolean true.

Here the function

`function confirmEnding(str, target) {`
  
with the use of:

- boolean; 
- the method slice(); 
- the string.length property,

The function is created:

  `return str.slice(str.length - target.length) === target  ;
}`

explanation:

The method slice will take as argument one integer that gives the string index of the str. This integer is given by the difference of first - second argument length. 

If then the given output of str.slice() is === to target we have true or false as result. 

And is what we wanted.  

```
function confirmEnding(str, target) {
  
  return str.slice(str.length - target.length) === target  ;
}

confirmEnding("Cesare", "e");
```