PowerShell, Cmdlet Output to File

To send the output of a PowerShell cmdlet to a file use Out-File.

Syntax:

.\pwrshl.ps1 | Out-File -FilePath .\my.log

Notes:

  • Use the -NoClobber to prevent from overriding an existing output file
  • There are ways to specify the output file encoding type

References:

https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/out-file

Shared by joubin on Thu Apr 08 2021

SUBSTRING (Transact-SQL)

The SUBSTRING function has the following syntax:

SUBSTRING ( expression, start, length )

Notes:

  1. It's an error to have a NULL expression
  2. The start is 1 based

To get around the NULL expression scenario, use the CASE WHEN ... expression in TSQL.

References:

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact-sql

https://docs.microsoft.com/en-us/sql/t-sql/functions/substring-transact-sql

Shared by joubin on Wed Apr 07 2021

Setting commit user email, Git

Global Git configuration: (Windows) c:/users/{user}/.gitconfig

git config --global user.email "email@example.com"

git config --global user.name "John Doe"

Single Repository Level: /.git/config

git config user.email "email@example.com"

git config user.name "John Doe"

References:

Shared by joubin on Wed Feb 20 2019

forkJoin, TypeScript

Use Case: In cases where there are multiple HTTP requests and the code needs to wait until the responses from all the HTTP requests are available.

forkJoin waits for each HTTP request to complete and group’s all the observables returned by each HTTP call into a single observable array and finally return that observable array.

The result of a forkJoin is an Observable. The data returned when all of the HTTP request are fullfilled, is an array with elements in the same order as they were presented in the array passed to the forkJoin rxjs library function.

References:

https://medium.com/@swarnakishore/performing-multiple-http-requests-in-angular-4-5-with-forkjoin-74f3ac166d61

https://angular.io/guide/rx-library

https://www.npmjs.com/package/rxjs

Shared by joubin on Tue Nov 10 2020

OData, Functions vs. Actions

Actions are operations exposed by an OData service that MAY have side effects when invoked. Actions MAY return data but MUST NOT be further composed with additional path segments.

Functions are operations exposed by an OData service that MUST return data and MUST have no observable side effects.

These are similar to SQL functions versus stored procedures.

In SQL, functions are generally used to query, whereas stored procedures could be used for both query and modifications (update/insert/delete).

References:

https://stackoverflow.com/questions/38089753/odata-v4-what-are-functions-and-actions-in-simple-terms

Shared by joubin on Wed Aug 12 2020

ngOnChanges lifecycle hook, Angular

Changes are only detected when the databound input property is changed via a template's binding. If the changes are done manually to a property on a component class, the change is not detected.

References:

https://medium.com/@isaacplmann/ngonchanges-only-runs-when-the-input-change-comes-from-a-template-binding-like-component-8797b759ba0b

Shared by joubin on Mon Nov 02 2020

Tsql, Rename Table Column

sp_rename '{table_name}.{column_old_name}', '{column_new_name}', 'COLUMN';

Microsoft recommends that you drop and recreate the table so that scripts and stored procedures are not broken.

https://www.techonthenet.com/sql_server/tables/alter_table.php

Shared by joubin on Thu Jan 04 2018

Tsql, Rename table

EXEC sp_rename 'schemaName.oldTableName', 'newTableName';

References:

https://docs.microsoft.com/en-us/sql/relational-databases/tables/rename-tables-database-engine

Shared by joubin on Wed Sep 23 2020

Software Test Fixture

A test fixture sets up the system under test (SUT) for the software testing process by initializing it (configuration and/or data) satisfying any preconditions the system may have.

Example: initialize a database with known parameters before running a test.

This allows for tests to be repeatable, which is one of the key features of an effective test framework.

In a non-software context, such as circuit boards, a test fixture is a setup or another device designed to hold the device under test (DUT) in place and allow it to be tested.

References:

https://en.wikipedia.org/wiki/Test_fixture

Shared by joubin on Wed Sep 21 2016

TSQL - Find duplicates in a column

SELECT   {col_name},
         COUNT({col_name}) AS dupe_cnt
FROM     {table_name}
GROUP BY {col_name}
HAVING   COUNT({col_name}) > 1
ORDER BY COUNT({col_name}) DESC

Replace:

  1. {col_name} with the column name being examined
  2. {table_name} with the respective table name

Shared by joubin on Tue Jun 23 2020

COL_LENGTH

Returns the table's column length in bytes:

COL_LENGTH ( 'table' , 'column' )

References:

https://docs.microsoft.com/en-us/sql/t-sql/functions/col-length-transact-sql

Shared by joubin on Wed Apr 29 2020

Using MSI for debugging in Visual Studio

To debug against Azure (e.g. getting access to Key Vault etc.) configure Visual Studio to use the account with which it uses to send credentials to Azure.

This configuration is under: Options => Azure Service Authentication => Account Selection

References:

https://docs.microsoft.com/en-us/azure/azure-app-configuration/howto-integrate-azure-managed-service-identity?tabs=core2x

https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview

Shared by joubin on Fri Apr 17 2020

Azure Data Factory Trigger files

The trigger files are stored in a location similar to:

/common/workflows/datafactory/trigger/*.json

Each trigger has the following information:

  • the schedule/condition defintion
  • a collection of pipelines references

References:

https://docs.microsoft.com/en-us/azure/data-factory/concepts-pipeline-execution-triggers#schedule-trigger-definition

Shared by joubin on Fri Apr 03 2020

Roslyn & RyuJIT

Roslyn

  • The .NET Platform Compiler i.e. compiles your C# (etc) code into IL
  • Has a public API e.g. could be included in your app to compile other code on-the-fly

RyuJIT

  • Compiles the Roslyn generated IL into native code (only x64)
  • No public API available

Shared by joubin on Thu Apr 02 2020

tracert, Windows

The TRACERT diagnostic utility determines the route to a destination by sending Internet Control Message Protocol (ICMP) echo packets to the destination.

References:

https://support.microsoft.com/en-ca/help/314868/how-to-use-tracert-to-troubleshoot-tcp-ip-problems-in-windows

Shared by joubin on Tue Mar 31 2020

.NET Portability Analyzer

The .NET Portability Analyzer is an open source tool that is utitlized to analyze assemblies, files or directory of files for compatibility across .NET implementations.

This tool reports on the compatibility of the current app across .NET implementations.

It comes as:

  1. Visual Studio Extension - analyzes individual assemblies/projects or the solution
  2. A console app (ApiPort) - analyzes assemblies/files/directories

References:





Shared by joubin on Fri Sep 06 2019

Debugging modes, VS Code

In VS Code, there are two core debugging modes, Launch and Attach.

  1. Starting in the browser
    • When you open DevTools in a browser, you are attaching DevTools to the open browser tab.
  2. Starting in the code editor
    • The editor launches your process, and it automatically attaches its debugger to the newly launched process.

References:

Shared by joubin on Fri Aug 09 2019

Launch Configuration, VS Code

A configuration file allows you to configure and save debugging setup details.

VS Code keeps debugging configuration information in a launch.json file located in a .vscode folder in your workspace (project root folder)

References:

Shared by joubin on Fri Aug 09 2019

Angular Framework app version

1. ng --version (or ng v)

2. Open Developer Tools in the browser. Under the 'Elements' tab, look for html/body/app-root[ng-version]

3. To render the Angular version on a page, import VERSION from @angular/cli.

const version = VERSION.full;







Shared by joubin on Wed Jul 31 2019