Skip to content

Instantly share code, notes, and snippets.



  • Germany
View GitHub Profile

Blazor: c# development

input field: update bound variable while typing


@bind-Value="@variable"  @oninput="@(args => OnInput(args.Value.ToString()))"


public string variable {get; set;}

void OnInput(string value)

MongoDB: replication sets on Debian

  • start with fresh VM!
  • install Debian with XFS file system!
  • determine pool of fixed IPs (
  • DNS assignment of computer names ( to IPs
  • we assume that our DNS server has the IP
  • do not create mondodb user accounts yet!

Give VM1 static IP


MongoDB: shell commands

Restore to new or existing database

mongorestore --db NewDatabase FolderOfOldDatabaseDump Note: if the database does exist then the data will be partially overwritten

Restore to existing database and delete it before

mongorestore --drop --db ExistingDatabase FolderOfOldDatabaseDump

Restore single collection to database


Windows: powershell commands

WMI query (Powershell)

Get-CimInstance -Class Win32_SystemEnclosure | Format-Table -AutoSize

or Get-WmiObject -query "Select * from Win32_SystemEnclosure"

Delete previous Windows updates (you can not revert back)

Dism.exe /online /Cleanup-Image /StartComponentCleanup /ResetBase

OpenSSL: shell commands

Combine pem file and key file to single pfx file

openssl pkcs12 -export -inkey a.key -in a.pem -out a.pfx

Convert cer/crt file to pem file

openssl x509 -inform der -in a.cer -out a.pem

Create self signed ssl certificate

openssl req -x509 -newkey rsa:4096 -keyout a.key -out a.pem -days 365

MongoDB: c# development

Async linq needs these imports

using MongoDB.Driver;
using MongoDB.Driver.Linq;

Async query with join returning object from collection

var query = (from a in collectionA.AsQueryable()
             join b in collectionB on a.Id equals b.whateverId
             where a.AttributeId == 10

MongoDB: queries

Find with regular expression

db.getCollection('foo').find({"field": /.*test.*/})

Update or create field in all documents

db.getCollection('foo').updateMany({}, {$set: {field: value}})

Remove field in all documents

db.getCollection('foo').updateMany({}, {$unset: {field:1}});