Skip to content

Instantly share code, notes, and snippets.

View un4ckn0wl3z's full-sized avatar
🎯
Complex solutions may seem impressive, but simplicity often leads to success.

Anuwat Khongchuai un4ckn0wl3z

🎯
Complex solutions may seem impressive, but simplicity often leads to success.
View GitHub Profile
class Service {
static async task(numv: number){
return new Promise((resolve, reject) => {
setTimeout(() => {
console.log('Task completed ' + numv)
resolve(numv)
}, 3000)
})
import { StringDecoder } from 'string_decoder';
import * as brotli from 'brotli';
export class CompressionHelper {
static tryBrotliCompress(rawStringData: string): string {
const buf = Buffer.from(rawStringData, 'utf8');
const bufBytes = new Uint8Array(buf)
const compressChunks = brotli.compress(bufBytes);
if(compressChunks === null) return Buffer.from(bufBytes).toString("base64");
import { Stack } from '@datastructures-js/stack';
import { v4 as uuidv4 } from 'uuid';
export class MessageStateHelper {
private static messagesStack = new Stack<string>();
public static isAllMessagesCompleted(): boolean {
return this.messagesStack.isEmpty();
}
@un4ckn0wl3z
un4ckn0wl3z / hon.cmd
Created September 1, 2023 06:54
Play HoN offline with bot and enable test suite command
setsave "ui_forceenabletesting" "true"
startgame practice GameName map:caldavar allheroes:true devheroes:true nostats:true mode:botmatch norespawntimer:true easymode:true
@un4ckn0wl3z
un4ckn0wl3z / client.conf
Created August 31, 2023 17:09 — forked from steos/client.conf
openvpn config with lan gaming support
client
# specify server ip address here
remote <SERVER-IP>
dev tap
# name of the windows network connection
dev-node openVPN
import { Injectable } from "@nestjs/common";
import { TelemetryClient } from "applicationinsights";
import { AvailabilityTelemetry, DependencyTelemetry, EventTelemetry, ExceptionTelemetry, Identified, MetricTelemetry, NodeHttpDependencyTelemetry, NodeHttpRequestTelemetry, PageViewTelemetry, RequestTelemetry, Telemetry, TelemetryType, TraceTelemetry } from "applicationinsights/out/Declarations/Contracts";
const AZURE_APP_INSIGHTS_CONN_STRING = process.env.AZURE_APP_INSIGHTS_CONN_STRING
@Injectable()
export class ApplicationInsightsService {
private _instance: TelemetryClient
import { Logger, Module } from '@nestjs/common';
import { MongoClient } from 'mongodb';
import { MongoProperty } from './mongo-property.interface';
@Module({
providers: [
{
provide: 'PAYMENT_DATABASE_CONNECTION',
useFactory: async (): Promise<MongoProperty> => {
const maxReconnectAttempts = 5;
import { CustomSingletonLoggerService, DataAlreadyExistsError, LogDto, SingletonFlushSummaryLog, SingletonLoggerHelperService } from "@eqxjs/stub"
import { Injectable } from "@nestjs/common"
// export declare class LogDto {
// appName?: string;
// componentVersion?: string;
// componentName?: string;
// broker?: string;
// channel?: string;
// useCase?: string;

Updating nested array inside array mongodb

For example: We have a document like this one;

clubs:{
cid: 1,
cname: "Fenerbahce",
cplayers: [{

pid: 1,

#!/bin/bash
# Define the Kafka broker and topic
BROKER_LIST="localhost:9092"
TOPIC="mfaf.exampleTopic"
# Loop to simulate load test
while true; do
# Generate some random JSON data and save it to a file
# echo "{\"key\": \"value\"}" > m.json