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
import { dirname } from 'path'
import { fileURLToPath } from 'url'
import { FlatCompat } from '@eslint/eslintrc'
import prettier from 'eslint-plugin-prettier'
import jsxA11y from 'eslint-plugin-jsx-a11y'
const __filename = fileURLToPath(import.meta.url)
const __dirname = dirname(__filename)
const compat = new FlatCompat({ baseDirectory: __dirname })
-- =========================================
-- Create a read-only SQL Server login/user for all databases
-- Usage: Set @username and @password as needed
-- =========================================
-- Step 1: Declare variables for username and password
DECLARE @username NVARCHAR(128) = N'USERNAME';
DECLARE @password NVARCHAR(128) = N'PASSWORD';
-- Step 2: Create the login at the server level (if not already created)
'use client';
import React, { createContext, JSX, useCallback, useContext, useEffect, useState } from "react";
import { useLocalStorage } from "@/hooks/useLocalStorage";
import { THEME, LOCALE } from "@/theme";
// import type { ThemeMode, LocaleType } from '@/theme';
interface ApplicationConfigsProps {
children: JSX.Element;
}
# Check if script is running as Administrator
$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)
if (-not $isAdmin) {
Write-Error "This script must be run as Administrator. Exiting..."
exit 1
}
# Step 1: Backup and remove NODE_ENV from system environment
$originalNodeEnv = [System.Environment]::GetEnvironmentVariable("NODE_ENV", "Machine")
[System.Environment]::SetEnvironmentVariable("NODE_ENV", $null, "Machine")
// React and types
import * as React from 'react';
import type { Dayjs } from 'dayjs/esm';
// Dayjs and locales
import 'dayjs/locale/he';
import 'dayjs/locale/en';
// MUI X Date Pickers
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider';
@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();