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
export function formatFixedPoint(val: bigint, decimals = 18): string { | |
const l = val / 10n ** BigInt(decimals); | |
const r = val % 10n ** BigInt(decimals); | |
if (r === 0n) { | |
return l.toString(); | |
} | |
return `${l}.${r.toString().padStart(decimals, "0").replace(/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
import { | |
CallHandler, | |
ExecutionContext, | |
Injectable, | |
NestInterceptor, | |
} from "@nestjs/common"; | |
import { Observable, map } from "rxjs"; | |
export class PickOptions { | |
type?: any; |
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 { Global, Module } from "@nestjs/common"; | |
import { ConfigService } from "@nestjs/config"; | |
@Global() | |
@Module({ | |
providers: [ | |
{ | |
provide: LockService, | |
inject: [ConfigService], |
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
version: '2' | |
services: | |
etcd-1: | |
image: gcr.io/etcd-development/etcd:v3.3.9 | |
restart: always | |
ports: | |
- 2379 | |
- 2380 | |
volumes: |
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 { BroadcastChannel, createLeaderElection } from 'broadcast-channel' | |
import React from 'react' | |
const channels = {} | |
export function useBroadcastLeader(id = 'default') { | |
const [isBroadcastLeader, setIsBroadcastLeader] = React.useState(false) | |
React.useEffect(() => { | |
if (!channels[id]) { |
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 { 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 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 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 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 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 |
NewerOlder