Skip to content

Instantly share code, notes, and snippets.

View steamonimo's full-sized avatar

steamonimo

  • Germany
View GitHub Profile
@steamonimo
steamonimo / visualstudio_commands.md
Last active September 4, 2022 00:03
Visual Studio: commands

Visual Studio: shell commands

Compare two text files

devenv /diff file1.txt file2.txt

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)

{

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

@steamonimo
steamonimo / mongodb_commands.md
Last active April 28, 2021 18:29
MongoDB: commands

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

@steamonimo
steamonimo / windows_commands.md
Last active April 28, 2021 18:30
Windows commands

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
@steamonimo
steamonimo / openssl_commands.md
Last active April 28, 2021 18:30
openssl: commands

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

@steamonimo
steamonimo / mongodb_csharp.md
Last active April 28, 2021 18:30
MongoDB: c#

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

@steamonimo
steamonimo / mongodb_queries.md
Last active June 16, 2021 23:13
MongoDB: queries

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