url: /states/IN/counties/12345
folder structure:
/pages
/states
/[state]
/counties
[county].tsx
index.tsx
Get-ChildItem -Path "." -Include "node_modules" -Recurse -Directory | Remove-Item -Recurse -Force |
type PromiseGenerator<T> = () => Promise<T>; | |
interface PromiseResult<T> { | |
status: 'fulfilled' | 'rejected'; | |
value: T | Error; | |
} | |
/** | |
* Executes a list of promise-generating functions with a specified maximum concurrency, | |
* returning a promise that resolves to an array of results. Each result includes the |
import express from 'express'; | |
import requestTimeout from 'connect-timeout'; | |
express() | |
.get( | |
'/long-running', | |
requestTimeout('3s', { | |
respond: false, | |
}), | |
(req, res) => { |
const alpha = 'abcdef'.toUpperCase().split(''); | |
const randomNumber = () => Math.floor(Math.random() * 10).toString(); | |
const randomLetter = () => alpha[Math.floor(Math.random() * alpha.length)]; | |
const randomCharacter = () => Math.random() > 0.5 ? randomLetter() : randomNumber(); | |
function generateOtp(length = 6) { | |
return Array.from({ length }, randomCharacter).join(''); | |
} | |
const pass = generateOtp(); |
// https://www.typescriptlang.org/play?#code/IYZwngdgxgBAZgV2gFwJYHsIwA4Cd0C2qIApgIIA2FAFAJQwDeAUDKzFJiMjACbDIkYAXhgQSAdxgARfiToBuFm2DjgqbgAV8RUgDpgVagG0lbNmMlbCxOdVwkQ6CgDcS9IQD5GpszFLIAFVQCEnQEZDsHJ1cAGhgAJgAGZNpFXzYAX1oYnzMLGCsdW3tHFzdhL2Z09P8gkLCIkuiSOKSUtOqsgF0fVJ8OCFKSXQp0AHNqAAMDChhkdHQAaxgAEgZ8mQE6XWcDBBIAeTg6GABaXlkdvcPj2gyCEEnaJiYMl9BIWEQUDCxSAEd9hA0AYTlU2AMuBcBMJRBJpLIFD4VGpuPlCjZqJFSq53JVcmxasFQuFsc1WslEn0zFkOqwUeo4ZZtJiyWU8d5qn4SIFiQ02bEEpTqZkRaxIU5hqMJpNSLhUAY5gtlmsNojaFcKPsjidznwBJrtbd7o9nm8mNQPtAYCdPJzlKpGXhrKRKDQxTAGdwAUCQe7FFkFEA | |
async function promiseAll() { | |
const date = new Date(); | |
await Promise.all([ | |
new Promise((resolve) => { | |
setTimeout(resolve, 2000); | |
}), | |
new Promise((resolve) => { | |
setTimeout(resolve, 2000); |
url: /states/IN/counties/12345
folder structure:
/pages
/states
/[state]
/counties
[county].tsx
index.tsx
netstat -p TCP -fan | Select -Skip 4 | ForEach { | |
$Properties = $_.Trim() -split '[\s]+' | |
[PSCustomObject]@{ | |
'Proto'= $Properties[0] | |
'Local Address'= $Properties[1] | |
'Foreign Address'= $Properties[2] | |
'State'= $Properties[3] | |
} | |
} | Select -Expand 'Foreign Address' |
Get-ChildItem -Recurse -Filter *.csv | Where-Object {$_.LastWriteTime -gt (Get-Date).AddDays(-1)} | Remove-Item -Force -Recurse -ErrorAction SilentlyContinue |
// inspired by https://schneidenbach.gitbooks.io/typescript-cookbook/content/nameof-operator.html | |
/** Ensure the string value is a valid property name of type `T` */ | |
function propName<T>(name: keyof T): string { | |
return name.toString(); | |
} | |
/** Ensure the string value is a valid property name of instance of type `T`. */ | |
function propOf<T>(instance: T, name: keyof T): string { | |
return propName<T>(name); |
Windows:
netstat -aon | findstr '8080'
powershell Get-Process -Id (Get-NetTCPConnection -LocalPort 8080).OwningProcess