Skip to content

Instantly share code, notes, and snippets.

View wmakeev's full-sized avatar
💭
💻

Makeev Vitaliy wmakeev

💭
💻
View GitHub Profile
@wmakeev
wmakeev / report-stock-all-current.js
Last active January 21, 2023 06:25
[МойСклад - остатки] #moysklad #stock
// https://gist.githubusercontent.com/wmakeev/09aad933ef9bcb1a8804e3449ec5ff74
import { env } from "../env.js";
/**
* Возвращает остатки МойСклад
*
* @param {import('moysklad').Instance} ms
*/
export async function getMoyskladStock(ms) {
@wmakeev
wmakeev / createInternalOrdersFromSales.js
Last active September 1, 2024 13:12
[МойСклад - Букмарклеты] #moysklad #bookmarklet
/**
* Создание внутренних заказов для пополнения остатков магазинов по проданным
* за последние 7 дней товарам
*/
(async () => {
// Функция для отображения ошибки
const error = (msg) => {
alert(msg);
throw new Error(msg);
@wmakeev
wmakeev / index.js
Last active January 23, 2023 05:20
[Test bookmarklet] #bookmarklet #test
import { addValue } from "./module2.js";
export const foo = (name) => {
console.log(`${addValue(name)} in index.js`);
};
window._my_foo = foo;
@wmakeev
wmakeev / mergePdf.js
Last active January 24, 2023 06:24
[Merge PDF] #pdf #merge
// gist: https://gist.github.com/wmakeev/ede27b97b3d227258684c5e80bf7fca3
import { PDFDocument } from "pdf-lib";
/**
* Merges pdf files in one (with pdf-lib)
*
* @see https://stackoverflow.com/a/68482188
*
* @param {ArrayBuffer[]} pdfsToMerge
@wmakeev
wmakeev / object.entries.js
Last active October 22, 2023 11:57
[TypeScript type fixes] #typescript #fix
/** @type {TypedEntries} */
export function typedEntries(obj) {
// @ts-expect-error ignore
return Object.entries(obj);
}
/** @type {TypedFromEntries} */
export function typedFromEntries(entries) {
return Object.fromEntries(entries);
}
@wmakeev
wmakeev / redirect.js
Last active January 26, 2023 09:40
[Redirect bookmarklet] #bookmarklet #redirect #url #queystring
(() => {
// 1. Скопировать этот код на страницу https://caiorss.github.io/bookmarklet-maker/
// 2. Заполнить название закладки
// 3. Сюда добвить ID вашей функции в Yandex.Cloud
const FUNCTION_ID = "qwertyyuio1234567890";
// 4. Тут указать название закладки с фильтром в разделе "Заказы покупателей"
const FILTER_NAME = "Все";
@wmakeev
wmakeev / settings.json
Created January 30, 2023 18:33
[$mol vscode code format settings] #mol #format #settings
{
"typescript.tsdk": "node_modules/typescript/lib",
"files.watcherExclude": {
"**/node_modules": true,
"**/-*": false
},
"search.exclude": {
"**/node_modules": true,
"**/-*": true
},
@wmakeev
wmakeev / example.js
Last active October 16, 2023 06:34
[ESM __dirname] #esm #dirname #filename #node
import * as url from "node:url";
/**
* Returns `__dirname` like value for ESM
*
* ```js
* const dirname = getDirname(import.meta.url)
* ```
* @link https://blog.logrocket.com/alternatives-dirname-node-js-es-modules/
* @param {string} fileUrl
@wmakeev
wmakeev / harp-sample-1.ts
Last active March 1, 2023 03:41
$mol samples #mol #sample
// prettier-ignore
export class $my_model extends $mol_object {
static type() {
return ''
}
@$mol_mem_key
static item( id: string ) {
@wmakeev
wmakeev / load.ts
Last active March 28, 2023 11:58
[$mol bach loader adaptation (concept)] #mol #batch
namespace $ {
/** Элемент очереди на массовую загрузку */
type Queue_item = {
id: string
resolve: ( value: unknown ) => void
reject: ( reason?: any ) => void
signal: AbortSignal
}