Using telnet as a tool for troubleshooting network port connections

Note that you may need to enable telnet on your workstation (see this Article: How to enable telnet for troubleshooting when CMD reports: “‘telnet’ is not recognized as an internal or external command”)

Once you have telnet enabled, follow these steps:

  1. Open a command prompt
  2. Type in “telnet <IP ADDRESS OF SERVER PC> <PORT>” and press enter.
  3. For example, you would type “telnet 123.45.67.89 1521”
  4. If a blank screen appears then the port is open, and the test is successful.
  5. If you receive a connecting… message or an error message then something is blocking that port.  It could be the Windows firewall, a third party firewall like your anti-virus software, or an institutional hardware firewall between the workstation and the server.

Source: Using telnet as a tool for troubleshooting connection problems on hosted Voyager servers – Ex Libris Knowledge Center

Rxjs debugging subscribers

I wanted to see how many listeners there was for a certain subject, and where they reside in the source code.
Here is how in chrome devtools, put a breakpoint before the subjects .next() call. And inspect the subject:

observers array count = number of “listeners”
FunctionLocation = source code reference

(Context: Angular v11, rxjs)

Use of Enums in Angular 8+ HTML template

in the TS

import { SomeEnum } from 'path-to-file';

public get SomeEnum() {
  return SomeEnum; 
}

in the HTML use

*ngIf="SomeEnum.someValue === 'abc'"

EDIT: Time goes by and we learn more as a developer, the approach I’m using right now doesn’t use the get method. Both solutions work, just choose the one you like the most.

in the TS

import { SomeEnum } from 'path-to-file';

export class ClassName {
  readonly SomeEnum = SomeEnum;
}

in the HTML use

*ngIf="SomeEnum.someValue === 'abc'"

From: Use of Enums in Angular 8 HTML template for *ngIf – Stack Overflow

Find out which process is locking a file or folder in Windows

You can use the Resource Monitor for this which comes built-in with Windows 7, 8, 10 and 11! Open Resource Monitor, which can be found By searching for Resource Monitor or resmon.exe in the start menu, or As a button on the Performance tab in your Task Manager Go to the CPU tab Use the search field in the Associated Handles section See blue arrow in screen shot below When you’ve found the handle, you can identify the process by looking at the Image and/or PID column. You can then try to close the application as you normally would, or, if that’s not possible, just right-click the handle and kill the process directly from there. Easy peasy!

Resource Monitor screenshot

Source: filesystems – Find out which process is locking a file or folder in Windows – Super User

Log info with tracepoints – Visual Studio (Windows) | Microsoft Docs

Tracepoints allow you to log information to the Output window under configurable conditions without modifying or stopping your code. This feature is supported for both managed languages (C#, Visual Basic, F#) and native code as well as languages such as JavaScript and Python.

Source: Log info with tracepoints – Visual Studio (Windows) | Microsoft Docs

SharpLab Online Tool – Reveal what happens during compilation of C#

SharpLab is a .NET code playground that shows intermediate steps and results of code compilation. Some language features are thin wrappers on top of other features — e.g. using() becomes try/finally. SharpLab allows you to see the code as compiler sees it, and get a better understanding of .NET languages.

Recent versions include experimental support for running code, with some limitations.

Online tool: SharpLab

Readme: https://discoverdot.net/projects/sharplab

Retry and fault handling in C# .NET

Sometimes you need to implement some sort of retry logic if an error occurs in a c# program.

Existing libraries for retry and fault handling:
Polly
http://www.thepollyproject.org/

CircuitBreaker.Net
https://github.com/alexandrnikitin/CircuitBreaker.Net

Read more about the related Circuit Breaker pattern:

CircuitBreaker
http://martinfowler.com/bliki/CircuitBreaker.html

Circuit Breaker Pattern
https://msdn.microsoft.com/en-us/library/dn589784.aspx

Error handling and policies in general:

https://en.wikipedia.org/wiki/Exception_handling#Restarts_separate_mechanism_from_policy

https://docs.microsoft.com/en-us/dotnet/standard/exceptions/

https://stackify.com/csharp-exception-handling-best-practices/

Working with Equals() and GetHashCode() to compare your objects in C#

In general these interfaces and methods are good to implement when working with comparing objects of the same type in C#:

Interfaces:
System.IEquatable<T> – strongly typed implementation
IComparable<T> – strongly typed implementation

Override methods:
An override of Object.Equals(Object).
An override of Object.GetHashCode().
An override of Object.ToString() is usually a good idea.
Operator overloads for operator == and operator !=.

General rule of GetHashCode():
If two objects is equal then their hashvalues should be the same.
E.g.:
If Equals == true then
x.GetHashCode() == y.GetHashCode()
GetHashCode() is frequently used by collections like Dictionary<Key, Value> and HashSet<T>

Links:
Guidelines for Overloading Equals() and Operator == (C# Programming Guide)
https://msdn.microsoft.com/en-us/library/ms173147.aspx