teleren/devto huggingface dataset:
Beware of Promise.all
Tags: javascript, typescript, performance
Published: 2021-10-28 18:26:46

In Javascript, `Promise.all` lets you execute a bunch of Promises in parallel and get an array of results back.

```js
const responses = await Promise.all([
  fetch("/api/1"),
  fetch("/api/2")
])
```

Pretty straight forward.  However, if you were to do the above with 100 fetch calls instead, you might accidentally take down your server in a self-inflicted Denial of Service attack. Even if you protect against this in the API with rate-limiting, you're still going to see a lot of errors for failed requests as you scale up.

APIs are the exception.  Most types of external calls have no concept of rate-limiting at all - filesystem operations, system calls, etc.

For example, in NodeJS you can spawn new shells to call out to other programs on the computer. I use this in my open source A/B testing platform [GrowthBook](https://github.com/growthbook/growthbook) to call a Python script.  Something like this:

```js
const results = await Promise.all(
  metrics.map(m => callPython(m))
)
```

The above will happily spawn hundreds of Python shells if given a large array and start executing them all in parallel. My dev machine is pretty powerful, so I didn't notice during testing that all 8 CPU cores would go to 100% for a couple seconds. When I deployed the code to a Docker container on AWS though, I definitely noticed when it started crashing and restarting all the time.

The solution is to add rate-limiting or concurrency limits to your `Promise.all` calls.  There are a few ways to do this.

For API calls where you want to limit the number of calls per second, you can use the simple [p-throttle](https://github.com/sindresorhus/p-throttle) library:

```js
import pThrottle from 'p-throttle'

// Limit to 2 calls per second
const throttle = pThrottle({
  limit: 2,
  interval: 1000
})

const responses = await Promise.all([
  throttle(() => fetch("/api/1")),
  throttle(() => fetch("/api/2")),
  ...
])
```

For system calls where you want to limit the number of parallel executions, no matter how long they take, there is the simple [p-limit](https://github.com/sindresorhus/p-limit) library:

```js
import pLimit from 'p-limit'

// Only 5 promises will run at a time
const limit = pLimit(5)

const results = await Promise.all(
  metrics.map(
    m => limit(() => callPython(m))
  )
)
```

For more advanced use cases, you might want to look into using a full-featured job queue instead like [bree](https://github.com/breejs/bree), [bull](https://github.com/taskforcesh/bullmq), or [agenda](https://github.com/agenda/agenda).

As developers we spend a lot of time worrying about external attacks and not enough time on protecting our apps from naive internal code.  I hope this helps others avoid the same CPU crashing bugs in production that I had to work through. Good luck out there!
My first PR in hacktoberfest 2021
Tags: hacktoberfest
Published: 2021-10-28 18:06:27

Hello every, my name is Dustin. I'd like to talk about my experience of solving very first and simple issues on github that are labelled as hacktoberfest 2021. 

## Reasons
The reason behind why I decided to contribute to open sources project is because I will learn a bunch of new things and coding styles.

## First pull request
My very first pull request was pretty simple and short in terms of coding but reading the code and finding where it is to fix was difficult enough. 

The project can be found [here](https://github.com/code4romania/seismic-risc)
My pull request can be found [here](https://github.com/code4romania/seismic-risc/pull/748)

## Detail
Interesting enough though, when I understood the issue clearly and started to fork the project, I got into a problem where I cannot clone the project locally. You can find the issue [here](https://github.com/code4romania/seismic-risc/issues/746) but it turned out that there a little space after a file name. A project maintainer resolved it immediately so that I could clone the project.

The issue was actually about a url link. There's a few buttons that allow users to copy, or share the post on their social platforms. But the link was assigned to a static url that points straight to the main landing page. So what I did was that I pull the current url off of `window.location.href` and set it to the URL. Every worked just fine. The process of fixing code was quite easy but I had to go through a lot of files and folders to find the issue because this project is quite huge. 

```js
const URL = 'https://seismic-risc.now.sh';
```

to

```js
const URL = window.location.href;
```
Hacktoberfest - Working with Swift
Tags: opensource, swift
Published: 2021-10-28 18:04:09

# Project Introduction
👉 Since starting of this semester, I took an IOS app development class. I was impressed by how XCode is convenient for the user to build the app interface, it is like dragging and dropping things in Adobe Photoshop.

👉During the Hacktoberfest month, I wanted to work on an open source app in Swift language to explore how the IOS app truly works in the real world.

👉The project is about Bookmark containing saved important links with categories for user to read them later. You can take a look at its [GitHub Repo](https://github.com/ACM-VIT/sticky-links) or my [Folked Repo](https://github.com/kiennguyenchi/sticky-links).

# Project Issue
❓I took an issue to add favorite feature to the app. With the following links display, whenever an user clicks on the bookmark button besides it. It would pin to the top of the list 

👉I spent hours to read through the project for to find where to put my code in, run the Simulator to see how the app works.

👉I took me a lot of time to complete this project since I don't have a Mac yet, it is inconvenient to work with IOS app because XCode serves Mac user only. I had to borrow a Mac from my friend, installed the Xcode 12GB with my slow Internet connection, wrote the code, ran it, returned to her and borrowed back one day.

🔗This is my filing [Issue](https://github.com/ACM-VIT/sticky-links/issues/2) on GitHub.

# Project Process
I knew that what I have exactly to do. First step, I needed to get the data from the view, the table cell data and its index.

```
var linkView = sender.superview
while let view = linkView, !(view is UITableViewCell) {
     linkView = view.superview
}
guard let tableCell = linkView as? UITableViewCell else {return}
guard let indexPath = tableView.indexPath(for: tableCell) else {return}
```
Next, I needed to remove the link from the current index, which was currently showing on the screen.

```
let link = self.links[indexPath.row]
self.links.remove(at: indexPath.row)
```
Next, I needed to insert it at index 0, because after I added it to the bookmark, it would stay on top of the list.
```
self.links.insert(link, at: 0)
```
In final step, I needed to save my modification and reloaded the interface.
```
self.saveLink()
self.tableView.reloadData()
```

🔗This is my [Pull Request](https://github.com/ACM-VIT/sticky-links/pull/32) on GitHub.

# Conclusion
👉The owner of this repo is so slow in replying, which sometimes inconvenient to me to interact. It may take up to a week for a reply.

👉Overall, it is fantastic to work on an actual open source IOS app in the real world. I can see some very similar code structures and designing tools that I learnt in class. Wanna keep falling in love with Swift and Xcode, I really need to save money to get a Mac.

✔️During the Hacktoberfest, I worked with total 4 different programming languages/framework, which would make me so excited about open source programming. I had try Rust, Vue, React and Swift, very unfamiliar to me a month ago, but familiar now.
Hacktoberfest 2021 with QuestDB community
Tags: hacktoberfest, opensource, sql
Published: 2021-10-28 18:03:01

##### QuestDB is the fastest open source time series database. Key features : 

<li> Reduce hardware costs

<li> Contain operational complexity

<li> Decrease development costs

<li> Cloud native (AWS, Azure, GCP)

<li> On-premises or embedded

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5ekcgqohs46mz0phdawg.jpg)

 
### Hacktoberfest 2021 with QuestDB!
QuestDB is participating as an open source project. We're super excited to meet with other open source contributors and maintainers.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4vf2j5kvsjgse59ffv44.png)

<br>
 
As a way of saying "thank you" for being part of the journey, we want to offer contributors some of our stickers, pins, t-shirts, and awesome virtual swag.

##### Level 1

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rudlphx77mva1e79fs7v.png)


Show the love
To claim your swag for the this level:

<li> You have starred QuestDB GitHub repository - https://github.com/questdb/questdb

<li> You have watched our Stack Overflow tag - https://stackoverflow.com/questions/tagged/questdb

<li> You have joined our Community Slack - https://slack.questdb.io/

##### Level 2

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/c6vtswdjaiuy7a0ht5w8.png)


Open-source contributor
To claim your swag for the this level:

<li> You have asked or answered a question on Stack Overflow with the QuestDB tag

<li> You have opened a valid GitHub issue or Pull Request

##### Level 3

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/n0elvmfhxa12ut5x71lv.png)

<br>



Dedicated to the Quest
<li> To claim your swag for the this level:

<li> You have written a tutorial or guide using QuestDB

<br>

How can you claim swag?

<br>

Fill out the swag request form https://docs.google.com/forms/d/e/1FAIpQLSfI3VUwXpHT1TbZYjUkYFQpuyfhWicWu2zA0NBGP0pO3ImITA/viewform with required information. And our team will validate your request!
DevNews Season 6 is Here!
Tags: news, podcast
Published: 2021-10-28 17:56:48

---
title: DevNews Season 6 is Here!
published: true
description: Listen to S6E1 of the DevNews pod wherever you get your podcasts.
tags: news, podcast
series: DevNews Season 6
cover_image: https://dev-to-uploads.s3.amazonaws.com/i/zoxvbu0494gq3sxtjp4v.png
---

We're back with an all-new season of DevNews — and we can't wait for you to hear it!

{% podcast https://dev.to/devnews/s6-e1-vs-code-in-the-browser-facebook-internal-documents-and-corporate-open-source %}

**Hosts:** @saronyitbarek & @joshpuetz 

**Guests:** 
- [Brigit Murtaugh](http://twitter.com/@BrigitMurtaugh), Microsoft, Visual Studio Code team - Program Manager II
- [João Moreno](http://twitter.com/@joaomoreno), Principal Software Engineer on the Visual Studio Code team at Microsoft

In this episode, we talk about the explosive Facebook internal documents, a merger between Ruby Central and Ruby Together, and the short lived removal of .NET’s Hot Reload feature, which had a lot of developers frustrated and confused by the decision. Then we speak with Brigit Murtaugh, Program Manager II at Microsoft, and João Moreno, Principal Software Engineer for VS Code about how they created a new lightweight version of VS Code that can run fully in the browser.


---

_You can [follow DevNews](dev.to/devnews) to get episode notifications and listen right in your feed_ _— or subscribe on your platform of choice! Plus, if you leave us a review, we'll send you a free pack of thank-you stickers. Details [here](https://airtable.com/shr8oKAIMZgdYnBxx)._ 

## **Quick Listening Links**
- [Apple Podcasts](https://podcasts.apple.com/us/podcast/s6-e1-vs-code-in-the-browser-facebook-internal/id1525581923?i=1000539986709)
- [Spotify](https://open.spotify.com/episode/4y8jtmrVSzVj4ZhvYqsUJO)
- [Google](https://podcasts.google.com/feed/aHR0cDovL2ZlZWRzLmNvZGVuZXdiaWUub3JnL2Rldm5ld3NfcG9kY2FzdC54bWw/episode/aHR0cHM6Ly9kZXZwb2RzLmRldi9wb2RjYXN0cy9kZXZuZXdzLzQx?sa=X&ved=0CAQQkfYCahcKEwiorZ7U1u3zAhUAAAAAHQAAAAAQCg)
- [Stitcher](https://www.stitcher.com/show/devnews/episode/s6-e1-vs-code-in-the-browser-facebook-internal-documents-and-corporate-open-source-87858653)
- [Listen Notes](https://www.listennotes.com/podcasts/devnews/s6e1-vs-code-in-the-browser-slWf0MHLv49/)
- [TuneIn](https://tunein.com/podcasts/Technology-Podcasts/DevNews-p1352512/?topicId=167233431)
- [RSS Feed](http://feeds.codenewbie.org/devnews_podcast.xml)
- [DEV Pods website](https://devpods.herokuapp.com/podcasts/devnews/episodes/226)

#### _Acknowledgements_ 
- _@levisharpe for producing & mixing the show_ 
- Our Season 6 Sponsor: [Cosmos HackAtom](https://www.hackatom.org/)


We hope you enjoy this kickoff to a new season of DevNews 📰
Get favicons from any domain using a hidden google API
Tags: webdev, tooling, todayilearned
Published: 2021-10-28 17:36:04

Did you know ?

Google offers a secret URL that can automatically pull the favicon image of any domain. Cherries on the cake, we can ask for different sizes and the images returned are in PNG format (not ICO), meaning they will render correctly in all browsers using the `<img>` tag.

The API works using a simple GET:
```bash
https://www.google.com/s2/favicons?domain=${domain}&sz=${size}
```

The query parameters are:
* `domain`: *mandatory*, the domain you are interested in,
* `sz`: *optional*, a size hint such as `256`.

In case the right size is not found, it will return the default one, usually 16x16.

-----

https://www.google.com/s2/favicons?domain=dev.to&sz=128
![128x128](https://www.google.com/s2/favicons?domain=dev.to&sz=128) 

https://www.google.com/s2/favicons?domain=dev.to&sz=512 (nothing found for 512x512, so returns a 16x16 PNG)
![16x16 fallback](https://www.google.com/s2/favicons?domain=dev.to&sz=512)


https://www.google.com/s2/favicons?domain=stackoverflow.com&sz=128 (yep, sometimes the quality is far from optimal)
![stackoverflow 128x128](https://www.google.com/s2/favicons?domain=stackoverflow.com&sz=128)
Implement a Docusaurus Feature
Tags: opensource
Published: 2021-10-28 17:32:27

# Introduction
This week, I'm working on my Static Site Generator (SSG) - [Potato Generator](https://github.com/kiennguyenchi/potato-generator) to add a new feature for it.

I was introduced a new tool, which is Docusaurus. It has several useful functionalities that can be used to implement a website such as supporting React components, Themes, Plugins, Markdown support,... It took me a while to download the Docusaurus app, tried to publish it on my own and explored the features. It was interesting, you can take a look at my [Docusaurus Demo Website](https://kiennguyenchi.github.io/knc-docusaurus-website/index.html). 

I picked Syntax Hightlighting for code block to implement into my SSG. For many programmers, it is needed to have this function in your SSG because every programmer would have the code block in any of their documents.

# Process
I broke down the tasks into 2 issues to solve: Identify code block and style for code block.

In order to identify the code block, I wrote code to notice the appearance of code block when I write the output to HTML file. Whenever there is an open syntax of code block, I would put the code following until finding close syntax of code block into a div container.

This is the result after identifying the code block and write them to HTML.
![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/0tu2r09mq6w9vvuoucdv.JPG)

After that, I changed the style for the div container to have black background, white text with normal fonts. It would look more similar like a code block.

Here is the result after modifying the style.
![](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/h5sg1tedywhdpncl3czd.JPG)

Whenever there is a code block input into my program, it would be exported to HTML in the following format:

```
<div style='background-color: black; color: white;'>

<p style='font-family:Consolas;'> int main(){</p>
<p style='font-family:Consolas;'> cout << "Hello World";</p>
<p style='font-family:Consolas;'> }</p> 

</div>
```

# Conclusion
Overall, I felt interesting to implement such an useful feature like this. I would like to improve my SSG with more useful functionalities like this in the future.

Looking at my [commit](https://github.com/kiennguyenchi/potato-generator/commit/bdc9ca305d581675a9c972e86863e96b7a4596fb) of new code block feature on SSG.
Starting a technical blog
Published: 2021-10-28 17:13:39

---
title: Starting a technical blog
description: Decision to start a technical blog
tags: ''
cover_image: ''
canonical_url: null
published: true
id: 880052
date: '2021-10-28T17:13:39Z'
---
# Starting a Blog

I have decided to start a technical blog. This will be a combination of tutorials, opinions and anecdotes of my experience of 20 years working in software.
Hopefully the content will be of use to someone.

{% user jonashdown %}
Filament Hero : Update!
Tags: nextjs, javascript, webdev, tailwindcss
Published: 2021-10-28 17:12:47

Hello everyone! 👋🏻

I just wanted to give an update on Filament Hero and the progress made due to Hacktoberfest! 

At the beginning of the month, I posted an [article](https://dev.to/cdthomp1/my-hacktoberfest-repos-2121) outlining a couple of my repos that will be participating in Hacktoberfest. This led to some great contributions to Filament Hero during the month! 

## What Progressed?
### New Design 📐
When I was getting ready for Hacktoberfest, I decided to dedicate some time to polish the design for Filament Hero, mainly on the "backend". I worked out exactly what I wanted the application to do as well as what type of data models to create. 

#### New Models 📝
I looked at my existing models and realized I can achieve a lot more if I added a few more properties. Updating and adding these new models will allow Filament Hero to be a better application to those who use it by keep track of more data as well as more metrics as well.

#### New CRUD Methods 🚀
With the new models, I needed new CRUD methods to match them. While doing so, I realized that MongoDB may not be the best choice, which lead me to ask the community what a better DB would be. I am currently still researching and experimenting different DB and ORM providers and I will provide an update with my results. 

### Newer Look 🔥
I also played around with a newer look and feel with Filament Hero. I updated the data table and added toast notifications when the users creates, updates, or deletes a printer, filament, print, ect. While working on the data table, I noticed that the table gets very wide, especially on small screens, that makes it difficult to view all the information. My question to you is, is there a better way to present the data to the user. For example, to display a list of cars in a fleet with their current status and maintenance data I would normally create a table with all the properties having their own column. Do you just have a side scrolling table on mobile screens? Omit data on small screens? Is there a design pattern I should learn?

That is all that has happened to Filament Hero this month. I am grateful to those who participated in getting Filament Hero further in its development! If you would like to follow along with the development, or want to participate, please checkout [FilamentHero.com](https://filamenthero.com)!
What is your favorite Vim color schemes?
Tags: vim, javascript, react, programming
Published: 2021-10-28 17:07:02

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/eszde9b2f7e9i8y5qxml.png)

Vim is my favorite text editor. There are tons of color schemes for this famous editor that you can find on https://vimawesome.com/ and https://vimcolorschemes.com/

My beloved color scheme is "kolor" (https://github.com/zeis/vim-kolor). I love it not only because of its simple mix of low contrast colors but also because that color scheme is dedicated to the Ugandan children, a very meaningful and respectful activity of Vim community.

How about you? What is your favorite Vim color scheme?

(My new personal project for educational purpose with MERN stack:
https://github.com/linhtch90/bn_bookstore_public_source
Live Demo: https://bn-bookstore.herokuapp.com/#/)
Commit case-sensitive only filename changes in Git
Tags: git, github, webdev
Published: 2021-10-28 16:53:54

Suppose you have a folder name `Dashboard` you changed it to `dashboard` default configuration git doesn't recognize that change. Same things happens to files.

For that need to clean the cache, after struggle few hours I found a simple workable solution.

Here it is 

```
git rm -r --cached .
git add --all .
git commit -a -m "Versioning untracked files"
git push
```
[source Issue](https://stackoverflow.com/questions/17683458/how-do-i-commit-case-sensitive-only-filename-changes-in-git)
Live From INTERACT: Engineering Leadership Screwups
Tags: leadership, career, devops, podcast
Published: 2021-10-28 16:41:14

Have you ever had to manually book 50,000 flights because you rushed to deliver new features on your product?

In this episode of the Dev Interrupted podcast, we asked some of our favorite engineering leaders if they could share memorable stories of professional mistakes with our audience.

The great thing about opening up about past mistakes is that it normalizes failure. All of us will make decisions that we come to regret - the best we can do is learn and grow from them. This is especially true of people in leadership positions who are responsible for managing teams.

In what will be the last podcast episode to feature excerpts from our INTERACT engineering leadership conference, Conor Bronsdon, Dev Interrupted Community Leader, presents a three-part interview he performed for audiences at INTERACT.

We applaud Luca Rossi, Head of Engineering at Translated; Shweta Saraf, Senior Director of Engineering at Equinix; and Chris Downard, VP of Engineering at GigSmart, for their candid, open responses about professional moments of failure.

{% spotify spotify:episode:1sI2kR1gWCZKTexNR8KTid %}

## Episode Highlights Include:
* The difference between agile and underdeveloped
* How to be honest with yourself when you a mistake
* Adapting to change as new information becomes available
* Inspiring your team after you make an unpopular decision

## Join the Dev Interrupted Community
With over 1900 members, the Dev Interrupted Discord Community is the best place for Engineering Leaders to engage in daily conversation. No sales people allowed. [Join the community >>](https://discord.com/invite/devinterrupted)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jkp4kf4dubb2dbfpam81.png)