teleren/devto huggingface dataset:
Book Review: The art of leadership
Tags: bookreview, leadership, rands
Published: 2020-08-28 16:20:23

---
title: Book Review: The art of leadership
published: true
date: 2020-08-28 00:00:00 UTC
tags: BookReview,Leadership,Rands
canonical_url: https://hceris.com/book-review-the-art-of-leadership/
---

[![The Art of Leadership](https://hceris.com/static/a3e10039bab95a4eac1ab3f94a9bff09/77c11/cover.jpg "The Art of Leadership")](/static/a3e10039bab95a4eac1ab3f94a9bff09/77c11/cover.jpg)

If you have read [Rands in Repose](https://randsinrepose.com/) long enough, this book will ring familiar. _Rands_ has a very particular way of writing about managing humans, as he likes to say. I find it kind of soothing. It’s his third book after [Managing humans](https://www.amazon.com/Managing-Humans-Humorous-Software-Engineering/dp/1430243147) and [Being Geek](https://www.amazon.com/Being-Geek-Software-Developers-Handbook/dp/0596155409). Thematically it is much closer to the first one.

This time around, he’s focused on giving actionable advice, with plenty of items about how to improve communication, run 1on1’s, or make meetings more effective. I’d say that’s the most valuable part of this book. Picking one or two things, and applying them in your regular day-to-day. You don’t need to be a manager for that, just like you don’t need to be a _Lead_ to practice leadership.

How do you actually run a 1on1? Like, in practice. There are plenty of useless generalities out there, such as “you just have to listen”. But what do you do, how do you prepare? I remember when I first started doing regular 1on1s with everybody in my team. I didn’t really know how I was supposed to guide the conversations and, you know, _manage things_. There is a lot of good advice to follow here.

The problem with books that touch on managing or guiding people is that most situations require a lot of context to say something that truly applies to them. _Rands_ has written so much about these topics through the last twenty years that you see the patterns emerging, making it easier to digest.

Which brings me to what I liked the least. _Rands_ has been on many of the most relevant SV companies. In this book, Netscape, Apple, and Slack are specifically mentioned. I bet there are plenty of interesting stories to share, situations that can make all this advice a lot more relatable. But he, as a matter of policy, never speaks about concrete people. So that’s out of the question. It’s understandable but a pity nonetheless. I think the book would benefit a lot from that.

## Verdict

If you have been reading _Rands_ through the years, this book probably won’t tell you anything terribly new. I liked the _How to rands_ section a lot, that’s something that I want to copy.

I only give it ⭐⭐⭐ stars because I feel like I’ve read most of it before. For new readers, I imagine it’ll be a lot more useful.
How to wait for all the fonts to load on a webpage using JavaScript?
Tags: javascript
Published: 2020-08-28 00:00:00

---
  title: How to wait for all the fonts to load on a webpage using JavaScript?
  published: true
  tags: JavaScript
  date: Fri Aug 28 2020 05:30:00 GMT+0530 (India Standard Time)
  canonical_url: https://melvingeorge.me/blog/wait-for-fonts-to-load-javascript
  cover_image: https://melvingeorge.me/_next/static/images/main-167fc015919d1e24738110bb122750b2.jpg
  ---
  [Originally posted here!](https://melvingeorge.me/blog/wait-for-fonts-to-load-javascript)
  
Many times we may want to do some work after all our fonts are loaded on a webpage.

We can do this using the `document.fonts` object.

The object returns another object called `FontFaceSet` in which you can find the `ready` property.

- The `ready` in the `FontFaceSet` is a Promise.

- This promise is resolved only after the fonts in an HTML document is loaded.

Let's write the code to understand it better.

```javascript
document.fonts.ready
  .then(() => {
    // do those operations after
    // the fonts are loaded here
    console.log("Fonts are loaded!!!");
  })
  .catch(() => {
    console.log("Error");
  });
```

Here we have written a `then()` handler to do some operations when our fonts are loaded and a `catch()` handler when there is an error in loading fonts.

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

---
Identity Community Hour - 08/27/2020
Published: 2020-08-27 23:52:15

# Community Hour == YOUR hour

This is the time of the week that we go over your questions, issues and challenges. We also spend some time to to review and promote content that you created. Today's stream was really fun and packed with questions and content that you sent us. You can catch up with our morning session here:

{% youtube CprllaQ5-pE %}

# Community Shout outs
With no guest this week, we were able to focus solely on our community. Check out some of the interesting content we found around the Interwebs

- [Azure AD Sign-In Logs – Managed Identities + Service Principals](https://scomandothergeekystuff.com/2020/08/24/azure-ad-sign-logs-managed-identities-service-principals/)
- [Assigning groups to Azure AD roles and Privileged access groups, a first look!](https://www.vansurksum.com/2020/08/20/assigning-groups-to-azure-ad-roles-and-privileged-access-groups-a-first-look/)
- [Adding an Azure Active Directory User to Azure SQL Database with Automation](https://joeydantoni.com/2020/08/25/adding-an-azure-active-directory-user-to-azure-sql-database-with-automation/)
- [Azure MySQL Audit Logs and Azure AD Authentication Learnings](https://medium.com/microsoftazure/azure-mysql-audit-logs-and-azure-ad-authentication-learnings-cbf11c4a5887)
- [Add Azure AD Auth. to Your Apps with the Microsoft Identity Platform and Microsoft Auth Library](https://www.youtube.com/watch?v=zLgNcDf081s)
- [Secure gRPC service with .NET Core and Azure Active Directory](https://dev.to/425show/secure-grpc-service-with-net-core-and-azure-active-directory-4p6k)

# Friends of Identity - Instafluff
This week we collaborated with [Instafluff](https://twitch.tv/Instafluff), a popular Twitch streamer, as he's embarking on a new project to build his own social network and wants to integrate with Azure AD B2C. You can [catch his stream](https://www.twitch.tv/videos/722098482) and see the steps necessary to integrate Azure AD B2C with his JavaScript solution.

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

# Come code with us
We love streaming and we usually stream live twice a week on Twitch! But what we love more is to collaborate with developers and tackle real world scenarios. As such, if you're interested to code with us, if have questions/challenges that you want us to help you with or simply a suggestion on what to stream, then we would love for you to reach out. Join us live on the [425Show](https://twitch.tv/425Show) :

10a - 1p eastern US time Tuesdays
11a - 12n eastern US time Thursdays for Community Hour

Be sure to send your questions to us here, on Twitter ([Christos](https://twitter.com/christosmatskas), [JP](https://twitter.com/AzureAndChill)) or email: iddevsoc@service.microsoft.com!
I expect you to fix my broken math app...in under 24 hours
Tags: webdev, html, javascript, practice
Published: 2020-08-27 23:52:13

#The HTML is fine
```
<h1>A simple math app</h1>
<form>
  <p><label for="solution">Solve this equation</label></p>
  <span class="operand"></span>
  <span>+</span>
  <span class="operand"></span>
  <span>=</span>
  <input type="tel" id="solution" name="solution" />
  <p id="message"></p>
  <input type="submit" id="solve" value="Solve" />
</form>
```

#The JavaScript is broken
```
// Generate a random number between 1 and 10
function newRandomNumber() {
    Math.ceil(Math.random() * 10);
}
// Assign random numbers to each operand
function generateNewEquation() {
    operands.forEach(
        function (operand) {
            operand.textContent = newRandomNumber;
        }
    }
}
// Show message for wrong answer
function wrongAnswer(solution) {
    message.textContent = `Nope. ${operands[0]textContent} + ${operands[1].textContent} was ${solution}`;
}
// Show message for right answer
function rightAnswer(solution) {
    message.textContent = 'Great job! ${operands[0].textContent} + ${operands[1].textContent} was ${solution}';
}
// Reset and return focus to entry field
function clearEntryField()
    solutionEntry.value = "";
    solutionEntry.focus();
}
// Compare sum of operands to user-entered value
function checkSolution(event, operands, answer) {
    event.preventDefault();
    var solution = Number(operands[0].textContent) + operands[1].textContent;
    solution = answer ? rightAnswer(solution) : wrongAnswer(solution);
    generateNewEquation();
    clearEntryField();
}
// Select necessary DOM elements
var operands = document.querySelectorAll("operand");
var solutionEntry = document.getElementById("solution);
var message = document.getElementById("message");
var solveButton = document.getElementById("solve");
// Add click handler to 'Solve' button
solveButton.addEventListener('click', function(e) {
    checkSolution(e, operands);
});
// Reset/Generate new equation
generateNewEquation();
```

##If you'd rather fork the code instead of copy-paste, here's a CodePen containing the broken code shown above
{% codepen https://codepen.io/beginnr/pen/MWymPqj %}

##Thanks in advance!

*Hint: 11 things are broken*
Day 205: Loads
Tags: hiphop, code, coding, lifelongdev
Published: 2020-08-27 23:47:51

_liner notes_:
- Professional : Had a team meeting and it was good to see everyone. Also reworked some documentation in a tutorial to be a little clearer. Also did more research in for an upcoming blog post. The day flew by quick!

- Personal : Last night, I edited the show recording from Saturday and submitted it to the radio station to be played this week. Also listened through some submitted tracks. Spent the rest of the night working on my side project. I think I got it working but my Chromebook couldn't handle streaming video and screen sharing in 2 different tabs and then viewing that combined stream in yet another browser tab. I may have come up with a way to ease the loads, but need to see if the API can do it.

![Pathway with large moss covered walls on both sides with a small stream running through the center in Ice Age Trail, WI](https://dev-to-uploads.s3.amazonaws.com/i/m94i9t7jeo7zqs37cgjw.png)

After work, I attended the Web Components SF virtual meetup. Some really good presentations and interesting conversations happening in the chat room. Some people even commented that they liked the blog post I wrote on creating Web Components. Felt really cool that people in the community found it to be valuable! Going to do some more research and experimentation to see if I can modify all the streams happening. I want to also go.

Have a great night!

peace piece
Dwane / conshus
https://dwane.io / https://HIPHOPandCODE.com
{% youtube _e4oIEvzXDk %}
[Rails] Getting polymorphic models with human name for view
Published: 2020-08-27 23:09:55

---
title: [Rails] Getting polymorphic models with human name for view
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

## Model

```ruby
class Contracts::Rental < ApplicationRecord
  belongs_to :tenant, polymorphic: true # User, Company
  belongs_to :landlord, class_name: 'Company'
  belongs_to :agency, class_name: 'Company'
  belongs_to :property, polymorphic: true # Properties::Building, Unit, Room

  class << self
    def property_types
      [Properties::Building, Properties::Unit, Properties::Room]
    end
  end
end
```
## I18n

{% link https://dev.to/n350071/rails-i18n-model-name-with-namespace-1h17 %}

## Helper


```ruby
module Contracts::RentalsHelper
  # => [["Building", "Properties::Building"], ["Unit", "Properties::Unit"], ["Room", "Properties::Room"]]
  def property_type_names
    [Contracts::Rental.property_types.map(&:model_name).map(&:human), Contracts::Rental.property_types.map(&:to_s)].transpose
  end
end
```

## View
```erb
  <div class="field">
    <%= form.label 'Property Type' %>
    <%= form.select(:property_type, options_for_select(property_type_names, selected: contracts_rental.property_type)) %>
  </div>
```
Rails I18n model name with namespace
Published: 2020-08-27 22:58:04

---
title: Rails I18n model name with namespace
published: true
description: 
tags: 
//cover_image: https://direct_url_to_image.jpg
---

config/locales/models.en.yml
```yml
en:
  activerecord:
    models:
      user: User
      properties/building: Building
      properties/unit: Unit
      properties/room: Room
```

if you have following models

```ruby
class Properties::Building < ApplicationRecord end
class Properties::Unit < ApplicationRecord end
class Properties::Room < ApplicationRecord end
```
How do you use DEV?
Tags: discuss, productivity, career
Published: 2020-08-27 22:51:55

<span>Photo by <a href="https://unsplash.com/@finesite?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">krisna iv</a> on <a href="https://unsplash.com/s/photos/productivity?utm_source=unsplash&amp;utm_medium=referral&amp;utm_content=creditCopyText">Unsplash</a></span>

---

I have to confess - I have several great articles bookmarked over the past few months that I am still trying to catch up 👩‍💻.

* Do you have a set schedule to catch up with bookmarked articles?
* If tutorials are posted on <a href="https://Dev.to">Dev</a> or any other blogging platform, do you try them out?
* Any best practices around blogging platform(s) usage you would like to share?

Thanks!
Top 5 DEV Comments from the Past Week
Tags: bestofdev
Published: 2020-08-27 20:52:48

---
title: Top 5 DEV Comments from the Past Week
published: true
description: Highlighting some of the best DEV comments from the past week.
tags: bestofdev
cover_image: https://res.cloudinary.com/practicaldev/image/fetch/s--7VrAA2ln--/c_imagga_scale,f_auto,fl_progressive,h_420,q_auto,w_1000/https://thepracticaldev.s3.amazonaws.com/i/qmb5wkoeywj06pd7p8ku.png
---

This is a weekly roundup of awesome DEV comments that you may have missed.  You are welcome and encouraged to boost posts and comments yourself using the **[#bestofdev](/t/bestofdev)** tag.

@rafaacioly shared some helpful tips on what to include in an interview:

{% devcomment 143oc %}

@abdisalan_js doesn't have a simple answer for their favorite database — and that's awesome!

{% devcomment 140af %}

When it comes to learning vs doing, @jessicaward is all about balance

{% devcomment 143le %}

Food replicators and holodecks? Reason enough for me, @rentecjeremy!

{% devcomment 144dp %}

As @brandinchiu says, startup life has pros and cons — but above all else, you need to look after yourself.

{% devcomment 143l9 %}



See you next week for more great comments ✌
Scaling with .NET Core, Shopify's rewrite, and we turn 50 🥳
Tags: performancematters, performance, monitoring
Published: 2020-08-27 22:17:44

Hi folks, 

Welcome to the 50th edition of Performance Matters 🥳 Thanks so much for joining us on this journey and being a valued member of the performance community. 

This week, we have a special [live deployment tracking webinar](https://octopus.zoom.us/webinar/register/9615970848217/WN_P6ebOgWSTbGQ1h-W8Lx87w) focused on performance, we take a look at how Raygun handles hundreds of millions of JS files per month, Shopify's rewrite, and a whole lot more. 

Enjoy! 

Your Curator 

------------------------------

### FEATURED ARTICLES

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

<strong>How Raygun scaled their architecture using .NET Core 3 and Linux</strong>

Take a look at how the engineering team at Raygun rebuilt their sourcemaps worker from the ground up in order to dramatically increase throughput, save costs, and delete 32TB of data 😱 

[How to process hundreds of millions of JS files](https://raygun.com/blog/scaling-rayguns-architecture/?utm_medium=perfmatters&utm_source=email&utm_campaign=scaling_architecture%20&utm_content=blog)

------------------------------

<strong>Shopify – 4x faster with a rewrite</strong>

Learn how Shopify reduced response times, increased resilience and capacity, and invested in their future.

[See the end result](https://engineering.shopify.com/blogs/engineering/how-shopify-reduced-storefront-response-times-rewrite)

------------------------------

<strong>How fast should your site load?</strong>

Go ask Google and you see that 2–5 seconds does the trick... or is it more complicated than that? 

[Why the answer shouldn't be fixed](https://medium.com/firebase-developers/how-fast-should-your-site-load-cfb14be48e8b)

------------------------------

### BUG OF THE WEEK

<strong>Google users frustrated by major worldwide outage</strong>

Experts have claimed that this is the largest failure of Google’s services in its 16-year history.

[Google's largest outage in history](https://digit.fyi/google-users-frustrated-by-major-worldwide-outage/)

------------------------------

### COMMUNITY

<strong>The fastest JSON parsers in the world</strong>

Daniel Lemire shares Version 0.5 bosting better performance under Visual Studio, a new UTF-8 validator (lookup4), better support for C++20, and more...

[Read the thread and check out GitHub](https://twitter.com/lemire/status/1296211367507173377)

------------------------------

<strong>Webinar: Live deployments and performance tracking</strong> 

Learn first-hand how to seamlessly configure deployments, identify issues, and track performance gains.

[Watch live performance monitoring](https://octopus.zoom.us/webinar/register/9615970848217/WN_P6ebOgWSTbGQ1h-W8Lx87w)

------------------------------

If you think Performance Matters is pretty great, why not [sign up](https://performancematters.dev/) to receive it in your inbox every week? 🙌

------------------------------

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

------------------------------
Fast way to enable CORS in Flask servers
Tags: flask, python, cors, react
Published: 2020-08-27 21:39:15

---
title: Fast way to enable CORS in Flask servers
published: true
description: Quicly enable CORS in Flask servers to allow communication via HTTP methods (CREATE, POST, DELETE, etc.)
tags: #flask #python #cors #react
cover_image: https://upload.wikimedia.org/wikipedia/commons/thumb/3/3c/Flask_logo.svg/2560px-Flask_logo.svg.png
---

*Originally published at https://matheustguimaraes.com/blog/flask-cors*

# Fast way to enable CORS in Flask servers

Cross-Origin Resource Sharing (CORS) is a mechanism that uses additional HTTP headers to tell browsers to give a web application running at one origin, access to selected resources from a different origin. A web application executes a cross-origin HTTP request when it requests a resource that has a different origin (domain, protocol, or port) from its own. [[1]](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS)

Lets create a simple Flask server called *app.py*:

```python
from flask import Flask, jsonify


@app.route("/", methods=["GET"])
def get_example():
    """GET in server"""
    response = jsonify(message="Simple server is running")
    return response

@app.route("/", methods=["POST"])
def post_example():
    """POST in server"""
    return jsonify(message="POST request returned")

if __name__ == "__main__":
    app.run(host="0.0.0.0", port="5000", debug=True)
```

If you are building an React app and using axios library, GET requests to server will look something like this:

```js
import axios from "axios"

const apiURL = "http://localhost:5000"

axios
    .get(apiURL)
        .then((response) => {
            setState(response.message);
        })
    .catch((error) => {
        console.log(error);
    });
```

But without CORS enabled, the browser will block the server's response for security reasons. To receive data using a React application, CORS must be enabled.

To enable CORS in GET responses on the server, you can simply add a header in response:

```python
@app.route("/", methods=["GET"])
def get_example():
    """GET in server"""
    response = jsonify(message="Simple server is running")
    
    # Enable Access-Control-Allow-Origin
    response.headers.add("Access-Control-Allow-Origin", "*")
    return response

```

After ```response.headers.add("Access-Control-Allow-Origin", "*")```, all GET requests will be accepted.

To enable requests like POST, PUT, DELETE, etc., the easiest way is to install *Flask-CORS* (https://flask-cors.readthedocs.io/en/latest). To install Flask-CORS using pip:

```sh
pip install flask-cors
```

In an example of a POST request, simply add the decorator @cross_origin in the function beginning:

```python
@app.route("/", methods=["POST"])
@cross_origin()
def post_example():
    """POST in server"""
    return jsonify(message="POST request returned")
```

There you go. Now your React app can communicate, receive and send information to the server using all HTTP methods, including POST, PUT, DELETE and more.

Have a nice day!

*Follow me on https://twitter.com/matheusguimr to talk more about web development :)*
GNU tree annoyed me so I fixed it
Tags: shell, perl
Published: 2020-08-27 21:33:50

---
title: GNU tree annoyed me so I fixed it
published: true
description: A small shell function and perl script to make GNU tree more usable
tags: shell, perl
//cover_image: https://direct_url_to_image.jpg
---

The `tree` utility is incredibly useful, but sometimes it can be just too verbose. Often you want to see a tree of some directory with exceptions - for example, you might have a sub-directory full of your project's dependencies that you have no interest in seeing.

To solve that problem `tree` has the `-I` option. My project's dependencies generally live in a `local/` directory, so I can exclude it thus:

    tree -I local

Now, what if I want to exclude something else as well, such as hiding my tests too. You would think that you could do this:

    tree -I local -I t

But no. It only pays attention to one `-I` argument. Specifically, it only cares about the last one. If you want to ignore multiple directories you need to combine them into a *pattern*:

    tree -I local|t

Except that doesn't work, the shell will interpret that as piping the output from `tree -I local` into `t`. You need to escape the pipe character:

    tree -I local\|t

This is all a bit of a pain. Add to that that you can't set defaults in an environment variable or a configuration file, so I generally find myself forgetting to say `-I` at all and then having to do it again when my screen is filled with unwanted gibberish.

So I've [fixed it with a shell function](https://github.com/DrHyde/configurations/blob/08b4b6264e22a0a52c19b663ed73ef807cd8b53f/bash/dot-bash_functions.d/tree). That function will automatically apply any defaults that are in `~/.treerc` (you can see mine [here](https://github.com/DrHyde/configurations/blob/08b4b6264e22a0a52c19b663ed73ef807cd8b53f/dot-treerc)), and will combine multiple `-I` arguments into one.

It also lets you say `-I \$FIGNORE` as a special case to ignore anything mentioned in that specific environment variable. The env var is normally used to tell the shell what files to ignore when doing tab-completion, but I figure that, combined with per-project environment variables controlled by [direnv](https://direnv.net/) it's a reasonable place to put such data. I may change that later though.

The argument processing is done in perl, as it's far easier to do in that language than in the shell, but it doesn't do a complete job because I'm lazy. In particular if you combine arguments in an invocation like this:

    tree -ahI foo

then it won't spot that and give the `-I` in there the correct treatment. Patches welcome!