This file contains 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
package dynamicmultireader | |
import "io" | |
var EOF = io.EOF | |
type dynamicMultiReader struct { | |
currentReader io.Reader | |
newReaderFactory NewReaderFactory | |
closeHandler CloseHandler |
This file contains 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
/** | |
* Escapes pattern-characters of LIKE and ILIKE operators. | |
* | |
* @example | |
* query('SELECT * FROM articles WHERE title LIKE $1', [ '%' + escapePostgresLikeOperator(searchString) + '%' ]) | |
* | |
* @param input {string} string to escape | |
* | |
* @returns {string} the string to use in LIKE/ILIKE clause | |
*/ |
This file contains 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
// get-books-headers.dto.ts | |
import { Contains } from 'class-validator'; | |
class GetBooksHeadersDto { | |
@Contains('en') | |
'accept-language': string; | |
} | |
// books.controller.ts | |
import { HeadersWithValidation } from './headers-with-validation.decorator.ts' |
This file contains 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
#include <stdio.h> | |
int main() | |
{ | |
int a, b, c, d; | |
int count = scanf("%d %d", &c, &d); | |
b = (c + d) / 2; | |
a = c - b; | |
printf("%d %d", a, b); | |
return 0; |
This file contains 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
const { promisify } = require('util'); | |
const fs = require('fs'); | |
const path = require('path'); | |
const readDir = promisify(fs.readdir); | |
const lstat = promisify(fs.lstat); | |
async function traverseDir(dir, first) { | |
// рекурсивный перебор файлов | |
const files = await readDir(dir); |
This file contains 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
function alg(arr) { | |
const maxFreqNum = findMaxFreqNum(arr) | |
const firstIndex = arr.indexOf(maxFreqNum) | |
const lastIndex = arr.lastIndexOf(maxFreqNum) | |
const contiguousArr = arr.slice(firstIndex, lastIndex+1) | |
return contiguousArr.length | |
} |