Instantly share code, notes, and snippets.

View jsconfig.json
{
"compilerOptions": {
"baseUrl": "./src/",
"target": "es6",
"jsx": "react",
"module": "commonjs"
},
"include": ["src/**/*"]
}
View limit-goroutines.go
concurrency := 10 // 10 is max concurrency
sem := make(chan bool, concurrency)
urls := []string{"url1", "url2"}
for _, url := range urls {
sem <- true // mark one as running (will block when full)
go func(url) {
defer func() { <-sem }() // mark one as completed
// Do something with the url
}(url)
}