teleren/devto huggingface dataset:
Python tips: elegant exception handling with contextlib.suppress
Tags: python, pythontips, contextlib
Published: 2020-12-02 07:09:31

Python has a very elegant and concise way of handling exceptions, to my taste. What's more exciting is that it also has other techniques to make your code even more readable. Today, I'm going to share a small tip on using a context manager for handling 'lazy exceptions.'

Imagine that you need to handle a couple of possible errors and tell your program to ignore them. You can do it ‘the long way’ using the good old `try` `except` syntax:
```python
try:
    do_a()
    try:
        do_b()
    except ExceptionB:
        pass
except ExceptionA:
    pass
```
Looks rather incomprehensible and ugly, not to mention the case when you've got several such exceptions to handle. Following the Python [principles](https://www.python.org/dev/peps/pep-0020/) *'Flat is better than nested'* nad *'Simple is better than complex'*, we can break it down:
```python
try:
    do_a()
except ExceptionA:
    pass

try:
    do_b()
except ExceptionB:
    pass
```
A bit easier to read, but still, quite long for a simple 'try to do `a()` and `b()`, and if you fail, just keep going'. Here's where the `contextlib` module from the Python standard library comes to our rescue. `contextlib` provides utilities for common tasks involving the `with` statement, and, in our case, can help our code to achieve better clarity:
```python
from contextlib import suppress
with suppress(ExceptionA):
    do_a()
    with suppress(ExceptionB):
        do_b()
```
A bit abstract, though. [Python documentation](https://docs.python.org/3/library/contextlib.html#contextlib.suppress) gives us a more practical example. Say, we want to remove a file in case it still exists on our system. If we do it the usual way, we’ll type:
```python
try:
    os.remove('somefile.tmp')
except FileNotFoundError:
    pass
```
With suppressing, it’ll be like:
```python
from contextlib import suppress

with suppress(FileNotFoundError):  # if you get this exception
    os.remove('somefile.tmp')  # while trying to do this, go on
```
Two lines instead of four (well, not counting the import line). Not bad, especially if you have several such exceptions to handle.

There's a limitation to using this method, though. Use it only with specific exceptions to cover those errors where you know it's okay to keep going (pass). If you need to give specific instructions what to do if something goes wrong, than the traiditional `try` `except` will fit you better.

Hope you enjoyed my post! If you did, don't forget to like it. Thank you :)
Getting Started with GitHub CLI
Tags: github, git, tutorial, cloud
Published: 2020-12-02 06:57:07

*Original post on my [blog](https://onyxcode.net) as part of my #2Articles1Week.*

GitHub CLI is a wonderful new tool released by GitHub in an effort to bring GitHub to the terminal. In this tutorial, I will be showing you how to setup, install and use some basic features of GitHub CLI.

# Installation
Because of the amount of install methods, I've taken the liberty of creating a separate article dedicated to [installation methods](https://onyxcode.net/install-methods-gh-cli).

# Authentication
When you first try to run `gh`, it will ask you to authenticate with your GitHub account. 
```
gh auth login
```
Select if you are authenticating with a GitHub Enterprise Server, or GitHub.com. In this tutorial, I will be authenticating with GitHub.com.
```
? What account do you want to log into?  [Use arrows to move, type to filter]
> GitHub.com
  GitHub Enterprise Server
```
Next, select if you wish to authenticate with a web browser, or with an authentication token. To keep it simple, I'll authenticate with a web browser.
```
? How would you like to authenticate?  [Use arrows to move, type to filter]
> Login with a web browser
  Paste an authentication token
```
Make sure to copy your one-time code before pressing "Enter" to open the authentication window.
```
! First copy your one-time code: <your code will be here>
- Press Enter to open github.com in your browser...
```

![By57wWKumX.png](https://file.coffee/u/By57wWKumX.png)

After entering your activation code, you will be brought to the OAuth page.

![NYs6clge0f.png](https://file.coffee/u/NYs6clge0f.png)

After authorizing, and confirming your password, you will be brought to this page.

![4wWImySCyF.png](https://file.coffee/u/4wWImySCyF.png)

Congratulations! You are now authenticated! Returning to the terminal, you will be greeted with this message.

```
✓ Authentication complete. Press Enter to continue...
```

One last thing!

```
? Choose default git protocol  [Use arrows to move, type to filter]
> HTTPS
  SSH
```

I'd recommend using HTTPS, since it's the most widely used protocol, so I'll be choosing it.

```
✓ Configured git protocol
✓ Logged in as onyxcode
```

Congrats! You're done setting up GitHub CLI!


# Usage Examples
Full documentation at [cli.github.com/manual](https://cli.github.com/manual/).

- Create a public gist

```
gh gist create --public hello.py
```

- Clone a repository

```
gh repo clone onyxcode/hazy
```

- List issues for a repository

```
gh issue list -R Rapptz/discord.py
```

- Download latest release

```
gh release download -R microsoft/winget-cli
```


# In closing
I hope you found this article helpful! If you did, share and like!
Conversation in social network times
Tags: comics, socialnetwork, offtopic
Published: 2020-12-02 06:39:12

---
title: Conversation in social network times
published: true
description:  Conversation in social network times
tags: comics, socialnetwork, offtopic
//cover_image: https://direct_url_to_image.jpg
---

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/2vsxjb33nmmdfp3xt2nz.png)

Has it happened to you guys as well?

You can also see the post in the author's blog:  http://thiagocafe.com/view/20201118_conversation_social_network
Upwork vs Freelancer?
Tags: freelancing, discuss, beginners, career
Published: 2020-12-02 06:33:54

Hey guys,

I have created account on [Upwork](https://www.upwork.com) and [Freelancer](https://www.freelancer.in/) since last 1 month. I have created my profile as web developer. This is what I have observed in both of the sites!


* There are lots of jobs available but it lacks technical details as compare to Upwork. While in Upwork there are detailed jobs available.
* Bidding on freelancer is more easy then Upwork because freelancer provides 1 free point maybe every 3 days.
* In freelancer there are so many spams in jobs, while I didn't saw that in Upwork.
* There are lots of people in freelancer which means much competition and while in Upwork there are less people then freelancer (maybe because it doesn't provide free connects to bid).
* In Freelancer it is so frustrating to see low bids on really good projects. Due to this low bids you really don't want to lose your point by posting your bid there.
* Upwork is far more better then freelancer, yes it is costly as you have to buy connects to bid on project but you can have genuine projects.
* In Upwork it takes time to approve your application then freelancer.



>What do you guys think about this?

>Which one is better for beginners like me?

>What is your experience for both of this sites or Do you have any good alternative then this?

>I want some advice on freelancing since I'm beginner.


***Thanks For Reading!***
That first day back after a break
Published: 2020-12-02 06:19:17

The best part of coming back after a break like Thanksgiving is I am fresh and ready to take on the World.

The worst part, I totally forgot where I was at before the break and my ToDo list is looking longer than when I left it.

Plus, just how did so many apps get updated between last week and now, that's going to take a while to catch up LOL.
NPM libraries: which are the good ones?
Tags: javascript, help, discuss
Published: 2020-12-02 05:49:20

Getting to know a language's ecosystem is intimidating. 

I am switching from backend to frontend for a while, and I think I can master typescript on my own. But when I go to https://www.npmjs.com/ where it seems like one million libraries are available, I'm like : where do I even start? 😱

Dear readers, do you have a list of go-to libraries on npm that solves a specific and common problem well?
I'm not talking about big frameworks like React/Vue/Angular but things like momentjs.

On the other hand, can you think of libraries which are overused? 

How do you evaluate whether you want to depend on a library and when reinventing the wheel is actually the better choice?
Please explain why I need software architecture
Tags: explainlikeimfive, fullstack, desktop, computerscience
Published: 2020-12-02 05:46:57

Like MVC, MVVM, MVP.

How does it apply to

- Server-side only?
- Frontend only?
- Fullstack?
- Desktop app development?
- Mobile development?
- Starting a project from scratch?
- Continuing someone-else's project? Or forking a project?
- Working with a team?
Typescript Without Compilation
Tags: javascript, typescript, webdev, typesystems
Published: 2020-12-02 05:40:58

# Typescript Without Compilation

Hi, in this post I will show how to use Typescript with static typings without needing a build step. I have also [implemented this in my project SwordCSS](https://github.com/swordcss/swordcss).

## Installation

We still need to install and configure Typescript though.

```
$ npm install -D typescript
```

`tsconfig.json`:
```json
{
  "compilerOptions": {
    "moduleResolution": "node",
    "module": "CommonJS",
    "target": "ESNext",
    "sourceMap": false,
    "declaration": false,
    "checkJs": true,
    "allowJs": true
  }
}
```
You can change the options however you want, but make sure the last four `compilerOptions` are the same.

## JSDoc

Now, let me give you an introduction to JSDoc. JSDoc is a format for commenting on and annotating Javascript code. Here is how you would use it with Typescript:
```js
//@ts-check
/*
 * @function
 * @param {string} param1
 * @param {number} param2
*/
function doingSomething(param1, param2) {
	doSomething(param1, param2)
}
```
Or at least that is how you would use it with functions. There are some other things you can do, and you can look at what is supported with JSDoc + Typescript.

**IMPORTANT** You must have `//@ts-check` at the top of your file for it to be type checked.
Wes Bos Javascript, Node, Gatsby, React BFD discount
Tags: javascript, node, gatsby, webdev
Published: 2020-12-02 05:34:28

Hey everyone, Wes Bos, the popular full stack web developer from Ontario, Canada is offering Black Friday discount on all of his courses. For the next 7 days, you are eligible to get 50% discount for any Wes Bos’s course you buy. This is the only time of the year when Wes Bos slashes the price of his amazing courses.

You don’t want to let this opportunity go. Do take a look at the list of popular Wes Bos courses down below and sign up for your favorite with Black Friday offer. And, the best part is, Wes Bos supports Parity Purchasing Power, so on top of black friday discount, you get additional discount if you are from a country where the price may look expensive.

<h2>List of Wes Bos Popular Courses</h2>

Master Gatsby — Build modern websites with Gatsby, React and Friends – <a href="https://mastergatsby.com/friend/GALORE">ReadMore</a> 

Beginner JavaScript – Learn Javascript from scratch – <a href="https://beginnerjavascript.com/friend/GALORE">Read More</a>

Advanced React and GraphQL — Build Full Stack Applications with React and GraphQL – <a href="https://advancedreact.com/friend/GALORE">Read More</a>

React For Beginners – The best way to learn React – <a href="https://reactforbeginners.com/friend/GALORE">Read More</a>

ES6 for Everyone — The best way to learn modern ES6 JavaScript – <a href="https://es6.io/friend/GALORE">Read More</a>

Learn Node — The best way to learn Node.js, Express, MongoDB – <a href="https://learnnode.com/friend/GALORE">Read More</a>

For each of the above courses, you get 50% black friday discount.

You can also take a look at Wes Bos’s most popular course “<a href="https://javascript30.com/friend/GALORE">JavaScript 30 — Build 30 things with vanilla JS in 30 days with 30 tutorials</a>“. It is available for free at the moment until next notice.

If you have any questions about this offer, please feel free to reach out.
8 Best Tableau Courses Online in 2021- Find the Best One!
Tags: datascience, machinelearning
Published: 2020-12-02 05:29:10

Are you looking for **Best Tableau Courses Online?**, but unable to find a good Tableau Course, then Don’t worry! I have chosen some of the Best Tableau Courses Online after filtering out hundreds of courses. So, give your few minutes to this article and find out the Best Course for you.

As a Data Analyst or Data Scientist, you have to showcase your findings in a visual form, so that **stakeholders can understand** it properly. This is important in the Data Science field. That’s why the knowledge of **Data Visualization is important.** 

Tableau is the most **powerful, secure, and flexible end-to-end analytics platform** for your data. Tableau has in-built visualization reporting tools, by drag and drop, you can create a wonderful presentation report.

**Audi, Bank of America, Amazon, Burger King, EY, and Kimberly-Clark Corporation** are a few of the top companies using Tableau. – Tableau

This is the number of Top Industries that use Tableau-
![Best Tableau Courses Online](https://dev-to-uploads.s3.amazonaws.com/i/k7x9iha1manco20nuuit.png)
Source: enlyft


Now, you might be thinking, OK fine! Tableau is required for Data Science, but from where to learn?. So, if you are thinking the same, then don’t worry. I have chosen some **Best Tableau Courses Online.** These courses will definitely give you good command of Tableau.

Let me tell you, on what criteria I have chosen these courses-

##**Criteria-**

1. Rating of these Courses.
2. Coverage of Topics.
3. Engaging trainer and Interesting lectures.
4. Number of Students Benefitted.
5. Good Reviews from various aggregators and forums.

So, without wasting your time, let’s start finding the Best Tableau Courses Online for you.
**[Click to continue reading...](https://www.mltut.com/best-tableau-courses-online/#1-data-visualization-with-tableau-specialization-coursera)**
SVM Implementation in Python From Scratch- Step by Step Guide
Tags: machinelearning, datascience, python
Published: 2020-12-02 05:20:58

In this article, I am gonna share the **SVM Implementation in Python From Scratch.** So give your few minutes and learn about Support Vector Machine (SVM) and how to implement SVM in Python.

So, without further ado, let’s get started-

#**SVM Implementation in Python From Scratch**

Before moving to the implementation part, I would like to tell you about the Support Vector Machine and how it works.

##**What is a Support Vector Machine?**

SVM was developed in the **1960s** and refined in the **1990s.** It becomes very popular in the machine learning field because SVM is very powerful as compared to other algorithms.

SVM ( Support Vector Machine) is a **supervised machine learning algorithm.** That’s why training data is available to train the model. SVM uses a classification algorithm to classify a two group problem. SVM focus on decision boundary and support vectors, which we will discuss in the next section.

##**How SVM Works?**

Here, we have two points in two-dimensional space, we have two columns x1 and x2. And we have some observations such as red and green, which are already classified. This is linearly separable data.
![SVM Implementation in Python From Scratch](https://dev-to-uploads.s3.amazonaws.com/i/dsdgpi70p9td1srong69.jpg)

But, now how do we derive a line that separates these points. This means a separation or decision boundary is very important for us when we add new points.

So to classify new points, we need to create a boundary between two categories, and when in the future we will add new points and we want to classify them, then we know where they belong. Either in a Green Area or in Red Area.

**So how can we separate these points?**
**[Click to continue reading...](https://www.mltut.com/svm-implementation-in-python-from-scratch/#how-svm-works)**
Capture global JS errors with window.onerror()
Tags: javascript
Published: 2020-12-02 05:19:29

Did you know you can capture and report on global JavaScript errors with window.error? Check it!

```js
// The "error" event fires when an uncaught error is thrown
window.addEventListener('error', function(event) {
  console.log('Captured error:', event);
});
```

Inside the error object, you'll get all sorts of information including the error message, target element, and even the stack trace.

<img src="https://res.cloudinary.com/dzynqn10l/image/upload/v1600924032/JS%20Bits/chrome_gKb5SjwUmX_neyjfp.png">

This is how a lot of error logging platforms capture client-side errors: the event listener can be added globally and the callback can send the error date to a server where you can do all sorts of things with it. Neat! 😎

----------
Check out more #JSBits at my blog, [jsbits-yo.com](http://jsbits-yo.com/). Or follow me on [Twitter](https://twitter.com/JS_Bits_Bill)!
Coding_at_43.rb
Tags: 100daysofcode, codenewbie, ruby, rails
Published: 2020-12-02 05:14:16

I just looked, and I haven't written anything here since July. That's crazy to me. A lot has happened since then. I finally moved out of the house that I'd rented when working in the oil field. After being laid off, $1200 a month just wasn't affordable anymore, especially in the tiny town I live in. I did manage to find something more affordable, but still a pretty high price range as there wasn't much available. I'd relocate somewhere, but first I need to find a job that pays a living wage(my wife has health issues and can't work, plus taking care of our 4 year old).

I was able to land another job after the oil field. I'm currently working at Baxter Healthcare, a company that makes various medical equipment. I'm not making near the money I was(we are still scraping by for now), and things are still a struggle especially with covid, but I'm proud to say I'm making some headway with programming. 

Recently I started talking to one of my followers on twitter, Michael Maitoza, and for the last month he and I both started the Ruby content on www.learnenough.com. Michael Hartl was kind enough to give us both scholarships, and we are going through it together.

Today I finished the Ruby course, and I must say it is one of the most rewarding things I've done to date (aside from actually finishing a course, but that's a story for another time). I worked really hard on it, and put in the time, and I feel I have a decent grasp of the language. I'm no expert, but I learned enough to be dangerous :D 

Next on my list is completing the Ruby on Rails Tutorial. I'm shooting for maybe another month for that, but I'm going for better understanding vs just finishing, so if it takes longer I'm good with that. I'm probably going to rebuild my website as I did it in Jekyll and really didn't have a good understanding of Ruby at the time. After that, I have some ideas for some things to build, possibly a team project with Michael Maitoza, so we'll see how things go.

Glad to be back, thanks for reading!

PS. If you're like me and are struggling and would like a shot at getting a scholarship for Learn Enough, you can apply here: 

https://news.learnenough.com/learn-enough-scholarship-program

If you get in let me know, I'd love to add a few people to my discord to talk Ruby with :)
How I created a translator web app using HTML,CSS and JAVASCRIPT
Tags: css, javascript, html, webdev
Published: 2020-12-02 05:03:46

There are three things that are needed for an application-input,processing and output.For processing in this app means translation.We will be using `funtranslation api` which returns translated content.
#Funtranslations API
There are so many translation languages available which can be used for translations.Here we will be using minion language and to get response from the api we need to send the url in the given format-
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/3ui04si33n441kiccxfl.PNG)

#Taking user input
For any translator app, the first thing needed is the user's input so we that using `textarea` tag of HTML.
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vqwdz9i7dkanzvhaets5.PNG)

#Processing user input
For processing which is done in our app.js, we reference `textarea` in javascript using `document.querySelector()`

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/oupezjr4an7xl9hnrj9b.PNG)

Now we have reference to input and to extract the value from this we will use `textInp.value`.But first, we will make a function to get our translation url which we will be using it to fetch translated text from the server using the `funtranslations api` 
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/hw92wvx3exaxoidsg9mt.PNG)

Here serverUrl is the base url which is required for API. Now a fetch function which gets the translated text and displays output using `innerText` on an output element also referenced using `document.querySelector()`

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/0xuskdwfbd53sclj8jh5.PNG)

#Translated output to the user
We will create a div that has no text and will show output after processing when the button is clicked.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/i9ng1fyq6gkd822jt0hx.PNG)

Button referenced in the script and added an event listener `addEventListener()` on it which waits for a click on the button and then calls our `clickHandler` function.

![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/vo31p9c5ii9u28zrblx9.PNG)

To check the live demo of this app you can go to [Banana app](https://gobanana.netlify.app/)
Also I have created a repo on [github](https://github.com/amansethi00/banana-translator-app).

>This is my first blog. Suggestions are welcome from all of you. Thank You.

To know more about me, you can connect with me on [Twitter](https://twitter.com/amansethi00).