Skip to content

Instantly share code, notes, and snippets.

Avatar

steamonimo

  • Germany
View GitHub Profile
View blazor_radzen.md

Blazor: c# development

input field: update bound variable while typing

razor

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

code

public string variable {get; set;}

void OnInput(string value)
{
View mongodb_replset.md

MongoDB: replication sets on Debian

  • start with fresh VM!
  • install Debian with XFS file system!
  • determine pool of fixed IPs (192.168.1.231-235)
  • DNS assignment of computer names (mongodb1.corp.com-mongodb5.corp.com) to IPs
  • we assume that our DNS server has the IP 192.168.1.9
  • do not create mondodb user accounts yet!

Give VM1 static IP

View mongodb_commands.md

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

View windows_commands.md

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
View openssl_commands.md

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
View mongodb_csharp.md

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
View mongodb_queries.md

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}});