Skip to content

Instantly share code, notes, and snippets.

View Avi-E-Koenig's full-sized avatar
🎯
Focusing

Avi E. Koenig Avi-E-Koenig

🎯
Focusing
View GitHub Profile
@Avi-E-Koenig
Avi-E-Koenig / client.ts
Last active January 19, 2025 14:52
Whatsapp web js
import { Client, LocalAuth, WAState } from "whatsapp-web.js";
const _createClientInstance = (): Client => {
global.client = global.client?.getState()
? global.client
: new Client({
authStrategy: new LocalAuth({
clientId: "client",
}),
});
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"command": "npm run start:dev",
"name": "Run Server",
"request": "launch",
@Avi-E-Koenig
Avi-E-Koenig / logger.js
Created January 3, 2025 13:51
Winston file logger
import winston from 'winston';
import asyncLocalStorage from './request-context.js';
// Custom format to handle errors properly
const errorStackFormat = winston.format((info) => {
if (info instanceof Error) {
return Object.assign({}, info, {
stack: info.stack,
message: info.message,
});
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"command": "npm run start:dev",
"name": "Run Server",
"request": "launch",
import puppeteer from 'puppeteer';
import sharp from 'sharp';
import logger from '../../services/logger.js';
import PDFDocument from 'pdfkit';
import { promisify } from 'util';
import fs from 'fs';
import { Recipe } from 'muhammara';
export async function convertToPdf(url, pdfOptions = {}) {
const browser = await puppeteer.launch();
@Avi-E-Koenig
Avi-E-Koenig / Monday_API
Last active November 21, 2023 04:15
Get Volunteers
{
"info": {
"_postman_id": "4ff3f646-3ee3-4227-b941-4a1467b9a478",
"name": "Monday_API",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
"_exporter_id": "3883128"
},
"item": [
{
"name": "Get Volunteer list",
@Avi-E-Koenig
Avi-E-Koenig / file.vue
Created November 9, 2023 11:50
Vue Snippet work
<template>
<v-container class="new-mone" v-if="formSchema">
<v-row>
<v-col>
<h1>
{{ formName }}
</h1>
</v-col>
</v-row>
<v-row>
@Avi-E-Koenig
Avi-E-Koenig / GenericBreadcrumbs.tsx
Created May 21, 2023 13:57
Dynamic React Mui Breadcrumbs
import { Breadcrumbs, Link as MuiLink, Typography } from '@mui/material';
import { Link } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { useLocation } from 'react-router-dom';
type BreadCrumbSegment = { path: string; name: string };
function BreadCrumbs() {
const location = useLocation();
@Avi-E-Koenig
Avi-E-Koenig / useLocaleTimeAgo.ts
Created March 22, 2023 15:08
useTimeAgo composable for Vue3
import AppLogger from '@/services/AppLogger'
import type { UseTimeAgoMessages, UseTimeAgoUnitNamesDefault } from '@vueuse/core'
import { useI18n } from 'vue-i18n'
import { useTimeAgo } from '@vueuse/core'
const messages = {
en: {
common: {
timeAgo: {
'just-now': 'just now',
@Avi-E-Koenig
Avi-E-Koenig / experiment.js
Created March 21, 2023 12:14
some chatgpt fun
const { errMessage } = require('../errController');
const Event = require('./event.model');
const Setting = require('./setting.model');
const aggregateQueryOld = [
{
$match: {
$expr: {
$and: [
{ $isArray: '$targetAudience' },