Skip to content

Instantly share code, notes, and snippets.

View SPodjasek's full-sized avatar

Sebastian Podjasek SPodjasek

View GitHub Profile
SPodjasek /
Created February 11, 2024 19:34 — forked from jasonk/
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 /
Last active February 2, 2024 13:43
Show status of git repositories found in subdirectories
set -e
function check_git_status() {
local DARK_GRAY="\x1B[0;30m"
local GRAY="\x1B[1;30m"
local LIGHT_GRAY="\x1B[0;37m"
local RED="\x1B[1;31m"
local NO_COLOUR="\x1B[0m"
SPodjasek /
Last active August 21, 2023 12:41
MonoDB useful queries

Show connection count...

  • by appName:
    db.currentOp(true).inprog.reduce((acc,conn) => { 
      var appName = conn.appName ?? ''; acc[appName] = (acc[appName] ?? 0) + 1; return acc;
    }, {});
  • by client ip

db.currentOp(true).inprog.reduce((acc,conn) => {

SPodjasek /
Created January 16, 2023 11:23 — forked from mrpeardotnet/
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.


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;
import 'dart:math' show max;
import 'package:flutter/foundation.dart';
import 'package:flutter/widgets.dart';
import 'package:webview_flutter/webview_flutter.dart';
class ExpandableWebView extends StatefulWidget {
final String url;
final EdgeInsets padding;
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
def flutterRoot = localProperties.getProperty('flutter.sdk')
if (flutterRoot == null) {
SPodjasek / runlog.1
Last active December 22, 2017 16:17
Mojo::RabbitMQ::Client issue #11
-> "AMQP\1\1\0\t"
<- "\1\0\0\0\0\1\322\0\n\0\n\0\t\0\0\1\255\fcapabilitiesF\0\0\0\265\22publisher_confirmst\1\32exchange_exchange_bindingst\1\nbasic.nackt\1\26consumer_cancel_notifyt\1\22connection.blockedt\1\23consumer_prioritiest\1\34authentication_failure_closet\1\20per_consumer_qost\1\fcluster_nameS\0\0\0\22rabbit\@seba-M17xR4\tcopyrightS\0\0\0.Copyright (C) 2007-2015 Pivotal Software, Inc.\13informationS\0\0\0005Licensed under the MPL. See\bplatformS\0\0\0\nErlang/OTP\aproductS\0\0\0\bRabbitMQ\aversionS\0\0\0\0053.5.7\0\0\0\16AMQPLAIN PLAIN\0\0\0\5en_US\316"
-- Connection::Start {product: RabbitMQ, version: 3.5.7}
-> "\1\0\0\0\0\0\x{c3}\0\n\0\13\0\0\0\x{85}\13informationS\0\0\0-\bplatformS\0\0\0\4Perl\aproductS\0\0\0\26Mojo::RabbitMQ::Client\aversionS\0\0\0\0050.0.9\bAMQPLAIN\0\0\0#\5LOGINS\0\0\0\5guest\bPASSWORDS\0\0\0\5guest\5en_US\x{ce}"
<- "\1\0\0\0\0\0\f\0\n\0\36\0\0\0\2\0\0\0<\316"
-- Connection::Tune {frame_max: 131072, heartbe
SPodjasek /
Created January 21, 2016 10:44
Komodo IDE perlbrew wrapper
source ~/perl5/perlbrew/etc/bashrc
env perl $@
SPodjasek / gist:8140175
Created December 26, 2013 23:27
Proper way to develop jQuery plugins
(function (factory) {
if (typeof define === 'function' && define.amd) {
define(["jquery"], factory);
} else {
}(function ($) {
* ...