teleren/devto huggingface dataset:
What is golang good for?
Tags: go
Published: 2019-11-06 19:42:12

<a href="https://golang.org/">Go</a> is a general purpose programming language. This means, you can use it for whatever you want (<a href="https://golangr.com/about-go/">Why Learn Go</a>). It's syntax looks a bit like C programming

```
    package main
    
    import "fmt"
    
    func main() {
       fmt.Println("Hello, World!")
    }
```

Its especially good for:

* systems: powerful standard 
* concurrency: you can use it to build concurrent apps without being concerned about performance
* networking

In other words, Go is good for those like to program in low level.
These days its used for:

* Networking and Webservers
* Automation and Command-line tools

That's a lot of stuff you can use it for already!

<img src="https://external-content.duckduckgo.com/iu/?u=https%3A%2F%2Fforum.golangbridge.org%2Fuser_avatar%2Fforum.golangbridge.org%2Fstabby%2F200%2F55_1.png&f=1&nofb=1">

Its not (yet) used much for desktop software, web frontends, mobile app development, games, banking. That does not mean it cannot be used, just that it has not matured yet for these purposes.

That silly animal on top? that's the Go logo btw. 

**Related links:**
* <a href="https://golang.org/">Official Golang website</a>
* <a href="https://golangr.com/">Golang Programming tutorial</a>
* <a href="https://www.youtube.com?v=cQ7STILAS0M">Video talk: Why Go is successful</a>
How Do You Achieve Deep Focus?
Tags: discuss, watercooler, productivity, askdev
Published: 2019-11-06 19:14:18

---
title: How Do You Achieve Deep Focus?
published: true
description: 
tags: discuss, watercooler, productivity, askdev
---

I've been reading Deep Work by Cal Newport 📙 lately and the idea of "deep work" really speaks to me. Deep work is described as the ability to focus without distraction on a cognitively demanding task for extended periods of time. ⌚

I often get distracted easily as I have a lot of browser tabs open, which is not surprising given the type of work I do. I know many other people face this problem too. 🙁

So I wanted to ask those of you who've conquered this. How did you achieve it? How do you minimize distractions and achieve your peak focus state? 💯

I personally try to use multiple browsers and/or context-based browser windows whenever possible. So, for example, I always have a few important tabs running on my main browser window. If I have to, say, write an article while doing research side by side, I open a new window and do everything related to that particular task (writing the article) in this window. 🤓 Once I'm done, I close all the tabs and go back to the main window.

That's just one of the things I do, but it's not a perfect solution, and it doesn't cover all types of distractions. I'm very interested in hearing what techniques you all use. 😃
write a simple media player for Winamp
Tags: html, android, javascript
Published: 2019-11-06 19:10:29

Anyone can write a simple media player for Winamp. I want to play music from my home computer to the internet by using Winamp. I already have made a canvas for the player. Just need an HTML code for that player with Volume button - Start - Stop Button and display of the song playing. I have some examples of players. I can send the design
How to create your own reduce 😎
Tags: javascript
Published: 2019-11-06 19:01:40

