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 { Controller, Get, Inject, Injectable, Module, Scope } from "@nestjs/common"; | |
import { | |
ContextId, ContextIdFactory, ContextIdResolver, ContextIdResolverFn, ContextIdStrategy, | |
HostComponentInfo, ModuleRef, NestFactory, REQUEST | |
} from "@nestjs/core"; | |
import { NestExpressApplication } from "@nestjs/platform-express"; | |
// Context strategy | |
const tenants = new Map<string, ContextId>(); | |
export class TenantContextIdStrategy implements ContextIdStrategy { |
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
ssh -L 3000:localhost:3000 your-non-root-user@yourserver-ip |
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
String.prototype.toPersianDigit = function (a) { | |
return this.replace(/\d+/g, function (digit) { | |
var enDigitArr = [], peDigitArr = []; | |
for (var i = 0; i < digit.length; i++) { | |
enDigitArr.push(digit.charCodeAt(i)); | |
} | |
for (var j = 0; j < enDigitArr.length; j++) { | |
peDigitArr.push(String.fromCharCode(enDigitArr[j] + ((!!a && a == true) ? 1584 : 1728))); | |
} | |
return peDigitArr.join(''); |
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 const parallel = (...fs) => sequential( | |
() => fs.map(f => f()), | |
Promise.all.bind(Promise)); | |
export const sequential = (f, ...fs) => val => Promise.resolve() | |
.then(() => f(val)) | |
.then(fs.length ? sequential(...fs) : id => id); |
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
--log_gc (Log heap samples on garbage collection for the hp2ps tool.) | |
type: bool default: false | |
--expose_gc (expose gc extension) | |
type: bool default: false | |
--max_new_space_size (max size of the new generation (in kBytes)) | |
type: int default: 0 | |
--max_old_space_size (max size of the old generation (in Mbytes)) | |
type: int default: 0 | |
--max_executable_size (max size of executable memory (in Mbytes)) | |
type: int default: 0 |
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
//////////////////// | |
// Exclude | |
//////////////////// | |
type MyExclude<T, L> = T extends L ? never : T; | |
type TestExclude = MyExclude<"a" | "b" | "c" | "d", "a" | "b"> | |
//////////////////// | |
// Extract | |
//////////////////// | |
type MyExtract<T, L> = T extends L ? T : never; |
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
version: "3.7" | |
services: | |
unleashDB: | |
expose: | |
- "5432" | |
image: postgres:13 | |
container_name: unleashDB | |
networks: | |
- internal |
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
type RequireOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { | |
[K in Keys]-?: Required<Pick<T, K>>; | |
}[Keys]; | |
type PartialOnlyOne<T, Keys extends keyof T = keyof T> = Pick<T, Exclude<keyof T, Keys>> & { | |
[K in Keys]?: Partial<Pick<T, K>>; | |
}[Keys]; |
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
function toCelsius(fahrenheit) { | |
return (fahrenheit - 32) * 5 / 9; | |
} | |
function toFahrenheit(celsius) { | |
return (celsius * 9 / 5) + 32; | |
} |