This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Type } from '@nestjs/common'; | |
import { defer, lastValueFrom, switchMapTo, throwError, timer } from 'rxjs'; | |
import { catchError } from 'rxjs/operators'; | |
export function withRetry< | |
T, | |
F extends (...args: any[]) => Promise<T>, | |
>(options: { retries: number; exceptErrors?: Type<Error>[]; fn: F }): F { | |
return (async (...args) => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function withRateLimit<T, E extends (...args: any[]) => Promise<T>>({ fn, limit, every }: { | |
fn: E, | |
// maximum amount of executions in specific amount of time | |
limit: number, | |
// the amount in milliseconds we are limiting the total amount of executions | |
every: number | |
}): E { | |
let lastExecTime = -1; | |
let requestCounter = 0; | |
let triggerFlushTimeout = null; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function getItems() { | |
const requestTime = new Date(); | |
const response = await fetch('http://myservice/items'); | |
const items = (await response.json()) as { id: string; price: number }[]; | |
const responseTime = new Date(); | |
return { | |
items, | |
requestTime, | |
responseTime, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { defineConfig } from 'cypress'; | |
let codeCoverageEnv = {}; | |
// make sure code coverage is enabled | |
if (process.env.CODE_COVERAGE_ENABLED === 'true') { | |
codeCoverageEnv = { | |
codeCoverage: { | |
url: `${ | |
process.env.cypress_baseUrl || 'http://backend:9001' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env sh | |
SSH_HOST=host.name | |
BACKUP_DISK="sda" | |
DISK_SIZE_BYTES=`expr 1073741824 \* $(ssh $SSH_HOST "lsblk --all | grep \"$BACKUP_DISK\" | head -1" | while read c1; do echo $c1; done | cut -d" " -f4 | sed "s/G//g")` | |
BLOCK_SIZE=512 | |
IMAGE_NAME="./sda.disk" | |
[ -f $IMAGE_NAME ] && IMAGE_CUR_SIZE=$(stat -c "%s" $IMAGE_NAME) || IMAGE_CUR_SIZE=0 | |
WRITEN_BLOCKS=$(($IMAGE_CUR_SIZE / $BLOCK_SIZE)) | |
echo -e "Current clone file size: \e[1m$IMAGE_CUR_SIZE\e[0m, total remote disk size: \e[1m$DISK_SIZE_BYTES\e[0m" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# MariaDB 10.1 CentOS repository list - created 2016-02-13 07:56 UTC | |
# http://mariadb.org/mariadb/repositories/ | |
[mariadb] | |
name = MariaDB | |
baseurl = http://yum.mariadb.org/10.1/centos7-amd64 | |
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB | |
gpgcheck=1 |