# What is it?
![](https://media.giphy.com/media/xTht9ZUiUszNadjxEk/giphy.gif)
The reduce, oh the reduce. 
So spoken but so little understood.

Well, `reduce()` started to become popular with ES6, along with the `map()` and `filter()` functions that recalled the javascript functional footprint.
Okay, what is it for?
As the name suggests, reduce seeks to reduce an array. 

It will iterate through each element of this list in order to ultimately generate a single value (of any type), such as the sum of all elements in this array. 

Remembering that we are not just stuck with numbers.
## Normal reduce:
```javascript
const nums = [1,2,3,4,5,6,7,8,9];
console.log(nums.reduce((acc, act) => return acc+act;)
```

# Let's create our own reduce 🤩
```javascript
Array.prototype.myReduce = (callback, initialValue) =>{
    const initialIndice = initialValue ? 0 : 1
    let acc = initialValue || this[0]
    
    for(let i = initialIndice; i < this.length; i++) {
        acc = callback(acc, this[i], i, this)
    }

    return acc;
}

const sum = (total, value) => total + value;
const nums = [1,2,3,4,5,6,7,8,9];
console.log(nums.myReduce(sum, 0))
```
### That's all folks 
![](http://giphygifs.s3.amazonaws.com/media/LYDNZAzOqrez6/giphy.gif)
Everything you need to know about css :empty selector.
Tags: css, html, design, angular
Published: 2019-11-06 18:54:16

CSS selector :empty is used to target empty elements or you can say like elements which don't have contents inside it. 

There are many a times when we give padding and margin to certain elements like a paragraph tag `` <p> hello </p> ``. Let's suppose that particular tag gets some dynamic loaded data into it. There will be situation where there will not data and `` <p> </p>`` tag will still contain those styling in it.
In that case :empty selector comes into play.

Example:

``` .content p:empty {
        padding: 0;
        margin:  0;
} ```

this styling will be applied to that ``<p>`` tag which has no content inside it.

or

```.content p:not(:empty) {
    padding: 15px;
    margin:  15px;
} ```

this styling will be applied to that all ``<p>`` tag inside .content which but not to empty elements;
Get your juniors up and running! 🏇🏼
Tags: teams, productivity, ownership, junior
Published: 2019-11-06 18:39:33

---
title: Get your juniors up and running! 🏇🏼
published: true
description: How you can grow confidence and ownership in junior developers on your team
tags: teams, productivity, ownership, junior
---

In large codebases with new developers it can take a while before people feel comfortable working on projects or tasks by themselves. Getting developers to this stage can take lots of time, but it's worth the effort when many developers can work in parallel. Here are some of the reasons why junior devs may be uncomfortable jumping into the deep end or asking for help soon enough, and ways that you may be able to mitigate these problems and have a more productive happy team.

### Coder's Block 📖

Similar to writer's block, is coder's block. You know what you need to get done but you can't figure out the right way to get started. This is especially true for junior devs who may not understand the conventions or established patterns of your project very well yet.

#### How to Help

Describe the problem together and write up an outline of all the parts that need to change, even going so far as to pseudo code in functions in the real code and let the junior flesh out the details. Make sure to have a good linter that allows the junior dev to get feedback on style automatically. Encourage them to start with TDD to get a smaller feedback loop to start with.

### In Too Deep 🚧

This one is similar to Coder's Block, but has a different cause. Sometimes junior devs will take more with a task than they can actually deal with. This can manifest as going days and days with little to no progress made on the task. It causes stress for the whole team because it can seem as if things should be getting done but they aren't, and the junior dev might be afraid to ask for help on the whole item.

#### How to Help

If you can, try and split the task up into smaller sub-pieces and go through the pieces with them to make sure they understand what each of them means and if they have a clear path forward on the task. Regular check-ins on the progress of the item as a team are helpful to ensure that a person isn't stuck and will allow them to describe what help they may need to move forward.

### Excited puppy syndrome 🐶

High confidence and a lack of experience can cause excited new developers down a some weird paths to solutions that you might not have expected them to go down. Some of these paths will be fine, a few will be great, and others will be... not so great.

#### How to help

Spend time pair programming, and pair code reviewing. It's great to get insight about what the person was thinking, and why they made the choices they did. This will help not only their code, but will also surface ways that you can make the code easier to understand in the future.

Hopefully with these few tips you can help your new devs be happy and productive quickly.
How to delete all the data from your Firestore database
Tags: firestore, firebase, database, serverless
Published: 2019-11-06 18:28:43

Sometimes when you're developing a new application, it might be useful to just have an easy way to wipe out your entire database as you're just trying out a few things.

If you're using Google's [Cloud Firestore](https://firebase.google.com/docs/firestore) database, there is no option for doing so in the web console. However, you can do it using it the [Firebase CLI](https://firebase.google.com/docs/cli):

```
firebase firestore:delete --all-collections -y
```

This command will delete your entire database. So, before you run it, make sure that's what you really want to do.

---

[Follow me on Twitter](https://twitter.com/ceolinwill)
Tailwind and React inputs
Tags: codepen, react, css
Published: 2019-11-06 18:27:18

I have been interested in tailwind css so I wanted to quickly spit out a form I had in my head. here it is. I would love feedback and maybe some iterations on how to make the cod cleaner.

{% codepen https://codepen.io/koryteg/pen/GRRdqyv %}
How to update one property in a list of items in React
Tags: react, javascript
Published: 2019-11-06 18:26:16

---
title: How to update one property in a list of items in React
published: true
description: Toggle a boolean property from true to false and back
tags: reactjs, javascript
cover_image: https://ferrariwebdevelopment.s3.us-east-2.amazonaws.com/assets/20190926-updating-property.jpeg
---

## Toggle a boolean property from true to false and back

Imagine we have a list of groceries and we want to mark groceries that are purchased with a different *style*. We want to be able to click on the `<div>` element that contains one grocery and apply a new `CSS` class to it.

In essence, what we want to do is *toggle* the state of the grocery item from non purchased to purchased.
Each grocery item has a property called purchased that is set to `false` by default. When we click on the item we want to set this property to `true`.

What we need is a new function called `toggleItem()` that performs this operation on each click:

- if `item.purchased` is `false`, set it to `true`
- if `item.purchased` is `true`, set it to `false`

`toggleItem()` needs to know which item to toggle, and in order to do that it
needs to know the item `id`. We pass the item `id` in the arguments to `toggleItem()`.
Here's how we define the function on our class component:

```js
toggleItem = itemId => {
  this.setState({
    groceries: this.state.groceries.map(item => {
      if (itemId === item.id) {
        return { ...item, purchased: !item.purchased }
      }
      return item;
    })
  });
}
```

Let's explain what the function does in detail.

To do any operation to the state we need to call the `setState()` function of the class instance.
`setState()` takes an object as an argument and merges it with the current state, in effect applying any changes to the current state.
`setState()` also re-renders the components that are affected by this state change, so they are displayed according to the new state.

In the new state object we use `map()` to create a new array from the current state array.
Inside the `map()` method we iterate through all grocery items and we check if the item id is the same as the id passed in the function as the argument.

If the `id` is the same it means we have found the item to toggle, so we return an object that has all the existing item properties (using the spread operator) and we also update the purchased property to the opposite of the current value.

This code:

```js
purchased: !item.purchased
```

takes the `item.purchased` value, which can be `true` or `false`, and returns the opposite. It then re-assigns the value to the `purchased` property.

If the `id` of the item we are iterating on is not the same as the `id` passed into the arguments, we don't perform any operation on the item and just return it unchanged.
That's how we toggle a property on an item in a list of items.
Problem with localStorage
Tags: html, javascript, localstorage, help
Published: 2019-11-06 18:21:26

Hi guys! I have a problem.
https://pastebin.com/pPCpxT9N
By this code I would like to change the text written in the paragraph from "Text" to "Another text", and I want to save the changement by localStorage, but it doesn't work. Can you tell me why?
Content Projection in Angular - Part 2
Tags: angular, contentprojection, dynamicviews
Published: 2019-11-06 18:04:34

---
title: Content Projection in Angular - Part 2
published: true
description: More on what we discussed earlier. Advanced Usage of Content Projection
tags: angular, content-projection, dynamic-views
cover_image: https://thepracticaldev.s3.amazonaws.com/i/ncvdv6o1lwppevj4ujgl.jpg
---

>In the previous [article](https://dev.to/salmankazmi6/content-projection-in-angular-34a5) on this topic, I touched the basics of Content Projection with Angular and how easily one can work with dynamic templates without much fuss. I also discussed the use case where one may need to project content to a Component dynamically.

Continuing in this post, I will touch some advanced use case scenarios where we can leverage the power that Angular provides.

Now, to discuss further, a Component provides us a functionality where we may pass the template in between the opening and closing braces of the component where we use it as a child in our template.

Like `<demo><h1>This is the template for content projection</h1></demo>`

The contents of the `<h1>` tag will be displayed where `<ng-content>` tag is present in the child i.e., demo component.

What if the child has several `<ng-content>` tags. How can we pass the template to a particular `<ng-content>` tag thereby rendering the dynamic view to its correct position?

Let's discuss Targeted Projection.

Angular provides us with the `select` attribute of the `ng-content` tag. With this attribute, we can actually work with targeted projection.

**Use case 1:**

`<ng-content select="[first-place]"></ng-content>`

The template can be passed as follows:

```html
<demo>
   <p first-place>Hello World!</p>
</demo>
```

**Use case 2:**

`<ng-content select="[place='first']"></ng-content>`
`<ng-content select="[place='second']"></ng-content>`

The template can be passed as follows:

```html
<demo>
   <p place='first'>Content 1</p>
   <p place='second'>Content 2</p>
</demo>
```

**Use case 3:**

`<ng-content select=".place-first"></ng-content>`
`<ng-content select=".place-second"></ng-content>`

The template can be passed as follows:

```html
<demo>
   <p class='place-first'>Content 1</p>
   <p class='place-second'>Content 2</p>
</demo>
```

There are a few other use cases as well, which I will keep for some other day to discuss. I hope this post proves to be useful in you Angular learning journey. Cheers!
Batch Sending Email with Attachments through AppleScript
Tags: applescript, automation, email, mail
Published: 2020-04-17 04:55:19

---
title: Batch Sending Email with Attachments through AppleScript
published: true
date: 2019-11-06 17:46:00 UTC
tags: applescript,automation,email,mail
canonical_url: http://english.catchen.me/2019/11/batch-sending-email-with-attachments.html
---

I want to learn a little bit of AppleScript. I need to help a friend send out emails to welcome new students to the school. The requirements are:

 
1. addressing each recipient by their name in email content;
2. attaching the same file in all emails.
 

After some research and tinkering I have a script to send emails:

 <script src="https://gist.github.com/CatChen/fe07ab39c7ea27d296e57838d7b5f1a4.js"></script> 

`theRecipients` is the list of recipient names and email addresses. This is for requirement #1. `theAttachment` isn’t hardcoded to any file path. It will prompt and let me choose a file when I run the AppleScript.

 

The trickiest part is the `delay 1`. Without this line, emails will be sent without the attachment. It’s a hack to make sure each email has the attachment. I don’t know why it works and I can’t find an explanation online.

 

After building this AppleScript, I learn that Google App Script is another great way to automate sending emails through Gmail (or GSuite). I will learn App Script and write a post about that next time. If you like this kind of posts, you can subscribe through [email](https://chen.cat/subscribe-to-blogs) or [RSS/Atom](http://feedproxy.google.com/CatChen/English).

 ![](http://feeds.feedburner.com/~r/CatChen/English/~4/hfpinDLIMjY)
Retreiving anchor tag using BeautifulSoup
Published: 2019-11-06 17:19:13

Beautiful Soup is a Python library for pulling data out of HTML and XML files. It works with your favorite parser to provide idiomatic ways of navigating, searching and modifying the parse tree. It commonly saves the programmer's hours or days of work.

The examples in this documentation should work the same way in Python 2.7 and Python 3.2.

You need to install beautiful soup.

We will import urllib, SSL, Beautiful soup.

Urllib is a package that collects several modules for working with URLs:
    urllib.request for opening and reading URLs
    urllib.error containing the exceptions raised by urllib.request
    urllib.parse for parsing URLs
    urllib.robotparser for parsing robots.txt files

Secure Sockets Layer (SSL) is a networking protocol designed for securing connections between web clients and web servers over an insecure network, such as the internet. After being formally introduced in 1995, SSL made it possible for a web server to securely enable online transactions between consumers and businesses.

Note: Don't worry about the SSL and the next 3 lines. It is just a way to ignore errors if you have SSL certification errors

So, let's start.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/b3iep1ayblokcjtumv1y.PNG)

Now, we will ask the user to enter the Url. We will use urllib.request.urlopen().read() method to read data from web pages. Then we will pass this data to Beautiful soup so that it will deal with all the nasty bit of code and it will convert UTF-8 to Unicode as Python follows Unicode.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/up8gx9zzbjvkeft7pmdm.PNG)

Now, we retrieve all the anchor tags.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/3rdzqc8whe2t9nc3k5ov.PNG)

Then, we loop through all tags and we pull out all text in href.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/w574t7dxi4s4blxr9pwq.PNG)

So, let's try it out.

![Alt Text](https://thepracticaldev.s3.amazonaws.com/i/9xb8etxo2ol3hfur2k3e.PNG)

That's it. If you have any Doubts feel free to comment.
Will the car of tomorrow be electric?
Tags: electriccar, tesla
Published: 2019-11-06 17:07:32

How does it work an electric car

 Electric cars use lithium-ion batteries that metal stocks a very large amount of energy, it's a multitude of batteries mounted in series, when the car is powered up, the ions stored in each pile flutter and circulates  from the note to the cathode, which allows to power the engine.  Today all electric cars can be purchased with the battery and without rental.
Readmore in source .. https://dailytechmonde.blogspot.com/2019/11/electric-cars.html?m=1
Changelog: Block Tools For User Safety
Tags: changelog, meta
Published: 2019-11-06 16:37:40

As part of our ongoing commitment to community safety, we've rolled out the ability to block other community members. This is a tool designed to be used as a complement alongside the efforts of our community of moderators and existing anti-abuse systems. Our hope is that this feature doesn’t have to be used too often, but it is critical to provide tools which offer individuals immediate recourse against abuse and harassment.

So, what does blocking someone do?

Blocking someone means that:
- They will not appear in your feed
- You will not see their comments
- You will not receive any notifications on their activity
- They will not be able to comment on your posts
- They will not be able to message you through DEV Connect

_We also have a **mute** feature coming in the future, which will only hide in-feed content but will not block comments, etc. So, if you are not seeking to wholly block a user, and just want to see less of their content, please wait for that mute feature._

As this is our first implementation of the feature, we're open to additional suggestions on how to continue improving it. We will be refining this functionality in coordination with the community. Please [open an issue](https://github.com/thepracticaldev/dev.to/issues) if you have any suggestions or encounter a bug.

On a personal note, I am glad to have had the opportunity to work on this feature. As a DEV core team member and participant of the community, most of my time with DEV has been working on support and anti-abuse. I think we've implemented some great features and practices in responding to abuse reports thus far. However, we can’t rest on our laurels; providing everyone with additional anti-abuse tools is an incredibly important step in ensuring that everyone feels safe here in the community as we grow. We have more safety features coming down the pipeline in active development.

Happy coding. :heart:
Flawk Live Stream Outline - Week 4
Tags: showdev, javascript, node, startup
Published: 2019-11-06 17:03:06

> Cover Photo by JOSE LARRAZOLO on Unsplash

### Edit: I will be postponing the stream so I can rest an fight a cold, will update when I reschedule. 

## We have a public roadmap! You can vote for features you want to see!
## https://flawk.to/roadmap

Every week I do a stream as I build out my new company [flawk.to](https://flawk.to). I have posted a little about this previously ([#1](https://dev.to/ericadamski/creating-more-meaningful-interactions-4j2h), [#2](https://dev.to/ericadamski/i-m-building-a-product-should-i-stream-it-51nk)) and will continue to write about it as time goes on. Some feedback I got on how to make my streaming more useful for others was a plan! So each week I will be posting an outline of what I will be doing in the stream and what the goals of that stream will be.

Here is last weeks plan and video:
Video: https://www.youtube.com/watch?v=xA5hLmfLonI
Plan: https://dev.to/ericadamski/flawk-live-stream-outline-week-3-3aaa

For this week I will be:

A really important part of any web application is the ability to feed it data. Currently in Flawk I have been hard coding all of the forms. What I would really like is to have the Mongoose models I have already defined, and that hold the context of the systems data, generate the HTML for them selves!

Going to be going deep into [Mongoose](https://mongoosejs.com/) docs. Will be writing a lot of hooks and possibly getting into using some context 🤔. It should be an interesting foray into some more powerful features of JavaScript and the real reasons I love it so much as a language.

By the end of the stream I should:

* Have working forms

Looking forward to seeing y'all on the stream! I will be streaming over here https://www.twitch.tv/ericadamski starting at 9PM EST