Skip to content

Instantly share code, notes, and snippets.

View SPodjasek's full-sized avatar

Sebastian Podjasek SPodjasek

View GitHub Profile
@SPodjasek
SPodjasek / README.md
Created February 11, 2024 19:34 — forked from jasonk/README.md
MongoDB Update Pipeline Tricks

Starting with MongoDB 4.2, you can use [aggregation pipelines to update documents][$pipelines]. Which leads to some really cool stuff.

For example, prior to this you could easily add sub-documents to an array using [$addtoSet][$addtoSet], and you could remove documents from an array using [$pull][$pull], but you couldn't do both in the same operation, you had to send two separate update commands if you needed to remove some and add some.

With 4.2, now you can, because you can format your update as a pipeline, with multiple $set and $unset stages, which makes those things possible. However, since this is so new I had a really hard time finding examples of many of the things I wanted to do, so I started to collect some here for my reference (and yours).

See also:

@SPodjasek
SPodjasek / PVE-HP-ssacli-smart-storage-admin.md
Created January 16, 2023 11:23 — forked from mrpeardotnet/PVE-HP-ssacli-smart-storage-admin.md
HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

HP Smart Storage Admin CLI (ssacli) installation and usage on Proxmox PVE (6.x)

Why use HP Smart Storage Admin CLI?

You can use ssacli (smart storage administrator command line interface) tool to manage any of supported HP Smart Array Controllers in your Proxmox host without need to reboot your server to access Smart Storage Administrator in BIOS. That means no host downtime when managing your storage.

CLI is not as convenient as GUI interface provided by BIOS or desktop utilities, but still allows you to fully manage your controller, physical disks and logical drives on the fly with no Proxmox host downtime.

ssacli replaces older hpssacli, but shares the same syntax and adds support for newer servers and controllers.

Installation

@SPodjasek
SPodjasek / Formik-Autosave.tsx
Last active August 2, 2022 14:56 — forked from jaredpalmer/Formik-Autosave.jsx
Formik-Autosave with internal state for holding submitted values and optional visible status presentation
import { useFormikContext } from 'formik';
import debounce from 'lodash/debounce';
import React, { useCallback, useEffect, useState } from 'react';
import isEqual from 'react-fast-compare';
type AutoSaveFieldsStates = 'changed' | 'saved' | undefined;
export type AutoSaveFieldsStatusRenderer = (
state: 'submitting' | AutoSaveFieldsStates
) => React.ReactNode;