teleren/devto huggingface dataset:
Python Operators Precedence Example
Tags: python, datascience, machinelearning
Published: 2020-07-19 17:05:19

Hello everyone, welcome to DEV community today we will see python operator
so let's start:
The following table lists all operators from highest precedence to lowest.

[<a href="https://www.pythonslearning.com/2020/07/greater-than-or-equal-to-python.html">Operator Description</a>]
** Exponentiation (raise to the power)
~ + - Complement, unary plus and minus (method names for the last two are +@ and -@)

/ % // Multiply, divide, modulo and floor division
- Addition and subtraction
<< Right and left bitwise shift & Bitwise 'AND'td>
^ | Bitwise exclusive OR' and regularOR'
>= <a href="https://www.pythonslearning.com/2020/07/greater-than-or-equal-to-python.html">Comparison operators</a>
<> == != Equality operators
= %= /= //= -= += *= **= Assignment operators
is is not Identity operators
in not in <a href="https://www.pythonslearning.com/2020/07/what-is-list-in-python-with-example.html">Membership operators</a>
example
a = 20
b = 10
c = 15
d = 5
e = 0

e = (a + b) * c / d #( 30 * 15 ) / 5
print "Value of (a + b) * c / d is ", e

e = ((a + b) * c) / d # (30 * 15 ) / 5
print "Value of ((a + b) * c) / d is ", e

e = (a + b) * (c / d); # (30) * (15/5)
print "Value of (a + b) * (c / d) is ", e

e = a + (b * c) / d; # 20 + (150/5)
print "Value of a + (b * c) / d is ", e
When you execute the above program, it produces the following result list −

Value of (a + b) * c / d is 90
Value of ((a + b) * c) / d is 90
Value of (a + b) * (c / d) is 90
Value of a + (b * c) / d is 50
references: https://www.pythonslearning.com/2020/07/greater-than-or-equal-to-python.html
Angular : Introduction
Tags: angular, javascript, tutorial, beginners
Published: 2020-07-19 16:50:15

# What is Angular?
> **Angular** is a JavaScript framework which makes you able to create reactive Single Page Applications (SPAs). This is leading front-end development framework which is regularly update by Angular team of Google. The very first version Angular 1.0 is known as AngularJS. Angular's versions beyond 2+ are generally known as Angular only.


# What is Single Page Application (SPA)?
> A single page application is a web application or a website which provides users a very fluid, reactive and fast experience similar to a desktop application. It contains menu, buttons and blocks on a single page and when a user clicks on any of them; it dynamically rewrites the current page rather than loading entire new pages from a server. That's the reason behind its reactive fast speed. Because the page need not to reload again and again.

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

## Angular 1: 
> Angular 1 or Angular JS was initially released in 2010. It was the first Angular version. It create a revolution in the web application development. It was a browser side JavaScript which used within HTML code. It is popularly known as Angular JS.

## Angular 2 or above version: 
> Angular 2 was a complete rewrite of Angular 1. It was initially released in 2016. There is nothing common between Angular and Angular 1. All the above version of Angular is similar to each other. Angular 10 is the latest version. All these versions are known as Angular.

# Full Stack Development
>Angular is a complete framework of JavaScript. It provides Testing, animation and Accessibility. It provides full stack development along with Node.js, Express.js, and MongoDB.

>> Testing:- Angular provides Karma and Jasmine for unit testing. B y using it, you can check your broken things every time you save. Karma is a JavaScript test runner tool created by Angular team. Jasmine is the testing framework form unit testing in Angular apps, and Karma provides helpful tools that make it easier to us to call our Jasmine tests whilst we are writing code.

>> Animation Support: Angular facilitates you to create high-performance, complex choreographies and animation timelines with very little code through Angular's intuitive API.

>> Accessibility: In Angular, you can create accessible applications with ARIA-enabled components, developer guides, and built-in a11y test infrastructure.

