Posting with Windows Auth

Problem: core controller method:

public async void StartWorkflow([FromBody] WFInitiationDataModel model)

Use powershell to test it:

$data = @{
    "sysName" = "LTPS"        

$payload = ConvertTo-Json $data

$url = "http://localhost:5000/api/startwf"
Write-Host "POST:$url"

$response = $payload | Invoke-WebRequest -uri $url -Method Post -UseDefaultCredentials -ContentType "application/json" -TimeoutSec 21600

PowerShell SQL Select => Excel

This function runs an SQL query and displays results in a new Excel sheet:

function SQLtoXLS {
    param([String]$sql, [String]$server, [String]$db)

    $tbl = Invoke-Sqlcmd -ServerInstance $server -Database $db -Query $sql

    $xl = New-Object -comobject Excel.Application
    $xl.Visible = $False
    $xl.DisplayAlerts = $False

    $wb = $xl.WorkBooks.Add()
    $ws = $wb.Worksheets.Item(1)
    $ws.Name = "SELECT results"

    $r = 0

    if($tbl.Count -gt 0)
        $rowCount = $tbl.Count
        $colCount = $tbl[0].ItemArray.Count

        $grid = New-Object 'string[,]' ($rowCount + 1), $colCount

        $c = 0
        foreach($col in $tbl[0].Table.Columns)
            $grid[$r, $c] = $col.ColumnName

        foreach($row in $tbl)
            $c = 0
            foreach($i in $row.ItemArray)
                $grid[$r, $c] = [String]$i

        $ws.Range($ws.Cells.Item(1,1), $ws.Cells.Item($rowCount + 1, $colCount)).Value = $grid
        $ws.Range($ws.Cells.Item(1,1), $ws.Cells.Item(1, $colCount)).Font.FontStyle = "Bold"
        $ws.Cells.Item(1, 1).Value2 = "No results"

    $ws.Columns.AutoFit() | Out-Null
    $ws.Rows.AutoFit() | Out-Null
    $xl.Visible = $True

Usage example:

SQLtoXLS -sql "SELECT * FROM sql_table" -server "localhost" -db "my_db"

Parsing Excel document using PowerShell

$xlsFilePath = "C:\Excel_file.xlsx"

$xl = New-Object -comobject Excel.Application
$xl.Visible = $False
$xl.DisplayAlerts = $False
$wb = $xl.WorkBooks.Open($xlsFilePath)
$ws = $wb.Worksheets.Item(1)

$value = $ws.Cells.Item(1, "A").Value2
Write-Host $value
# ...


[System.Runtime.Interopservices.Marshal]::ReleaseComObject($xl) | Out-Null

Unity physics

If you want to use physics engine for your object (gravity, forces), make sure to add Rigidbody compoment. To interact with other physics objects attach collider object.
Rigitbody properties:
Mass – helps to figure out winner of collision
Drag – how quickly it will come to rest.
Angular Drag – rotation friction (opposite torque)
Use Gravity – impacted by general gravity or not. (Edit->ProjectSettings->Physics)
Is Kinematic – will rigidbody react to physics. Physics objects that affects others, but are not affected themselves. Translate updates collision data when object is moved. Static objects cause all objects to be reevaluated.
Interpolate – solve jittering if it was created by moving rigidbody. Interpolate smoothes transform based on previous frame. Extrapolate – smoothes based on predicted next frame.
Collision Detection – type of detection. Continuous for fast moving objects that are interacting with static geometry. Continuous Dynamic – fast moving and interacting with other dynamic objects.
Constraints – possible to lock axes for position or rotation.

AddForce(Vector3 direction & magnitude, [ForceMode mode]) – move object by adding forces;
Acceleration – continuous changes not affected by mass,
Force(default) – for continuous changes affected by mass,
Impulse – instant change affected by mass,
VelocityChange – instant change not affected by mass.
Forces ar dampened by rigidbody drag property.

AddTorque(Vector3 torque, [ForceMode mode]) is similiar for rotations

p.s transform.forward – shortcut to z axis of localspace of object.
Physics materials describes surface of object for friction and how object material affects it – like tenis ball vs. bowling ball

Generic serialization/deserialization

        public static void Serialize<T>(String file, T data)
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            using (StringWriter writer = new StringWriter())
                serializer.Serialize(writer, data);
                File.WriteAllText(file, writer.ToString());

        public static T Deserialize<T>(String file)
            String xml = File.ReadAllText(file);
            XmlSerializer serializer = new XmlSerializer(typeof(T));
            using (StringReader reader = new StringReader(xml))
                return (T)(serializer.Deserialize(reader));

Blender models in unity shows as documents

For some weird reason, after opening unity project, suddenly blender models were shown as documents not models. Existing scene objects reports to be missing. Solutions:
1) Try reseting model in unity (this helped for me)

2) Reimport the resources (right click on asset > import all).
3) Still nothing? reinstall blender with admin rights, try step 1 again.