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 multiply = (n, l) => l.map(a => Math.round(a / (1 / n))); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 http = require('http') | |
const {parse} = require('url') | |
/** | |
* This example is a simple implementation of a wrapper the Node.js http server. | |
*/ | |
class Router { | |
#routes |
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 topWords(text, count = 3, lang = 'en') { | |
const wordMap = new Map(); | |
const segmenter = new Intl.Segmenter(lang, { granularity: 'word' }); | |
for (let { segment, index, isWordLike } of segmenter.segment(text)) { | |
if (!isWordLike) continue; | |
const word = segment; | |
wordMap.set(word, (wordMap.get(word) || 0) + 1); | |
} | |
return Array.from(wordMap) | |
.sort(([, countA], [, countB]) => countB - countA) |
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 test(strings, name, age) { | |
const str0 = strings[0]; | |
const str1 = strings[1]; | |
return `${str0}${name}${str1}${age}`; | |
} | |
const name = 'Rustam'; | |
const age = 25; | |
console.log(test`My name is ${name} my age is ${age}`); |
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
WITH RECURSIVE tree AS (SELECT *, id AS root_category | |
FROM categories | |
WHERE parentId IS NULL | |
UNION ALL | |
SELECT c.*, p.root_category | |
FROM categories c | |
JOIN tree p | |
ON c.parentId = p.id) | |
SELECT * | |
FROM tree |
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
import { Prisma, PrismaClient } from '@prisma/client'; | |
import { exec } from 'child_process'; | |
import * as util from 'util'; | |
const execPromisify = util.promisify(exec); | |
const prisma = new PrismaClient(); | |
const tables = Prisma.dmmf.datamodel.models | |
.map((model) => model.dbName) | |
.filter((table) => table); |