Next topic : Angular installation.
Mardown Badges
Tags: markdown, badges, github, profile
Published: 2020-07-19 16:45:42

Ever heard the saying "a picture is a thousand words"?

Badges not only adds beauty to a markdown file, it communicates a message quickly.

Spice up your Github Profile and Projects with badges.

Here's a screenshot of my [Github Profile](https://github.com/Ileriayo):

![Ileriayo's GitHub Profile](https://dev-to-uploads.s3.amazonaws.com/i/fg12pjh2dgx6782w1st8.PNG)

I created this project to get you started: [Markdown Badges](https://ileriayo.github.io/markdown-badges)

Feel free to contribute and add more tech badges.

Follow me on [Twitter @Ileriayooo](https://twitter.com/Ileriayooo) for more on Tech and Opportunities.

If you want to be successful in tech, [here is a simple framework](https://twitter.com/Ileriayooo/status/1490416597596614660).
Do icons need alt attributes?
Tags: a11y, webdev, html, css
Published: 2020-07-19 16:37:04

---
title: Do icons need alt attributes?
published: true
description: When and how to include text alternatives for icons
tags: a11y, webdev, html, css
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/2hyfqt6zb33z60i4cxd2.jpg
---
"Hey Nadia - do icons need alt attributes?" When I got this question from a colleague a few days ago, my first instinct was to say, "it depends". Of course, I then went on to explain what it depends on, but I also realized that I get this question often enough for the answer to be turned into an easily shareable short post.

So, does an icon need an alt attribute? Well, it depends on how the icon is being added to the page and what the purpose of that icon is.

If an icon is added using an inline image element, it _must_ have an alt attribute. The value of that alt attribute can be a string of text (`<img src="icon.png" alt="Get more information" />`) or an empty value (`<img src="icon.png" alt="" />`) in case it’s a decorative icon, but it absolutely must have an alt attribute.

If the icon is added through CSS, it will never actually have an “alt attribute” as alt attributes are used on an `<img>` element. The icon can still, however, have a text alternative or a text equivalent to provide context for users.

An icon added through CSS for purely decorative purpose, for example, a fancy bullet list icon, doesn’t need any text alternative to provide more context or information to the user.

On the other hand, a when an icon added through CSS is functional (e.g. a magnifying lens to activate search) or provides some sort of information to the user (e.g. a check mark or an x to depict which features are included in a product), you need to include a text alternative. The text alternative in this case is not added through an `alt` attribute. It could just be a contextual text either accompanying the icon on the page or it could be a visually hidden string made available to screen reader users.

But, why do you need any alt text at all on icons? Because icons on their own may not be enough to give users context. For example, when you create an icon button for a hamburger menu or search, screen reader users with no or low vision will have no idea what that button does when they land on it unless there is some text there to tell them the purpose of that button. 

Screen reader users aren't the only people who need accessible icons. Most icons and symbols without any accompanying text can be just as confusing for persons with cognitive disabilities or someone who lacks the cultural context. Including text alternatives or alt text to your images is one of the simplest and quickest way of making your website usable and accessible.

And finally, if you’re still not convinced and need one more reason to include appropriate text alternatives for your icons, it's a great SEO win as well. Search engines, such as Google, give pages that include alt text in images high importance when indexing websites. 

--

Have a question? Feel free to ask in the comments below or on [twitter](https://twitter.com/nadiarasul).
Populating a pre-allocated array slower than a pushing to a regular array?
Tags: discuss, javascript
Published: 2020-07-19 16:34:27

For no good reason, I got the urge to do a performance comparison between populating an array by pushing to it vs writing to a buffer. Then, to make things more interesting, I decided to add a static array and a pre-allocated standard array.

Let's just say the results were not what I expected.

## Experiment
Populate the 4 data structures by adding 10^8 elements to each and comparing the time it took for each of them.

### Candidates
- Static array - populated by writing directly to the index
- Pre-allocated dynamic array - array initialized to hold all elements and then populated by setting elements for each index
- Buffer - populated by writing directly the offset. Should be similar to writing to an index, but there might be some internal overhead
- Array - empty array populated by pushing elements to it

### Expected results (from fastest to slowest)
1. Static array
2. Pre-allocated array
3. Buffer
4. Array

### Actual results (from fastest to slowest)
1. Static array (228.039ms)
2. Buffer (1.135s)
3. Array (2.545s)
4. Pre-allocated array (6.062s) (Why so slow???)

What I don't understand is why the pre-allocated array performed so poorly. I would expect its performance to be on par with a static array. I definitely didn't expect it to be outperformed by an array built by pushing elements into it.

## Code
```js
const NUMBER_OF_ELEMENTS = 10**8
const ELEMENT_LEN_BYTES = 4

const array = []

console.time('array')

for (let i = 1; i <= NUMBER_OF_ELEMENTS; i++) {
    array.push(i)
}

console.timeEnd('array')

const preAllocatedArray = new Array(NUMBER_OF_ELEMENTS)

console.time('pre-allocated array')

for (let i = 1; i <= NUMBER_OF_ELEMENTS; i++) {
    preAllocatedArray[i - 1] = i
}

console.timeEnd('pre-allocated array')

const intArray = new Uint32Array(NUMBER_OF_ELEMENTS)

console.time('int array')

for (let i = 0; i < NUMBER_OF_ELEMENTS; i++) {
    intArray[i] = i + 1
}

console.timeEnd('int array')


const buffer = Buffer.alloc(NUMBER_OF_ELEMENTS * ELEMENT_LEN_BYTES, 0)

console.time('buffer')

for (let i = 1, offset = 0; i <= NUMBER_OF_ELEMENTS; i++) {
    offset = buffer.writeUInt32BE(i, offset)
}

console.timeEnd('buffer')

// Results:
// array: 2.545s
// pre-allocated array: 6.062s
// int array: 228.039ms
// buffer: 1.135s
```

**Edit:** It looks like the V8 engine's optimizations favor `.push()` over direct index assignment. The findings for Chrome in [this (ancient) article] are consistent with my results on Edge, Chrome, and Nodejs; all of which run on top of the v8 engine.

Thanks @Alain Van Hout for sharing the link in the comments.

If anyone has any ideas how those optimizations are performed, please do share 🙂
[Tutorial Git] git log/reflog: Verificando o histórico do git
Tags: log, git, reflog, womakerscode
Published: 2020-07-19 16:33:15

Para ver o histórico de commits do **Git**, digite:

```
$ git log
```

- **$** indica que você deve usar o **usuário comum** para fazer essa operação.

E o retorno será todos os **commits** feitos até o momento.

![mostrando todos os commits](https://dev-to-uploads.s3.amazonaws.com/i/5pn1j63r6p0na2i2veuu.png)

Pressione [ENTER] quantas vezes sejam necessárias para ver os outros commits (isso ocorre quando o número de commits é maior do que o espaço ocupado pelo terminal) e ao final, quando aparecer a palavra **(END)**, pressione a letra **q** para sair.

![final da lista do histórico de commits](https://dev-to-uploads.s3.amazonaws.com/i/u9s261o8q2p8ibbkbkts.png)

Caso queira ver esse histórico numa versão mais resumida, use a flag apresentada abaixo:

```
$ git log --oneline
```

![usando a flag oneline](https://dev-to-uploads.s3.amazonaws.com/i/2rq7v2sr24p4lbahrhd5.png)

Caso queira ver apenas os 4 últimos **commits**,

```
$ git log -4
```

![4 últimos commits](https://dev-to-uploads.s3.amazonaws.com/i/b07z2q2yhkq5oxkbzfow.png)

Você pode substituir o número 4 por outro número inteiro, conforme a necessidade.

Também é possível fazer uma combinação desses comandos. Exemplo:

Usando o git log em combinação com a flag oneline.

![usando o git log em combinação com a flag oneline](https://dev-to-uploads.s3.amazonaws.com/i/x1asjuvht5s52z6xli4u.png)

Para ver o histórico de tudo que foi feito (não apenas commits),

```
$ git reflog
```

![usando o reflog](https://dev-to-uploads.s3.amazonaws.com/i/422dsr0ow08m4eo4b8gn.png)

Esse comando é muito útil para usar com o **reset** quando você precisa recuperar algo que foi perdido por acidente, seja depois de um **merge** ou próprio **reset** problemático, algo que quebrou ou foi excluído e até mesmo recuperar um **branch** excluído. Ele é como uma máquina do tempo mais potente do que o **log**.

```
$ git reset HEAD@{número_do_índice}
```

Entretanto, o **reflog** tem 90 dias de prazo de validade padrão.
Como criar um Toast no Flutter
Tags: dart
Published: 2020-07-19 14:56:15

Você pode acessar o pai ScaffoldState usando Scaffold.of(context)

Então faça algo como
```dart
Scaffold.of(context).showSnackBar(SnackBar(
      content: Text("Sending Message"),
    ));
```
Para mais detalhes consulte:
https://material.io/design/components/snackbars.html#usage

## Exemplo:
![Alt Text](https://dev-to-uploads.s3.amazonaws.com/i/ufvzaf0mjelzocrixqwj.png)
```dart
import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: const Home(),
    );
  }
}

class Home extends StatelessWidget {
  const Home({
    Key key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Snack bar'),
      ),

      /// We use [Builder] here to use a [context] that is a descendant of [Scaffold]
      /// or else [Scaffold.of] will return null
      body: Builder(
        builder: (context) => Center(
              child: RaisedButton(
                child: const Text('Show toast'),
                onPressed: () => _showToast(context),
              ),
            ),
      ),
    );
  }

  void _showToast(BuildContext context) {
    final scaffold = Scaffold.of(context);
    scaffold.showSnackBar(
      SnackBar(
        content: const Text('Added to favorite'),
        action: SnackBarAction(
            label: 'UNDO', onPressed: scaffold.hideCurrentSnackBar),
      ),
    );
  }
}
```
Error Chains in Go 1.13
Tags: go, tutorial, video
Published: 2020-07-19 16:18:51

{% youtube eeKCFg-d2UE %}

Go added a neat feature in 1.13 that they call `error chains`

Errors can now implement a method called `Unwrap` that should return another error. Typically, this is an error that occurred further down in the call stack.

It is very common in go to have errors get tossed further and further back up the call stack as functions resolve, until its finally handled properly. Error chains allow you to carry a series of errors all the way back up the call stack more easily.

They added two new functions in the `errors` package to interact with this concept, `Is` and `As`

`Is` takes a argument of an error and another error, returns true if any instance of the second error occurs in the first error's chain, and false otherwise.

`As` takes the same arguments, but sets the value of the second argument equal to the error that was found in the first error's chain if it was present.

Check out the video to see the concept in action.

If you liked it and want to know when I post more, be sure to [subscribe] (https://www.youtube.com/channel/UCTHij3Ac5GizLsn5yB4IX_Q?sub_confirmation=1) and thank ya'll again for your time!
Dear Developer, I need your help, in helping you!
Published: 2020-07-19 16:12:08

Dear Developer,

I write this while I'm resting as I've nothing to do.


Laying down on this couch, 
with a white coffee mug(it has a github sticker) on the table, 
And watching the rain fall. 

It sounds amazing, peaceful and I feel so connected to the Nature.

Then, Suddenly i found myself in deep Thoughts about the purposeless-ness that I've been feeling. It's weird to think about it, when I've a job, family and good friends too. 

Heck I've not even got cold since a year or so.

But it's restless, 


You: Why?

Me: (coughs) You probably dont know, but I've a worm of teaching people hard stuff after learning it for myself. And I'm not getting opportunities to do that.

You: What does that even mean?

Me: That means you should tell me what you want to learn(Web development or Software development related, if i may say that) some stuff, that you found hard or are just interested in it.

You: Well, I can rather just look up Google. Then why?

Me: Well, First of all It's gonna be personal, I'll write it as you asked, so you can learn.
We'll have chance to discuss it, between us and with our other developer friends. Sounds good?

You: Yeah, I guess.

Me: Then, Comment:
- What's that one thing that you're struggling with? 
- What's that one thing that you want to learn but find it hard to grab? 


Go ahead, I'll try my best to learn and then teach you. I'm waiting for you.
Rails - Convention Over Configuration
Tags: rails, ruby
Published: 2020-07-19 15:53:25

When starting the Rails Curriculum, the concept of convention over configuration was said to be the basis of Ruby on Rails. The Rails framework has provided developers with an environment designed to get more done, in a shorter time with less code. Convention over configuration is defined as a software design paradigm that attempts to minimize the number of recurring decisions that a developer needs to make. In Rails, the repetitive part of programming is abstracted away to allow you to focus more on problem solving. I’ve noticed that the naming conventions in the Rails framework follows a natural/sensible thought process. For example, when using the resources macro for the application routes, it creates the 7 RESTful routes and provides url helpers with appropriate naming. It’s conventions like this that help cut out a bunch of time in the developing process. Convention over configuration in Rails allows you to focus more on problem solving by abstracting the repetitive stuff away! Being new to the programming world, I thought Rails would be extremely difficult for me to learn. However, I’ve found that the constant use of convention over configuration has made everything in the framework come together very naturally.
The Importance Of Tracking Progress
Tags: fitness, personaltraining
Published: 2020-07-19 15:11:15

So you’ve set your goals, you’re working hard, and you think that you can see results, but you can’t measure it. Sound familiar? Lots of people train like a beast and stick to their routine, but they never track their progress, so they don’t know how far they have come, or if they need to up their game to get ahead. Thanks to ERA Fit, tracking your progress has never been easier. Whether you want <a href="https://erafit.com/">personal training in Miami</a>, or you want to stick to online personal training, ERA Fit has made it possible to track your progress and get an overview of where you are at. 

<h2>Setting Specific Goals</h2>

There are numerous tabs on your personal dashboard, and one of them is for setting your goals. It’s not all about weight and training; it’s everything from nutrition and exercise, to lifestyle and mentality. You log how you are now, and set your goals based on that. Your personal coach will also be on hand to help you plan these along the way. 

<h2>Progress</h2>

If you don’t know how far you have come, and you can’t measure your progress, the chances are that you might give up. You don’t just track your weight and training with ERA Fit. You will be able to track your strength, stamina, speed, as well as your physical appearance. There’s space to upload photos so that you can see your body changing. Sometimes the scales are a demotivator, but you can’t argue with a photo. 

<h2>Keeping Track</h2>

The best thing about online personal training is that you can keep track of everything that you do, and you can refer back to it at any time. Along with meal plans and ideas, there’s a place to log everything that you eat and when you eat it. You can also do the same with your workout. One thing that a lot of people don’t give enough credit to is sleep. <a href="https://aasm.org/college-students-getting-enough-sleep-is-vital-to-academic-success/">Sleep is essential</a> to a healthy lifestyle. If you aren’t getting enough, then you won't have the energy to do what you need to do. Equally, if you are having too much sleep, you aren’t giving your body enough time to work out, your mental health may be affected, and most importantly, it's not good for you. This is why there’s a section where you can record how much sleep you are having each night. 

Personal training and fitness are not just about working out and eating well. If you want to see results, you need to think about every aspect of your life and make changes accordingly. There’s no time like the present, take the first step, and take their 30-second quiz to see how your life could be improved.